[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DDX3S62U4O46.133LFLRFHMZI3@nvidia.com>
Date: Sat, 01 Nov 2025 14:19:18 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Joel Fernandes" <joelagnelf@...dia.com>,
<linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>,
<dri-devel@...ts.freedesktop.org>, <dakr@...nel.org>, "David Airlie"
<airlied@...il.com>
Cc: <acourbot@...dia.com>, "Alistair Popple" <apopple@...dia.com>, "Miguel
Ojeda" <ojeda@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>, "Boqun
Feng" <boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>,
<bjorn3_gh@...tonmail.com>, "Benno Lossin" <lossin@...nel.org>, "Andreas
Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Trevor Gross" <tmgross@...ch.edu>, "Simona Vetter" <simona@...ll.ch>,
"Maarten Lankhorst" <maarten.lankhorst@...ux.intel.com>, "Maxime Ripard"
<mripard@...nel.org>, "Thomas Zimmermann" <tzimmermann@...e.de>, "John
Hubbard" <jhubbard@...dia.com>, "Timur Tabi" <ttabi@...dia.com>,
<joel@...lfernandes.org>, "Elle Rhumsaa" <elle@...thered-steel.dev>,
"Daniel Almeida" <daniel.almeida@...labora.com>, "Andrea Righi"
<arighi@...dia.com>, "Philipp Stanner" <phasta@...nel.org>,
<nouveau@...ts.freedesktop.org>, "Nouveau"
<nouveau-bounces@...ts.freedesktop.org>
Subject: Re: [PATCH RFC 3/4] rust: drm: Add DRM buddy allocator bindings
On Fri Oct 31, 2025 at 4:06 AM JST, Joel Fernandes wrote:
<snip>
> + /// Allocate blocks from the buddy allocator.
> + ///
> + /// Returns an [`AllocatedBlocks`] structure that owns the allocated blocks and automatically
> + /// frees them when dropped. Allocation of `list_head` uses the `gfp` flags passed.
> + pub fn alloc_blocks(
> + &self,
> + start: usize,
> + end: usize,
> + size: usize,
> + min_block_size: usize,
> + flags: BuddyFlags,
> + gfp: Flags,
> + ) -> Result<AllocatedBlocks<'_>> {
It looks like some of the flags heavily modify the behavior of the
allocator, and make some of the parameters irrelevant (for instance,
IIUC `start` and `end` only make sense if `RANGE_ALLOCATION` is
passed?).
In that case, we should either have several allocation methods, or have
an `AllocationRequest` enum which variants are the allocation type and its
relevant parameters. E.g (very naively):
enum AllocationRange {
Whole,
Ranged(Range<u64>),
...
}
struct AllocationRequest {
range: AllocationRange,
top_down: bool,
contiguous: bool,
clear: bool,
}
I.e. use the type system to make sure we can only express things that
make sense, and never pass data that will end up being ignored.
If we do that well, I think we can drop the `BuddyFlags` type
altogether, which is great as it seems to serve several different
purposes.
Powered by blists - more mailing lists