Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp150807imp; Wed, 20 Feb 2019 16:26:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IbKz2jwzk29yD4AMWuJ8HRT0gHbfloErwiCzgUMJf7ghLftIAVYTDYF2FaNaZwPW/IMDIHc X-Received: by 2002:aa7:838c:: with SMTP id u12mr29424547pfm.189.1550708774588; Wed, 20 Feb 2019 16:26:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550708774; cv=none; d=google.com; s=arc-20160816; b=L5bNGwKoKerCVvzjxhlM3FfmqEyNf7kkm9Ju+T5BRN3SooJzCgMXlhnwoNtvWVWcuD CSoRBaKhwYwrA3P7z81YOQGbfl25yqppPbgiyJ8HAuuLOg65zikJBtyle0Djzp46AEZM QHSKxPrOl048/M5KE7W1G94T2c+6kWO9QojVA0yw0mmfFk0yi0Dw3c0rnYvl/OHTFYjQ 1R6Wew6RIwAEDPgK3zoBqRvdw29Yx0fDq36Vagf0wD+rops8m96PvuBHtpBvKzZppz2+ 0CFvn6hFJrLbWZmJBwaBOpTGcurz1ZCW1a54p9KWnonl78j80UQ5QgRMFWqhM6rcu8CJ ONAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=dFWrCIETKXjg1FNqFb1me5bCDn/NW3Z/3TsvBhl4xRU=; b=EUM+v0JLJktF146K14teOTsR11GVKBwQSC4JUWfeXva0j6//MWeVfIXIDJQ4gQuzqq i4D59TbXIIKRXDM/jdX1bAsaYGjWi8LGxIbtM3EJqI3du1HjvWpBrc03HEndL5W/HpZ3 uet64EGFzeDWCe6Y3586ZiEBEvFNhgr7MkWuw/oSjhLxJd/13KPW95FYXZNVDm3osVTE rb3pbbYNUBV/gHAlMw4EakTSFcL9Dx06IKG5rOf1Evd8z4zTHRrvMFunQI/5imygwuus qRYiE3hMsMD6YR9u6nHng8BZyEA8jsncnQCKRhfPqikQM4dVxx4fs1hkzYhQsHPpyD+H v13A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=I6tgQuog; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j22si9065787pgg.463.2019.02.20.16.25.58; Wed, 20 Feb 2019 16:26:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=I6tgQuog; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbfBUAZU (ORCPT + 99 others); Wed, 20 Feb 2019 19:25:20 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:7565 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbfBUAZU (ORCPT ); Wed, 20 Feb 2019 19:25:20 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 20 Feb 2019 16:25:24 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 20 Feb 2019 16:25:18 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 20 Feb 2019 16:25:18 -0800 Received: from [10.2.169.124] (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 21 Feb 2019 00:25:17 +0000 Subject: Re: [PATCH 03/10] mm/hmm: improve and rename hmm_vma_get_pfns() to hmm_range_snapshot() To: , CC: , Andrew Morton , Ralph Campbell References: <20190129165428.3931-1-jglisse@redhat.com> <20190129165428.3931-4-jglisse@redhat.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: Date: Wed, 20 Feb 2019 16:25:07 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190129165428.3931-4-jglisse@redhat.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1550708724; bh=dFWrCIETKXjg1FNqFb1me5bCDn/NW3Z/3TsvBhl4xRU=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=I6tgQuog86qv6gu1dhnEdEk72Zm7NdftP96EfqGPweBvT2ZUu31lvTrE6mpAj2CeU lJNcCeXEtXq5OvEdGjKH3Bb/Bsf2JTGPDQyQONBhJaKYOyB/jeDQkFaQr9e6d4q6Z7 Pr6P3iDGF5ALPBiard7zbm7SlHWArESTa/lntDBqxSQyGr6JScpdcGtDj47E3YXsSu xAP1iDj84rART96QHRN+EfzXH4oNGPfo4HqyWhrZ8C9FE8lUZV6kzc5wcFDB6nLTWW ZaoK4pBYw77SrwAguTS83eIJjkcQod+vtV9mR5K3tADcokFTAL7+K09uAcMTOQMNtw twK/pe5LbPkOQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/29/19 8:54 AM, jglisse@redhat.com wrote: > From: J=C3=A9r=C3=B4me Glisse >=20 > Rename for consistency between code, comments and documentation. Also > improves the comments on all the possible returns values. Improve the > function by returning the number of populated entries in pfns array. >=20 > Signed-off-by: J=C3=A9r=C3=B4me Glisse > Cc: Andrew Morton > Cc: Ralph Campbell > Cc: John Hubbard > --- > include/linux/hmm.h | 4 ++-- > mm/hmm.c | 23 ++++++++++------------- > 2 files changed, 12 insertions(+), 15 deletions(-) >=20 Hi Jerome, After applying the entire patchset, I still see a few hits of the old name, in Documentation: $ git grep -n hmm_vma_get_pfns Documentation/vm/hmm.rst:192: int hmm_vma_get_pfns(struct vm_area_struct *= vma, Documentation/vm/hmm.rst:205:The first one (hmm_vma_get_pfns()) will only f= etch=20 present CPU page table Documentation/vm/hmm.rst:224: ret =3D hmm_vma_get_pfns(vma, &range, st= art,=20 end, pfns); include/linux/hmm.h:145: * HMM pfn value returned by hmm_vma_get_pfns() or= =20 hmm_vma_fault() will be: > diff --git a/include/linux/hmm.h b/include/linux/hmm.h > index bd6e058597a6..ddf49c1b1f5e 100644 > --- a/include/linux/hmm.h > +++ b/include/linux/hmm.h > @@ -365,11 +365,11 @@ void hmm_mirror_unregister(struct hmm_mirror *mirro= r); > * table invalidation serializes on it. > * > * YOU MUST CALL hmm_vma_range_done() ONCE AND ONLY ONCE EACH TIME YOU = CALL > - * hmm_vma_get_pfns() WITHOUT ERROR ! > + * hmm_range_snapshot() WITHOUT ERROR ! > * > * IF YOU DO NOT FOLLOW THE ABOVE RULE THE SNAPSHOT CONTENT MIGHT BE IN= VALID ! > */ > -int hmm_vma_get_pfns(struct hmm_range *range); > +long hmm_range_snapshot(struct hmm_range *range); > bool hmm_vma_range_done(struct hmm_range *range); > =20 > =20 > diff --git a/mm/hmm.c b/mm/hmm.c > index 74d69812d6be..0d9ecd3337e5 100644 > --- a/mm/hmm.c > +++ b/mm/hmm.c > @@ -706,23 +706,19 @@ static void hmm_pfns_special(struct hmm_range *rang= e) > } > =20 > /* > - * hmm_vma_get_pfns() - snapshot CPU page table for a range of virtual a= ddresses > - * @range: range being snapshotted > + * hmm_range_snapshot() - snapshot CPU page table for a range > + * @range: range > * Returns: -EINVAL if invalid argument, -ENOMEM out of memory, -EPERM = invalid Channeling Mike Rapoport, that should be @Return: instead of Returns: , but= ... > - * vma permission, 0 success > + * permission (for instance asking for write and range is read = only), > + * -EAGAIN if you need to retry, -EFAULT invalid (ie either no = valid > + * vma or it is illegal to access that range), number of valid = pages > + * in range->pfns[] (from range start address). ...actually, that's a little hard to spot that we're returning number of va= lid=20 pages. How about: * @Returns: number of valid pages in range->pfns[] (from range start * address). This may be zero. If the return value is negative, * then one of the following values may be returned: * * -EINVAL range->invalid is set, or range->start or range->end * are not valid. * -EPERM For example, asking for write, when the range is * read-only * -EAGAIN Caller needs to retry * -EFAULT Either no valid vma exists for this range, or it is * illegal to access the range (caution: my white space might be wrong with respect to tabs) > * > * This snapshots the CPU page table for a range of virtual addresses. = Snapshot > * validity is tracked by range struct. See hmm_vma_range_done() for fu= rther > * information. > - * > - * The range struct is initialized here. It tracks the CPU page table, b= ut only > - * if the function returns success (0), in which case the caller must th= en call > - * hmm_vma_range_done() to stop CPU page table update tracking on this r= ange. > - * > - * NOT CALLING hmm_vma_range_done() IF FUNCTION RETURNS 0 WILL LEAD TO S= ERIOUS > - * MEMORY CORRUPTION ! YOU HAVE BEEN WARNED ! > */ > -int hmm_vma_get_pfns(struct hmm_range *range) > +long hmm_range_snapshot(struct hmm_range *range) > { > struct vm_area_struct *vma =3D range->vma; > struct hmm_vma_walk hmm_vma_walk; > @@ -776,6 +772,7 @@ int hmm_vma_get_pfns(struct hmm_range *range) > hmm_vma_walk.fault =3D false; > hmm_vma_walk.range =3D range; > mm_walk.private =3D &hmm_vma_walk; > + hmm_vma_walk.last =3D range->start; > =20 > mm_walk.vma =3D vma; > mm_walk.mm =3D vma->vm_mm; > @@ -792,9 +789,9 @@ int hmm_vma_get_pfns(struct hmm_range *range) > * function return 0). > */ > range->hmm =3D hmm; > - return 0; > + return (hmm_vma_walk.last - range->start) >> PAGE_SHIFT; > } > -EXPORT_SYMBOL(hmm_vma_get_pfns); > +EXPORT_SYMBOL(hmm_range_snapshot); > =20 > /* > * hmm_vma_range_done() - stop tracking change to CPU page table over a= range >=20 Otherwise, looks good. thanks, --=20 John Hubbard NVIDIA