From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DADBC433E6 for ; Tue, 2 Mar 2021 09:12:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6C7C164D74 for ; Tue, 2 Mar 2021 09:12:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C7C164D74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B2D6F8D00EE; Tue, 2 Mar 2021 04:12:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADBF78D0063; Tue, 2 Mar 2021 04:12:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 97CCC8D00EE; Tue, 2 Mar 2021 04:12:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0044.hostedemail.com [216.40.44.44]) by kanga.kvack.org (Postfix) with ESMTP id 80B638D0063 for ; Tue, 2 Mar 2021 04:12:31 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3B61D181AF5CA for ; Tue, 2 Mar 2021 09:12:31 +0000 (UTC) X-FDA: 77874368502.04.6159733 Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by imf06.hostedemail.com (Postfix) with ESMTP id CF614C0001F7 for ; Tue, 2 Mar 2021 09:12:29 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 02 Mar 2021 01:12:29 -0800 Received: from nvdebian.localnet (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 2 Mar 2021 09:12:26 +0000 From: Alistair Popple To: Ralph Campbell CC: "linux-mm@kvack.org" , "nouveau@lists.freedesktop.org" , "bskeggs@redhat.com" , "akpm@linux-foundation.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "John Hubbard" , "jglisse@redhat.com" , Jason Gunthorpe , "hch@infradead.org" , "daniel@ffwll.ch" Subject: Re: [PATCH v3 6/8] mm: Selftests for exclusive device memory Date: Tue, 2 Mar 2021 20:12:24 +1100 Message-ID: <4866160.ulnvbvOQiP@nvdebian> In-Reply-To: References: <20210226071832.31547-1-apopple@nvidia.com> <20210226071832.31547-7-apopple@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1614676349; bh=FeQHtfi4mCSWbQH0/aD7Oy3q/R8JrFmF5liDHR+wnLk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type: X-Originating-IP:X-ClientProxiedBy; b=HEiZZh4DK3KNf5gTFX02zJnM2b4ou/jDcSzCQDNZpPUD1j+uXhbse5auYqfmiU7Ec YXvVqk1kNu+9JT6l7F02Id1OMF+U0wEmNbvQu+/A3fXdEze7YxM7ab4F6YYYKwV/Fg Dm4znbewQozpm7A3c+OLIY1ia2ne7u3sRgRh+vejOiSB6QgLd6BMQm44HQa9cMzZFo k5ZNYwLJtxHXK1Cy2RXvbbUDWH1IntCrq79+XEho9Uqe5MtS3waXVyOSNZ7GIWALM8 B+++XLu/MiXh8eoRa+xCczpfPLRtfclfNcVGwwZ6yWPMbfL6KvN2XP1foQfzlXEZuJ iqBU0ylYO9AMQ== X-Stat-Signature: 1t57o8nrkucy3y5n35zxpwc4qjpysbrc X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CF614C0001F7 Received-SPF: none (nvidia.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=hqnvemgate26.nvidia.com; client-ip=216.228.121.65 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614676349-635289 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tuesday, 2 March 2021 10:14:56 AM AEDT Ralph Campbell wrote: > > From: Alistair Popple > > Sent: Thursday, February 25, 2021 11:19 PM > > To: linux-mm@kvack.org; nouveau@lists.freedesktop.org; > > bskeggs@redhat.com; akpm@linux-foundation.org > > Cc: linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org; dri- > > devel@lists.freedesktop.org; John Hubbard ; Ralph > > Campbell ; jglisse@redhat.com; Jason Gunthorpe > > ; hch@infradead.org; daniel@ffwll.ch; Alistair Popple > > > > Subject: [PATCH v3 6/8] mm: Selftests for exclusive device memory > > > > Adds some selftests for exclusive device memory. > > > > Signed-off-by: Alistair Popple > > One minor nit below, but you can add Thanks Ralph. Will fix that. > Tested-by: Ralph Campbell > Reviewed-by: Ralph Campbell > > > +static int dmirror_exclusive(struct dmirror *dmirror, > > + struct hmm_dmirror_cmd *cmd) > > +{ > > + unsigned long start, end, addr; > > + unsigned long size = cmd->npages << PAGE_SHIFT; > > + struct mm_struct *mm = dmirror->notifier.mm; > > + struct page *pages[64]; > > + struct dmirror_bounce bounce; > > + unsigned long next; > > + int ret; > > + > > + start = cmd->addr; > > + end = start + size; > > + if (end < start) > > + return -EINVAL; > > + > > + /* Since the mm is for the mirrored process, get a reference first. */ > > + if (!mmget_not_zero(mm)) > > + return -EINVAL; > > + > > + mmap_read_lock(mm); > > + for (addr = start; addr < end; addr = next) { > > + int i, mapped; > > + > > + if (end < addr + (64 << PAGE_SHIFT)) > > + next = end; > > + else > > + next = addr + (64 << PAGE_SHIFT); > > I suggest using ARRAY_SIZE(pages) instead of '64' to make the meaning clear. > >