rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alice Ryhl" <aliceryhl@google.com>
Cc: <akpm@linux-foundation.org>, <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>,
	<jgg@ziepe.ca>, <lyude@redhat.com>, <robin.murphy@arm.com>,
	<daniel.almeida@collabora.com>, <rust-for-linux@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/4] rust: scatterlist: Add type-state abstraction for sg_table
Date: Mon, 18 Aug 2025 15:12:17 +0200	[thread overview]
Message-ID: <DC5KVFUTRCA6.3Q3YQD4L026D2@kernel.org> (raw)
In-Reply-To: <DC5JSHSVPY3P.2HXRIGE8IZOIE@kernel.org>

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/

  reply	other threads:[~2025-08-18 13:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-15 17:10 [PATCH 0/4] Rust infrastructure for sg_table and scatterlist Danilo Krummrich
2025-08-15 17:10 ` [PATCH 1/4] rust: dma: implement DataDirection Danilo Krummrich
2025-08-18  9:34   ` Alice Ryhl
2025-08-18 11:27     ` Danilo Krummrich
2025-08-18 11:56       ` Miguel Ojeda
2025-08-18 12:24         ` Miguel Ojeda
2025-08-18 20:42         ` Danilo Krummrich
2025-08-18 12:22       ` Alice Ryhl
2025-08-18 12:57         ` Danilo Krummrich
2025-08-18 14:00           ` Alice Ryhl
2025-08-18 17:23             ` Danilo Krummrich
2025-08-18 18:47               ` Alice Ryhl
2025-08-18 21:03                 ` Danilo Krummrich
2025-08-20 13:17                   ` Daniel Almeida
2025-08-20 13:40                     ` Danilo Krummrich
2025-08-15 17:10 ` [PATCH 2/4] rust: scatterlist: Add type-state abstraction for sg_table Danilo Krummrich
2025-08-18  9:52   ` Alice Ryhl
2025-08-18 11:16     ` Danilo Krummrich
2025-08-18 12:21       ` Danilo Krummrich
2025-08-18 13:12         ` Danilo Krummrich [this message]
2025-08-18 12:27       ` Alice Ryhl
2025-08-18 12:37         ` Danilo Krummrich
2025-08-20 17:08   ` Daniel Almeida
2025-08-20 18:59     ` Danilo Krummrich
2025-08-15 17:10 ` [PATCH 3/4] samples: rust: dma: add sample code for SGTable Danilo Krummrich
2025-08-15 17:10 ` [PATCH 4/4] MAINTAINERS: rust: dma: add scatterlist files 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=DC5KVFUTRCA6.3Q3YQD4L026D2@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=abdiel.janulgue@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=lyude@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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).