From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: <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>, <tmgross@umich.edu>,
<abdiel.janulgue@gmail.com>, <acourbot@nvidia.com>,
<rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH v3 3/7] rust: alloc: implement VmallocPageIter
Date: Mon, 11 Aug 2025 11:30:04 +0200 [thread overview]
Message-ID: <DBZHRHSE33E9.2AMO99NOCX0C0@kernel.org> (raw)
In-Reply-To: <aJm0duBjfWyZT3YJ@google.com>
On Mon Aug 11, 2025 at 11:14 AM CEST, Alice Ryhl wrote:
> On Fri, Aug 08, 2025 at 08:10:17PM +0200, Danilo Krummrich wrote:
>> +/// An [`Iterator`] of [`page::BorrowedPage`] items owned by a [`Vmalloc`] allocation.
>> +///
>> +/// # Guarantees
>> +///
>> +/// The pages iterated by the [`Iterator`] appear in the order as they are mapped in the CPU's
>> +/// virtual address space ascendingly.
>> +///
>> +/// # Invariants
>> +///
>> +/// - `buf` is a valid pointer to the beginning of a [`Vmalloc`] allocation.
>> +/// - `size` is the size of the [`Vmalloc`] allocation `buf` points to.
>> +pub struct VmallocPageIter<'a> {
>> + /// The base address of the [`Vmalloc`] buffer.
>> + buf: NonNull<u8>,
>> + /// The size of the buffer pointed to by `buf` in bytes.
>> + size: usize,
>> + /// The current page index of the [`Iterator`].
>> + index: usize,
>
> My understanding is that an implementation using two pointers that
> repeatedly increments the starting pointer until it reaches the end
> pointer is more efficient.
If I directly advance the start pointer until hitting the end pointer, I need
three pointers, i.e. start, end and the advancing one, otherwise I can't
implement base_address() anymore, hence I went with an index instead.
next prev parent reply other threads:[~2025-08-11 9:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 18:10 [PATCH v3 0/7] BorrowedPage, IntoPageIter and VmallocPageIter Danilo Krummrich
2025-08-08 18:10 ` [PATCH v3 1/7] rust: page: implement BorrowedPage Danilo Krummrich
2025-08-08 18:10 ` [PATCH v3 2/7] rust: alloc: vmalloc: implement Vmalloc::to_page() Danilo Krummrich
2025-08-11 9:11 ` Alice Ryhl
2025-08-08 18:10 ` [PATCH v3 3/7] rust: alloc: implement VmallocPageIter Danilo Krummrich
2025-08-11 9:14 ` Alice Ryhl
2025-08-11 9:30 ` Danilo Krummrich [this message]
2025-08-08 18:10 ` [PATCH v3 4/7] rust: page: define trait IntoPageIter Danilo Krummrich
2025-08-11 8:57 ` Alice Ryhl
2025-08-11 9:01 ` Danilo Krummrich
2025-08-11 9:16 ` Alice Ryhl
2025-08-11 10:38 ` Danilo Krummrich
2025-08-11 10:41 ` Alice Ryhl
2025-08-08 18:10 ` [PATCH v3 5/7] rust: alloc: kbox: implement IntoPageIter for VBox Danilo Krummrich
2025-08-08 18:10 ` [PATCH v3 6/7] rust: alloc: layout: implement ArrayLayout::size() Danilo Krummrich
2025-08-19 13:09 ` Daniel Almeida
2025-08-08 18:10 ` [PATCH v3 7/7] rust: alloc: kvec: implement IntoPageIter for VVec 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=DBZHRHSE33E9.2AMO99NOCX0C0@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).