Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1941458ybg; Thu, 24 Oct 2019 02:30:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2owJYkIIPP4AZdrGfZ6RWoENGAs8eyq39RCe5hrCARGKinkphMtHQXRLuPfSdfPwgbRxw X-Received: by 2002:a17:906:c836:: with SMTP id dd22mr17661643ejb.178.1571909433531; Thu, 24 Oct 2019 02:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571909433; cv=none; d=google.com; s=arc-20160816; b=QQITIwRX+Tiqpws0a49maFnw57nxcfROszqOgaM450Ev4KsSr4o2RqHXES3+kCwIiY urwz5f/DwHkNG16BvyuW1hdYYkmB3/Zuy38XWC+AylabeJOA5cQuOliLLD7U9cyk/uoH 93zA+tYj2i6xpNjyEPEZ+FqDggYqfQdRxHIikyEYFH+ADhu2h+gA5DFjpCanVB7zNO3n RRhJr7T1baOQL0ssNOee4hwklsCfHxczXK9a9pzI+7AGMeSdUE3JBEJbHZTf66aL+vmd B/YU0tx8of7CwDKHDcNsOYm5gKu6fIi2B7T6rBMk1hqqAyaYSumrVGP56v5DWfiZqhK8 whRw== 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=gziLaVtBJuU4lCxLTMWw4D2EGiUWv9a+eDJHtPnkjto=; b=g4ZXJIUs+jT6kyy7vRfPiD/Oobn2qdPWsGF2kL1ROkZkLpMkJdbzRt/k1mYEFoMoJN BmIahXx0rBRyVXINT3dfi26zNg5QauUmU/y8tAiPN5Yv5i8GCGI33IuW2kyNkS0pZ0Pd C/W3RtzZ7+A/ZHsYx9l1JgH1Yco+OB5tDV4sFT2DG/SD9JJ8hYvfCCdqXErvaE3wSjIM mfesbuaTmlILkLOG750r0Eju5uiK37UPIlFzlIgJMw/rAayUK9WJlbd5+c3doXL1cwMj rcje7PJZhe5gWATBMttQleSXMr2fwoKgM3jZ9ldqWK0hpROBJpLLoSY/P9M/FmIEk/8R pMvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=TqJ+HRDx; 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 m12si14260875ejr.180.2019.10.24.02.30.08; Thu, 24 Oct 2019 02:30:33 -0700 (PDT) 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=TqJ+HRDx; 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 S2404188AbfJWT2Q (ORCPT + 99 others); Wed, 23 Oct 2019 15:28:16 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:11652 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732759AbfJWT2P (ORCPT ); Wed, 23 Oct 2019 15:28:15 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 23 Oct 2019 12:28:20 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 23 Oct 2019 12:28:15 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 23 Oct 2019 12:28:15 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 23 Oct 2019 19:28:14 +0000 Received: from [10.110.48.28] (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 23 Oct 2019 19:28:14 +0000 Subject: Re: [PATCH] mm: gup: fix comment of __get_user_pages() To: Liu Xiang , CC: References: <1571838707-4994-1-git-send-email-liuxiang_1999@126.com> From: John Hubbard X-Nvconfidentiality: public Message-ID: <36315623-2a82-41e6-c399-6cdfccd1d264@nvidia.com> Date: Wed, 23 Oct 2019 12:28:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1571838707-4994-1-git-send-email-liuxiang_1999@126.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1571858900; bh=gziLaVtBJuU4lCxLTMWw4D2EGiUWv9a+eDJHtPnkjto=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=TqJ+HRDxJUhL8d8j3yN8jAqCn/gGAiZpK40rtOL8rbiVTVj+a+dl23Pd4bUN7kMY5 tTZnsIuiAAkQaTVBGnaOkIiFzOdlp5DdpUh58Uzhc8Brjp0J6cStJ2GDOIaMlkqSOP S1ezvnSqfNFc+ktuvSCgqccCVNxLPgRweZvCkqEa1dDvLmamliVkHyeNt8lIFy24At bYMsLgnw4Ek3kE2bruzag3Jklhj0mzqvzHpMgbBRUz6L4bud+wp5wdt6tq9y7h3yh0 o/DsQZoBnqf3+8w6NAi2m1ToVCGGyY7GS/SWhOqgiKJRNyQKFigY4g64HzU1fwQToV 2jnNJMx4dVGcg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/23/19 6:51 AM, Liu Xiang wrote: > Because nr_pages is unsigned long, it can not be negative. > > Signed-off-by: Liu Xiang > --- > mm/gup.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/mm/gup.c b/mm/gup.c > index 8f236a3..0236954 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -735,10 +735,10 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags) > * @nonblocking: whether waiting for disk IO or mmap_sem contention > * > * Returns number of pages pinned. This may be fewer than the number > - * requested. If nr_pages is 0 or negative, returns 0. If no pages > - * were pinned, returns -errno. Each page returned must be released > - * with a put_page() call when it is finished with. vmas will only > - * remain valid while mmap_sem is held. > + * requested. If nr_pages is 0, returns 0. If no pages were pinned, > + * returns -errno. Each page returned must be released with a > + * put_page() call when it is finished with. vmas will only remain > + * valid while mmap_sem is held. > * > * Must be called with mmap_sem held. It may be released. See below. > * > Hi Liu, Thanks for fixing the documentation! As long as you're there...for the actual wording, can we please do it as shown below? This also addresses David's feedback, and it makes this read a lot better overall: diff --git a/mm/gup.c b/mm/gup.c index 8f236a335ae9..5816876fee51 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -734,11 +734,17 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags) * Or NULL if the caller does not require them. * @nonblocking: whether waiting for disk IO or mmap_sem contention * - * Returns number of pages pinned. This may be fewer than the number - * requested. If nr_pages is 0 or negative, returns 0. If no pages - * were pinned, returns -errno. Each page returned must be released - * with a put_page() call when it is finished with. vmas will only - * remain valid while mmap_sem is held. + * Returns either number of pages pinned (which may be less than the number + * requested), or an error. Details about the return value: + * + * -- If nr_pages is 0, returns 0. + * -- If nr_pages is >0, but no pages were pinned, returns -errno. + * -- If nr_pages is >0, and some pages were pinned, returns the number of + * pages pinned. Again, this may be less than nr_pages. + * + * The caller is responsible for releasing returned @pages, via put_page(). + * + * @vmas are valid only as long as mmap_sem is held. * * Must be called with mmap_sem held. It may be released. See below. * Patch ordering: I'll have to change the above as part of my upcoming series, to make it refer to "put_page() or put_user_page(), depending on FOLL_PIN", approximately. (Just more of a note to self than anything else, here.) thanks, John Hubbard NVIDIA