From: Ira Weiny <ira.weiny@intel.com>
To: John Hubbard <jhubbard@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christoph Hellwig <hch@infradead.org>,
"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
Keith Busch <keith.busch@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org, kbuild test robot <lkp@intel.com>,
"Kirill A . Shutemov" <kirill@shutemov.name>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2 2/2] mm/gup: fix a misnamed "write" argument, and a related bug
Date: Mon, 14 Oct 2019 13:28:47 -0700 [thread overview]
Message-ID: <20191014202846.GA8816@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <20191014184639.1512873-3-jhubbard@nvidia.com>
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 <lkp@intel.com>
> Suggested-by: Kirill A. Shutemov <kirill@shutemov.name>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> ---
> 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
>
>
prev parent reply other threads:[~2019-10-14 20:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 18:46 [PATCH v2 0/2] gup.c, gup_benchmark.c trivial fixes before the storm John Hubbard
2019-10-14 18:46 ` [PATCH v2 1/2] mm/gup_benchmark: add a missing "w" to getopt string John Hubbard
2019-10-14 18:46 ` [PATCH v2 2/2] mm/gup: fix a misnamed "write" argument, and a related bug John Hubbard
2019-10-14 20:28 ` Ira Weiny [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191014202846.GA8816@iweiny-DESK2.sc.intel.com \
--to=ira.weiny@intel.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=jhubbard@nvidia.com \
--cc=keith.busch@intel.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox