From: David Hildenbrand <david@redhat.com>
To: Peter Xu <peterx@redhat.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>,
Andrew Morton <akpm@linux-foundation.org>,
"Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
Lorenzo Stoakes <lstoakes@gmail.com>,
John Hubbard <jhubbard@nvidia.com>,
linuxppc-dev@lists.ozlabs.org,
Muchun Song <muchun.song@linux.dev>,
Jason Gunthorpe <jgg@nvidia.com>
Subject: Re: [PATCH 1/2] mm/gup: Fix hugepd handling in hugetlb rework
Date: Mon, 29 Apr 2024 09:17:44 +0200 [thread overview]
Message-ID: <19c5b260-fddf-478e-abc5-1c645957b562@redhat.com> (raw)
In-Reply-To: <20240428190151.201002-2-peterx@redhat.com>
On 28.04.24 21:01, Peter Xu wrote:
> Commit a12083d721d7 added hugepd handling for gup-slow, reusing gup-fast
> functions. follow_hugepd() correctly took the vma pointer in, however
> didn't pass it over into the lower functions, which was overlooked.
>
> The issue is gup_fast_hugepte() uses the vma pointer to make the correct
> decision on whether an unshare is needed for a FOLL_PIN|FOLL_LONGTERM. Now
> without vma ponter it will constantly return "true" (needs an unshare) for
> a page cache, even though in the SHARED case it will be wrong to unshare.
>
> The other problem is, even if an unshare is needed, it now returns 0 rather
> than -EMLINK, which will not trigger a follow up FAULT_FLAG_UNSHARE fault.
> That will need to be fixed too when the unshare is wanted.
>
> gup_longterm test didn't expose this issue in the past because it didn't
> yet test R/O unshare in this case, another separate patch will enable that
> in future tests.
>
> Fix it by passing vma correctly to the bottom, rename gup_fast_hugepte()
> back to gup_hugepte() as it is shared between the fast/slow paths, and also
> allow -EMLINK to be returned properly by gup_hugepte() even though gup-fast
> will take it the same as zero.
>
> Reported-by: David Hildenbrand <david@redhat.com>
> Fixes: a12083d721d7 ("mm/gup: handle hugepd for follow_page()")
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
LGTM
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-04-29 7:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 19:01 [PATCH 0/2] mm/gup: Fix hugepd for longterm R/O pin on Power Peter Xu
2024-04-28 19:01 ` [PATCH 1/2] mm/gup: Fix hugepd handling in hugetlb rework Peter Xu
2024-04-29 7:17 ` David Hildenbrand [this message]
2024-04-28 19:01 ` [PATCH 2/2] mm/selftests: Don't prefault in gup_longterm tests Peter Xu
2024-04-29 7:28 ` David Hildenbrand
2024-04-29 13:10 ` Peter Xu
2024-04-29 13:26 ` David Hildenbrand
2024-04-29 13:51 ` Peter Xu
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=19c5b260-fddf-478e-abc5-1c645957b562@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lstoakes@gmail.com \
--cc=muchun.song@linux.dev \
--cc=peterx@redhat.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;
as well as URLs for NNTP newsgroup(s).