[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DC5KVFUTRCA6.3Q3YQD4L026D2@kernel.org>
Date: Mon, 18 Aug 2025 15:12:17 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Alice Ryhl" <aliceryhl@...gle.com>
Cc: <akpm@...ux-foundation.org>, <ojeda@...nel.org>,
<alex.gaynor@...il.com>, <boqun.feng@...il.com>, <gary@...yguo.net>,
<bjorn3_gh@...tonmail.com>, <lossin@...nel.org>, <a.hindborg@...nel.org>,
<tmgross@...ch.edu>, <abdiel.janulgue@...il.com>, <acourbot@...dia.com>,
<jgg@...pe.ca>, <lyude@...hat.com>, <robin.murphy@....com>,
<daniel.almeida@...labora.com>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/4] rust: scatterlist: Add type-state abstraction for
sg_table
On Mon Aug 18, 2025 at 2:21 PM CEST, Danilo Krummrich wrote:
> On Mon Aug 18, 2025 at 1:16 PM CEST, Danilo Krummrich wrote:
>> On Mon Aug 18, 2025 at 11:52 AM CEST, Alice Ryhl wrote:
>>> On Fri, Aug 15, 2025 at 07:10:03PM +0200, Danilo Krummrich wrote:
>>>> +impl<P> Owned<P>
>>>> +where
>>>> + for<'a> P: page::AsPageIter<Iter<'a> = VmallocPageIter<'a>> + 'static,
>>>
>>> If you specifically require the iterator type to be VmallocPageIter,
>>> then I would hard-code that in the trait instead of specifying it here.
>>
>> I do not follow, hard-code in which trait?
>>
>>> But I think you just want `P: AsPageIter`.
>>
>> Yeah, I thought for now it's probably good enough to require VmallocPageIter and
>> revisit once we get more implementors of AsPageIter, but I think we can also do
>> it right away.
>>
>> I think we'd need a trait PageIterator, which implements page_count(), since we
>> technically can't rely on Iterator::size_hint(). Though, in this case I think we
>> can also just make AsPageIter::Iter: ExactSizeIterator?
>
> Forgot to mention this [1] as for why we expect VmallocPageIter (at least for
> now).
Actually, let me expand on this a bit:
What I mean is that for some generic page::AsPageIter we don't know anything
about the semantics of the order of the pages; this is implementation specific
to the actual Iterator implementation, such as VmallocPageIter.
(For instance, VmallocPageIter iterates pages in the order as they are
virtually contiguous mapped by Vmalloc. VmallocPageIter documents this in the
context of a guarantees section.)
Thus, before allowing any AsPageIter::Iter in SGTable::new(), I'd like to see
actual implementations and subsequently figure out if it makes sense to add
additional (empty) traits providing such kind of guarantees.
> [1] https://lore.kernel.org/rust-for-linux/958ef505-8713-4f88-9f24-5971ce8a08ce@kernel.org/
Powered by blists - more mailing lists