From: Lorenzo Stoakes <lstoakes@gmail.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Cc: Baoquan He <bhe@redhat.com>, Uladzislau Rezki <urezki@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
David Hildenbrand <david@redhat.com>,
Liu Shixin <liushixin2@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
Jens Axboe <axboe@kernel.dk>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Lorenzo Stoakes <lstoakes@gmail.com>
Subject: [PATCH v8 0/4] convert read_kcore(), vread() to use iterators
Date: Thu, 23 Mar 2023 10:15:15 +0000 [thread overview]
Message-ID: <cover.1679566220.git.lstoakes@gmail.com> (raw)
While reviewing Baoquan's recent changes to permit vread() access to
vm_map_ram regions of vmalloc allocations, Willy pointed out [1] that it
would be nice to refactor vread() as a whole, since its only user is
read_kcore() and the existing form of vread() necessitates the use of a
bounce buffer.
This patch series does exactly that, as well as adjusting how we read the
kernel text section to avoid the use of a bounce buffer in this case as
well.
This has been tested against the test case which motivated Baoquan's
changes in the first place [2] which continues to function correctly, as do
the vmalloc self tests.
[1] https://lore.kernel.org/all/Y8WfDSRkc%2FOHP3oD@casper.infradead.org/
[2] https://lore.kernel.org/all/87ilk6gos2.fsf@oracle.com/T/#u
v8:
- Make zero_iter() static.
v7:
- Keep trying to fault in memory until the vmalloc read operation
completes.
https://lore.kernel.org/all/cover.1679511146.git.lstoakes@gmail.com/
v6:
- Correct copy_page_to_iter_nofault() to handle -EFAULT case correctly.
https://lore.kernel.org/all/cover.1679496827.git.lstoakes@gmail.com/
v5:
- Do not rename fpos to ppos in read_kcore_iter() to avoid churn.
- Fix incorrect commit messages after prior revisions altered the approach.
- Replace copy_page_to_iter_atomic() with copy_page_to_iter_nofault() and
adjust it to be able to handle compound pages. This uses
copy_to_user_nofault() which ensures page faults are disabled during copy
which kmap_local_page() was not doing.
- Only try to fault in pages if we are unable to copy in the first place
and try only once to avoid any risk of spinning.
- Do not zero memory in aligned_vread_iter() if we couldn't copy it.
- Fix mistake in zeroing missing or unpopulated blocks in
vmap_ram_vread_iter().
https://lore.kernel.org/linux-mm/cover.1679494218.git.lstoakes@gmail.com/
v4:
- Fixup mistake in email client which orphaned patch emails from the
cover letter.
https://lore.kernel.org/all/cover.1679431886.git.lstoakes@gmail.com
v3:
- Revert introduction of mutex/rwsem in vmalloc
- Introduce copy_page_to_iter_atomic() iovec function
- Update vread_iter() and descendent functions to use only this
- Fault in user pages before calling vread_iter()
- Use const char* in vread_iter() and descendent functions
- Updated commit messages based on feedback
- Extend vread functions to always check how many bytes we could copy. If
at any stage we are unable to copy/zero, abort and return the number of
bytes we did copy.
https://lore.kernel.org/all/cover.1679354384.git.lstoakes@gmail.com/
v2:
- Fix ordering of vread_iter() parameters
- Fix nommu vread() -> vread_iter()
https://lore.kernel.org/all/cover.1679209395.git.lstoakes@gmail.com/
v1:
https://lore.kernel.org/all/cover.1679183626.git.lstoakes@gmail.com/
Lorenzo Stoakes (4):
fs/proc/kcore: avoid bounce buffer for ktext data
fs/proc/kcore: convert read_kcore() to read_kcore_iter()
iov_iter: add copy_page_to_iter_nofault()
mm: vmalloc: convert vread() to vread_iter()
fs/proc/kcore.c | 85 +++++++--------
include/linux/uio.h | 2 +
include/linux/vmalloc.h | 3 +-
lib/iov_iter.c | 48 +++++++++
mm/nommu.c | 10 +-
mm/vmalloc.c | 234 +++++++++++++++++++++++++---------------
6 files changed, 243 insertions(+), 139 deletions(-)
--
2.39.2
next reply other threads:[~2023-03-23 10:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 10:15 Lorenzo Stoakes [this message]
2023-03-23 10:15 ` [PATCH v8 1/4] fs/proc/kcore: avoid bounce buffer for ktext data Lorenzo Stoakes
2023-05-31 11:58 ` Jiri Olsa
2023-07-21 13:48 ` Baoquan He
2023-07-21 14:13 ` Jiri Olsa
2023-07-24 6:23 ` David Hildenbrand
2023-07-24 8:08 ` Baoquan He
2023-07-24 8:18 ` Jiri Olsa
2023-07-24 14:33 ` Baoquan He
2023-07-31 19:21 ` Lorenzo Stoakes
2023-07-31 19:24 ` David Hildenbrand
2023-07-31 19:40 ` Lorenzo Stoakes
2023-07-31 20:34 ` Jiri Olsa
2023-07-31 21:12 ` Lorenzo Stoakes
2023-07-31 21:50 ` Jiri Olsa
2023-07-31 21:58 ` Lorenzo Stoakes
2023-07-24 9:38 ` Linux regression tracking (Thorsten Leemhuis)
2023-03-23 10:15 ` [PATCH v8 2/4] fs/proc/kcore: convert read_kcore() to read_kcore_iter() Lorenzo Stoakes
2023-03-23 10:15 ` [PATCH v8 3/4] iov_iter: add copy_page_to_iter_nofault() Lorenzo Stoakes
2023-03-23 10:15 ` [PATCH v8 4/4] mm: vmalloc: convert vread() to vread_iter() Lorenzo Stoakes
2023-03-29 4:53 ` [PATCH v8 0/4] convert read_kcore(), vread() to use iterators Baoquan He
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=cover.1679566220.git.lstoakes@gmail.com \
--to=lstoakes@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bhe@redhat.com \
--cc=david@redhat.com \
--cc=jolsa@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liushixin2@huawei.com \
--cc=urezki@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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).