From: Danilo Krummrich <dakr@kernel.org>
To: lorenzo.stoakes@oracle.com, vbabka@suse.cz,
Liam.Howlett@oracle.com, urezki@gmail.com, ojeda@kernel.org,
alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net,
bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
abdiel.janulgue@gmail.com, acourbot@nvidia.com
Cc: rust-for-linux@vger.kernel.org, Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH v5 0/7] BorrowedPage, AsPageIter and VmallocPageIter
Date: Wed, 20 Aug 2025 16:53:36 +0200 [thread overview]
Message-ID: <20250820145434.94745-1-dakr@kernel.org> (raw)
This patch series implements the BorrowedPage type, the AsPageIter trait and
VmallocPageIter type.
AsPageIter can be implemented by any type that owns pages to allow users to
borrow them through a generic interface.
For instance, this is useful to access and borrow the backing pages of
allocation primitives, such as Box and Vec, backing a scatterlist.
Hence, implement AsPageIter for VBox and VVec.
Additionally, implement Vmalloc::to_page() and ArrayLayout::size(), which are
dependencies of the above.
Changes in v5:
- Avoid repetition in commit message of "rust: alloc: implement
VmallocPageIter".
- Change invariants of VmallocPageIter to:
- `buf` is a valid and [`page::PAGE_SIZE`] aligned pointer into a
[`Vmalloc`] allocation.
- `size` is the number of bytes from `buf` until the end of the [`Vmalloc`]
allocation `buf` points to.
- Inline some methods of VmallocPageIter.
Changes in v4:
- Rename IntoPageIter into AsPageIter.
- Put lifetime on AsPageIter::Iter instead of AsPageIter itself.
- Implement size_hint() for VmallocPageIter.
- Use PhantomData<page::BorrowedPage<'a>> instead of PhantomData<&'a u8>.
Changes in v3:
- Generalize the previous PageOwner impl of VBox and VVec in VmallocPageIter.
- Correspondingly, replace PageOwner with IntoPageIter.
Changes in v2:
- BorrowedPage
- Add link to Ownable
- Use borrow_page() in the example
- Add PageOwner, Vmalloc::to_page(), ArrayLayout, VBox, VVec patches.
Danilo Krummrich (7):
rust: page: implement BorrowedPage
rust: alloc: vmalloc: implement Vmalloc::to_page()
rust: alloc: implement VmallocPageIter
rust: page: define trait AsPageIter
rust: alloc: kbox: implement AsPageIter for VBox
rust: alloc: layout: implement ArrayLayout::size()
rust: alloc: kvec: implement AsPageIter for VVec
rust/bindings/bindings_helper.h | 1 +
rust/kernel/alloc/allocator.rs | 152 ++++++++++++++++++++++++++++++++
rust/kernel/alloc/kbox.rs | 40 ++++++++-
rust/kernel/alloc/kvec.rs | 40 ++++++++-
rust/kernel/alloc/layout.rs | 5 ++
rust/kernel/page.rs | 87 +++++++++++++++++-
6 files changed, 322 insertions(+), 3 deletions(-)
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
--
2.50.1
next reply other threads:[~2025-08-20 14:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 14:53 Danilo Krummrich [this message]
2025-08-20 14:53 ` [PATCH v5 1/7] rust: page: implement BorrowedPage Danilo Krummrich
2025-08-20 14:53 ` [PATCH v5 2/7] rust: alloc: vmalloc: implement Vmalloc::to_page() Danilo Krummrich
2025-08-20 14:53 ` [PATCH v5 3/7] rust: alloc: implement VmallocPageIter Danilo Krummrich
2025-08-20 14:53 ` [PATCH v5 4/7] rust: page: define trait AsPageIter Danilo Krummrich
2025-08-20 14:53 ` [PATCH v5 5/7] rust: alloc: kbox: implement AsPageIter for VBox Danilo Krummrich
2025-08-20 14:53 ` [PATCH v5 6/7] rust: alloc: layout: implement ArrayLayout::size() Danilo Krummrich
2025-08-20 14:53 ` [PATCH v5 7/7] rust: alloc: kvec: implement AsPageIter for VVec Danilo Krummrich
2025-09-04 21:47 ` [PATCH v5 0/7] BorrowedPage, AsPageIter and VmallocPageIter Danilo Krummrich
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=20250820145434.94745-1-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=a.hindborg@kernel.org \
--cc=abdiel.janulgue@gmail.com \
--cc=acourbot@nvidia.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=lorenzo.stoakes@oracle.com \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=urezki@gmail.com \
--cc=vbabka@suse.cz \
/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).