From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Joel Fernandes" <joelagnelf@nvidia.com>
Cc: linux-kernel@vger.kernel.org,
"Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Bj��rn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Dave Airlie" <airlied@redhat.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
rust-for-linux@vger.kernel.org,
"Nikola Djukic" <ndjukic@nvidia.com>
Subject: Re: [PATCH -next v9 1/3] rust: clist: Add support to interface with C linked lists
Date: Fri, 20 Feb 2026 10:57:13 +0900 [thread overview]
Message-ID: <DGJEZWJ0CXBS.1HN17L6PQL326@nvidia.com> (raw)
In-Reply-To: <ebd17ac8ab6d1e1ad6a8eb8defa49915@nvidia.com>
On Fri Feb 20, 2026 at 12:29 AM JST, Joel Fernandes wrote:
<snip>
>> > + pub unsafe fn from_raw<'a>(ptr: *mut bindings::list_head) -> &'a Self {
>> > + // SAFETY:
>> > + // - [`CList`] has same layout as [`CListHead`] due to repr(transparent).
>> > + // - Caller guarantees `ptr` is a valid, sentinel `list_head` object.
>> > + unsafe { &*ptr.cast() }
>> > + }
>>
>> IIUC you can call `CListHead::from_raw` here instead of repeating its
>> code.
>
> CListHead::from_raw returns &CListHead, but we need &CList<T, OFFSET>.
> Since CList is repr(transparent) over CListHead, the direct ptr.cast()
> is the correct approach - we'd need an additional cast after
> CListHead::from_raw anyway, which would be more code, not less.
Ah, in that case that works, yes.
>> > + fn next(&mut self) -> Option<Self::Item> {
>>
>> This method is the only one not marked `#[inline]`.
>
> Added #[inline], thanks for catching that.
>
>> > +impl<'a> FusedIterator for CListHeadIter<'a> {}
>>
>> I asked this a couple of times ([1], [2]) but got no reply, so let me
>> try again. :) Given that `list_head` is doubly-linked, can we also
>> implement `DoubleEndedIterator`?
>
> Apologies for the missed replies! Yes, DoubleEndedIterator makes sense
> for doubly-linked lists. I'll add it as a follow-up patch since it
> requires a prev() method and some additional iterator state tracking.
Mmm, I expected (without trying) that it would be trivial, but if it
requires big changes to the iterator then let's consider that as a
follow-up indeed to avoid delaying this series further.
next prev parent reply other threads:[~2026-02-20 1:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 23:32 [PATCH -next v9 0/3] rust: Add CList and GPU buddy allocator bindings Joel Fernandes
2026-02-10 23:32 ` [PATCH -next v9 1/3] rust: clist: Add support to interface with C linked lists Joel Fernandes
2026-02-11 9:23 ` Danilo Krummrich
2026-02-11 17:28 ` Joel Fernandes
2026-02-19 0:35 ` Alexandre Courbot
2026-02-19 0:59 ` Joel Fernandes
2026-02-19 2:47 ` Alexandre Courbot
2026-02-19 15:29 ` Joel Fernandes
2026-02-19 16:20 ` Joel Fernandes
2026-02-20 1:57 ` Alexandre Courbot [this message]
2026-02-10 23:32 ` [PATCH -next v9 2/3] rust: gpu: Add GPU buddy allocator bindings Joel Fernandes
2026-02-10 23:32 ` [PATCH -next v9 3/3] nova-core: mm: Select GPU_BUDDY for VRAM allocation Joel Fernandes
2026-02-11 9:21 ` Danilo Krummrich
2026-02-11 9:19 ` [PATCH -next v9 0/3] rust: Add CList and GPU buddy allocator bindings Danilo Krummrich
2026-02-11 17:30 ` Joel Fernandes
[not found] <20260211-v9-nova-mm-v9-0-a8e261c2e734@nvidia.com>
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=DGJEZWJ0CXBS.1HN17L6PQL326@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=airlied@redhat.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ndjukic@nvidia.com \
--cc=nouveau@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--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