From: David Hildenbrand <david@redhat.com>
To: Pantelis Antoniou <p.antoniou@partner.samsung.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org,
Artem Krupotkin <artem.k@samsung.com>,
Charles Briere <c.briere@samsung.com>,
Wade Farnsworth <wade.farnsworth@siemens.com>,
Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH 1/1] Fix zero copy I/O on __get_user_pages allocated pages
Date: Thu, 8 May 2025 17:03:46 +0200 [thread overview]
Message-ID: <99ed92b7-c1b2-4e12-a7ee-776a7f890b47@redhat.com> (raw)
In-Reply-To: <20250507154105.763088-2-p.antoniou@partner.samsung.com>
On 07.05.25 17:41, Pantelis Antoniou wrote:
Hi,
> Recent updates to net filesystems enabled zero copy operations,
> which require getting a user space page pinned.
>
> This does not work for pages that were allocated via __get_user_pages
> and then mapped to user-space via remap_pfn_rage.
Right. Because the struct page of a VM_PFNMAP *must not be touched*. It
has to be treated like it doesn't exist.
>
> remap_pfn_range_internal() will turn on VM_IO | VM_PFNMAP vma bits.
> VM_PFNMAP in particular mark the pages as not having struct_page
> associated with them, which is not the case for __get_user_pages()
>
> This in turn makes any attempt to lock a page fail, and breaking
> I/O from that address range.
>
> This patch address it by special casing pages in those VMAs and not
> calling vm_normal_page() for them.
>
> Signed-off-by: Pantelis Antoniou <p.antoniou@partner.samsung.com>
> ---
> mm/gup.c | 22 ++++++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 84461d384ae2..e185c18c0c81 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -833,6 +833,20 @@ static inline bool can_follow_write_pte(pte_t pte, struct page *page,
> return !userfaultfd_pte_wp(vma, pte);
> }
>
> +static struct page *gup_normal_page(struct vm_area_struct *vma,
> + unsigned long address, pte_t pte)
> +{
> + unsigned long pfn;
> +
> + if (vma->vm_flags & (VM_MIXEDMAP | VM_PFNMAP)) {
> + pfn = pte_pfn(pte);
> + if (!pfn_valid(pfn) || is_zero_pfn(pfn) || pfn > highest_memmap_pfn)
> + return NULL;
> + return pfn_to_page(pfn);
> + }
> + return vm_normal_page(vma, address, pte);
I enjoy seeing vm_normal_page() checks in GUP code.
I don't enjoy seeing what you added before that :)
If vm_normal_page() tells you "this is not a normal", then we should not
touch it. There is one exception: the shared zeropage.
So, unfortunately, this is wrong.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-05-08 15:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250507154119uscas1p2a4055d14ab111fdb94a6378789c38d9d@uscas1p2.samsung.com>
2025-05-07 15:41 ` [PATCH 0/1] " Pantelis Antoniou
[not found] ` <CGME20250507154119uscas1p17799fe7589e4f1bd53d2d3dc7f44cb8c@uscas1p1.samsung.com>
2025-05-07 15:41 ` [PATCH 1/1] " Pantelis Antoniou
2025-05-08 15:03 ` David Hildenbrand [this message]
2025-05-08 15:23 ` Pantelis Antoniou
2025-05-08 15:37 ` David Hildenbrand
2025-05-08 15:47 ` Pantelis Antoniou
2025-05-07 21:50 ` [PATCH 0/1] " Andrew Morton
2025-05-08 8:24 ` Pantelis Antoniou
2025-05-07 21:54 ` Andrew Morton
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=99ed92b7-c1b2-4e12-a7ee-776a7f890b47@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=artem.k@samsung.com \
--cc=c.briere@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=p.antoniou@partner.samsung.com \
--cc=peterx@redhat.com \
--cc=wade.farnsworth@siemens.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