From: Joel Fernandes <joelagnelf@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>
Cc: linux-kernel@vger.kernel.org, Miguel Ojeda <ojeda@kernel.org>,
Boqun Feng <boqun@kernel.org>, Gary Guo <gary@garyguo.net>,
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>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
rust-for-linux@vger.kernel.org,
Alexandre Courbot <acourbot@nvidia.com>,
arunpravin.paneerselvam@amd.com, joel@joelfernandes.org
Subject: Re: [PATCH v11 4/4] rust: gpu: Add GPU buddy allocator bindings
Date: Mon, 2 Mar 2026 16:18:56 -0500 [thread overview]
Message-ID: <7b3146c1-ce5a-4bf9-9837-57c19b24ada9@nvidia.com> (raw)
In-Reply-To: <DGPPKJ5W6FVD.29LI1HKSBZSG2@kernel.org>
Hi Danilo,
On Fri, Feb 27, 2026 at 12:30:20PM +0100, Danilo Krummrich wrote:
> >
> > +RUST [GPU BUDDY]
> > +M: Joel Fernandes <joelagnelf@nvidia.com>
> > +L: dri-devel@lists.freedesktop.org
> > +L: rust-for-linux@vger.kernel.org
> > +S: Maintained
> > +F: rust/helpers/gpu.c
> > +F: rust/kernel/gpu/
>
> What about adding this to the existing GPU BUDDY ALLOCATOR entry? Maybe you can
> offer Matthew and Arun your help.
>
> Also, this wouldn't be a subentry of "RUST", but the rust version of GPU BUDDY,
> so it would be "GPU BUDDY [RUST]".
>
> Also, please add rust/kernel/gpu/ to the "DRM DRIVERS AND COMMON INFRASTRUCTURE
> [RUST]" entry.
Both these additions sound good to me. Just to list all the options below
so we save time on what we all agree on:
1. New GPU BUDDY [RUST] entry.
2. Add it under the existing "DRM DRIVERS AND COMMON INFRASTRUCTURE
[RUST]"
3. Add the rust files under the existing "GPU BUDDY ALLOCATOR" and add
myself and Alex as R:/M:
Which of these options make sense? Personally, I think #2 makes sense
since we are already suggesting to add it to the existing DRM RUST entry
anyway - we can just drop the new record and add rust/helpers/gpu.c
there as well. That's what I've done for now. Does that work for you/others?
> > +/// # Invariants
> > +///
> > +/// The inner [`Opaque`] contains a valid, initialized buddy allocator.
>
> The invariant should be justified in the constructor. Also, where is it used?
Done. Added `// INVARIANT:` justification in `GpuBuddyInner::new()` and
cited at all usage sites (ex, alloc_blocks).
> > +// SAFETY: GpuBuddyInner is `Sync` because the internal GpuBuddyGuard
> > +// serializes all access to the C allocator, preventing data races.
>
> I think it's more precise to refer to GpuBuddyInner::lock.
Agreed. Fixed to reference `GpuBuddyInner::lock`.
> > +/// # Invariants
> > +///
> > +/// The inner [`Arc`] points to a valid, initialized GPU buddy allocator.
>
> Do we need this invariant? Isn't this implied by the GpuBuddyInner type?
Right, removed.
> > + // SAFETY: list contains gpu_buddy_block items linked via __bindgen_anon_1.link.
> > + let clist = clist_create!(unsafe {
>
> This macro has three separate safety requirements, please justify all of them.
> Also, please also use markdown in safety comments.
Done. Expanded to justify all three safety requirements.
> > +pub struct Block(Opaque<bindings::gpu_buddy_block>);
>
> Does this need to be public? I don't see it being exposed by any API.
You're right. Made it private.
> > +/// An allocated block with access to the GPU buddy allocator.
>
> This needs a better description, i.e. what makes an `AllocatedBlock different
> compared to a "normal" Block.
Updated to the following:
/// A [`Block`] paired with its owning [`AllocatedBlocks`] context.
///
/// Unlike a raw [`Block`], which only knows its offset within the buddy address
/// space, an [`AllocatedBlock`] also has access to the allocator's
/// `base_offset` and `chunk_size`, enabling it to compute absolute offsets and
/// byte sizes.
///
/// Returned by [`AllocatedBlocks::iter()`].
pub struct AllocatedBlock<'a> {
this: &'a Block,
blocks: &'a AllocatedBlocks,
}
> > +/// - `block` is a valid reference to an allocated [`Block`].
> > +/// - `alloc` is a valid reference to the [`AllocatedBlocks`] that owns this block.
>
> References should always be valid, no need to mention that.
Removed.
> > + block: &'a Block,
>
> NIT: What about just naming it "this" and
>
> > + alloc: &'a AllocatedBlocks,
>
> "blocks"?
Done, that's better.
thanks,
--
Joel Fernandes
next prev parent reply other threads:[~2026-03-02 21:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 22:40 [PATCH v11 0/4] Rust " Joel Fernandes
2026-02-24 22:40 ` [reference PATCH v11 1/4] gpu: Move DRM buddy allocator one level up (part one) Joel Fernandes
2026-02-24 22:40 ` [reference PATCH v11 2/4] gpu: Move DRM buddy allocator one level up (part two) Joel Fernandes
2026-02-24 22:40 ` [reference PATCH v11 3/4] gpu: Fix uninitialized buddy for built-in drivers Joel Fernandes
2026-02-24 22:40 ` [PATCH v11 4/4] rust: gpu: Add GPU buddy allocator bindings Joel Fernandes
2026-02-25 14:38 ` Alexandre Courbot
2026-02-25 20:41 ` Joel Fernandes
2026-02-26 2:26 ` Alexandre Courbot
2026-02-26 21:42 ` Joel Fernandes
2026-02-27 12:00 ` Alexandre Courbot
2026-02-27 11:30 ` Danilo Krummrich
2026-03-02 21:18 ` Joel Fernandes [this message]
2026-03-03 21:43 ` Dave Airlie
2026-03-03 22:03 ` Danilo Krummrich
2026-02-27 12:08 ` Danilo Krummrich
2026-03-02 20:16 ` Joel Fernandes
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=7b3146c1-ce5a-4bf9-9837-57c19b24ada9@nvidia.com \
--to=joelagnelf@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@redhat.com \
--cc=aliceryhl@google.com \
--cc=arunpravin.paneerselvam@amd.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--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
Powered by JetHome