From: Pantelis Antoniou <p.antoniou@partner.samsung.com>
To: 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>
Subject: [PATCH 0/1] Fix zero copy I/O on __get_user_pages allocated pages
Date: Wed, 7 May 2025 10:41:04 -0500 [thread overview]
Message-ID: <20250507154105.763088-1-p.antoniou@partner.samsung.com> (raw)
In-Reply-To: <CGME20250507154119uscas1p2a4055d14ab111fdb94a6378789c38d9d@uscas1p2.samsung.com>
Updates to network filesystems enabled zero copy I/O by using the
netfslib common accessors.
One example of that is the 9p filesystem which is commonly used in qemu
based setups for sharing files with the host.
In our emulation environment we have noticed failing writes when performing
I/O from a userspace mapped DRM GEM buffer object.
The platform does not use VRAM, all graphics memory is regular DRAM memory,
allocated via __get_free_pages
The same write was successful from a heap allocated bounce buffer.
The sequence of events is as follows.
1. A BO (Buffer Object) is created, and it's backing memory is allocated via
__get_user_pages()
2. Userspace mmaps a BO (Buffer Object) via a mmap call on the opened
file handle of a DRM driver. The mapping is done via the
drm_gem_mmap_obj() call.
3. Userspace issues a write to a file copying the contents of the BO.
3a. If the file is located on regular filesystem (like ext4), the write
completes successfully.
3b. If the file is located on a network filesystem, like 9p the write fails.
The write fails because v9fs_file_write_iter() will call
netfs_unbuffered_write_iter(), netfs_unbuffered_write_iter_locked() which will
call netfs_extract_user_iter()
netfs_extract_user_iter() will in turn call iov_iter_extract_pages() which for
a user backed iterator will call iov_iter_extract_user_pages which will call
pin_user_pages_fast() which finally will call __gup_longterm_locked().
__gup_longterm_locked() will call __get_user_pages_locked() which will fail
because the VMA is marked with the VM_IO and VM_PFNMAP flags.
Pantelis Antoniou (1):
Fix zero copy I/O on __get_user_pages allocated pages
mm/gup.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
--
2.25.1
next parent reply other threads:[~2025-05-07 15:41 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 ` Pantelis Antoniou [this message]
[not found] ` <CGME20250507154119uscas1p17799fe7589e4f1bd53d2d3dc7f44cb8c@uscas1p1.samsung.com>
2025-05-07 15:41 ` [PATCH 1/1] " Pantelis Antoniou
2025-05-08 15:03 ` David Hildenbrand
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=20250507154105.763088-1-p.antoniou@partner.samsung.com \
--to=p.antoniou@partner.samsung.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=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