Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5201898ybp; Mon, 14 Oct 2019 17:32:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcWRLmE+MMePzmANtqeZ7bMGwUYkL4OStGqzoGe2HDfYGqadVBXzN3jeW1jt2eEJSPkR3Z X-Received: by 2002:aa7:d1ca:: with SMTP id g10mr30623620edp.156.1571099530396; Mon, 14 Oct 2019 17:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571099530; cv=none; d=google.com; s=arc-20160816; b=m0o6n9LE7Sw+8qv4ucA5EZVV4Q65UmkJDm3t+HtEAcXwBWeBepI9suTJrSogEV4xTY ld2AxLqRHtqooRcr26XIwMTADlwjJzkKIhk0f3ePq201TP40RMAiqsHrTiKkDko+Rgch kaB3F2N5t5jBEn3dEQ5PXu2dxuTHuR6vvT8AUEl3yZASSXesvHlQbeCuYdWI5+rYTTdn YC5MAI84E1na+6TZ+W9J3GQMjUowIwXGYHaRceQf/lVwvAOjXbwoK/LM06BmK18HeuNq aQRQqVrzUM9gH+HGDf2aFYq+ccSumpLXSW/F0QocxtgxgC3ok0M7e27O24my2W3j8M4r 5P7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1DyW5NTqoIrPS0zL5b1rLLCt6yCaUSL2Ia4viCrP7Is=; b=Fym8rtiLyFM+CPnOkHuW2A1jqqqlA3CTjwQFNP13/f4lxOe3sgPfSO5nBLVVXFqkoE /CNuSnbTt23OAihJiiwalXNgO941TCZLmboKa4WweCOoKq5/7F2XwEO2HyAd9tNVDuB/ lvdH0j6MyxGVJ36lViRK8UjavGwvBOCH69dw/Y59gD/jRc4OvGd/9N/IGKhlE98LRaVm /O9Sc5+OKMTR+vHhLH48Set1auVW1R8bO6D5Ogt1Z+Q47Y2OVDsr050+BizIIKUx9aP4 pKMryt03r3p+i7g1ZcuUGWbCxue6OojN83v8vtm5ONXNYZCMfHWFyXXZ9WQH+zDw6dDF AkjA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v17si13975427eda.256.2019.10.14.17.31.45; Mon, 14 Oct 2019 17:32:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733013AbfJNU2s (ORCPT + 99 others); Mon, 14 Oct 2019 16:28:48 -0400 Received: from mga04.intel.com ([192.55.52.120]:16285 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729667AbfJNU2s (ORCPT ); Mon, 14 Oct 2019 16:28:48 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2019 13:28:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,296,1566889200"; d="scan'208";a="207323991" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by orsmga002.jf.intel.com with ESMTP; 14 Oct 2019 13:28:47 -0700 Date: Mon, 14 Oct 2019 13:28:47 -0700 From: Ira Weiny To: John Hubbard Cc: Andrew Morton , Christoph Hellwig , "Aneesh Kumar K . V" , Keith Busch , LKML , linux-mm@kvack.org, kbuild test robot , "Kirill A . Shutemov" , Christoph Hellwig Subject: Re: [PATCH v2 2/2] mm/gup: fix a misnamed "write" argument, and a related bug Message-ID: <20191014202846.GA8816@iweiny-DESK2.sc.intel.com> References: <20191014184639.1512873-1-jhubbard@nvidia.com> <20191014184639.1512873-3-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191014184639.1512873-3-jhubbard@nvidia.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 14, 2019 at 11:46:39AM -0700, John Hubbard wrote: > In several routines, the "flags" argument is incorrectly > named "write". Change it to "flags". > > Also, in one place, the misnaming led to an actual bug: > "flags & FOLL_WRITE" is required, rather than just "flags". > (That problem was flagged by krobot, in v1 of this patch.) > > Also, change the flags argument from int, to unsigned int. > > You can see that this was a simple oversight, because the > calling code passes "flags" to the fifth argument: > > gup_pgd_range(): > ... > if (!gup_huge_pd(__hugepd(pgd_val(pgd)), addr, > PGDIR_SHIFT, next, flags, pages, nr)) > > ...which, until this patch, the callees referred to as "write". > > Also, change two lines to avoid checkpatch line length > complaints, and another line to fix another oversight > that checkpatch called out: missing "int" on pdshift. > > Fixes: b798bec4741b ("mm/gup: change write parameter to flags in fast walk") > Reported-by: kbuild test robot > Suggested-by: Kirill A. Shutemov > Suggested-by: Ira Weiny Reviewed-by: Ira Weiny > Cc: Christoph Hellwig > Cc: Aneesh Kumar K.V > Signed-off-by: John Hubbard > --- > mm/gup.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/mm/gup.c b/mm/gup.c > index 23a9f9c9d377..8f236a335ae9 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -1973,7 +1973,8 @@ static unsigned long hugepte_addr_end(unsigned long addr, unsigned long end, > } > > static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, > - unsigned long end, int write, struct page **pages, int *nr) > + unsigned long end, unsigned int flags, > + struct page **pages, int *nr) > { > unsigned long pte_end; > struct page *head, *page; > @@ -1986,7 +1987,7 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, > > pte = READ_ONCE(*ptep); > > - if (!pte_access_permitted(pte, write)) > + if (!pte_access_permitted(pte, flags & FOLL_WRITE)) > return 0; > > /* hugepages are never "special" */ > @@ -2023,7 +2024,7 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, > } > > static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, > - unsigned int pdshift, unsigned long end, int write, > + unsigned int pdshift, unsigned long end, unsigned int flags, > struct page **pages, int *nr) > { > pte_t *ptep; > @@ -2033,7 +2034,7 @@ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, > ptep = hugepte_offset(hugepd, addr, pdshift); > do { > next = hugepte_addr_end(addr, end, sz); > - if (!gup_hugepte(ptep, sz, addr, end, write, pages, nr)) > + if (!gup_hugepte(ptep, sz, addr, end, flags, pages, nr)) > return 0; > } while (ptep++, addr = next, addr != end); > > @@ -2041,7 +2042,7 @@ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, > } > #else > static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr, > - unsigned pdshift, unsigned long end, int write, > + unsigned int pdshift, unsigned long end, unsigned int flags, > struct page **pages, int *nr) > { > return 0; > @@ -2049,7 +2050,8 @@ static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr, > #endif /* CONFIG_ARCH_HAS_HUGEPD */ > > static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, > - unsigned long end, unsigned int flags, struct page **pages, int *nr) > + unsigned long end, unsigned int flags, > + struct page **pages, int *nr) > { > struct page *head, *page; > int refs; > -- > 2.23.0 > >