NVIDIA GPU driver infrastructure
 help / color / mirror / Atom feed
From: "Eliot Courtney" <ecourtney@nvidia.com>
To: "Yury Norov" <ynorov@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Burak Emir" <burak.emir@gmail.com>,
	"Yury Norov" <yury.norov@gmail.com>,
	"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>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>, "Zhi Wang" <zhiw@nvidia.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
	dri-devel <dri-devel-bounces@lists.freedesktop.org>
Subject: Re: [PATCH v5 5/5] gpu: nova-core: add ChannelIdPool
Date: Mon, 17 Aug 2026 16:03:51 +0900	[thread overview]
Message-ID: <DKR0ZNGYW9IT.37N7TEN97GG3N@nvidia.com> (raw)
In-Reply-To: <an8r4VECQ8iFP8ze@yury>

On Fri Aug 14, 2026 at 11:53 PM JST, Yury Norov wrote:
> On Fri, Aug 14, 2026 at 05:08:43AM -0400, Yury Norov wrote:
>> On Fri, Aug 14, 2026 at 01:54:24PM +0900, Eliot Courtney wrote:
>> > > 1. Provide a nz! macro to create constant non-zero things. Provide some
>> > >    constants for common alignments
>> > >
>> > > Potentially, we could use build_assert! for cases it is provably
>> > > non-zero but not a literal (although tbh not sure this is a good idea -
>> > > at least not do this initially). 
>> > >
>> > > So either: nz!: const { NonZero::new(value).unwrap() }, or, nz!: some
>> > > build assert gated construction of NonZero. A general nz! macro could
>> > > also help ergonomics for other use cases too.
>> > >
>> > > That looks like this:
>> > >
>> > > pool.alloc_area(nz!(8), Alignment::AL_8)?;
>> > 
>> > Actually found that if we implement SizeConstants for Alignment then we
>> > can get Alignment::SZ_4K etc almost for free.
>> 
>> Then maybe pass SZ_4K directly, and allow the alloc_area() to
>> calculate the alignment:
>> 
>>         pool.alloc_area(nz!(8), SZ_4K)?;
>
> Even worse, you can advertise the function like: allocate a contiguous
> set of channel IDs enough to represent XXX bytes of memory with YYY
> alignment. And that way, you'll be able to do:
>
>           pool.alloc_area(SZ_8K, SZ_4K)?;
>
> If my understanding of the function is right, it would be a clear
> improvement, because the user now doesn't think about ID channels pool
> as a set of bits, but an abstraction over the memory access technique,
> which it really is.

If we pass SZ_4K directly, we are back to using plain integers, which is
not what we should be doing for rust interfaces according to Miguel. Let
me send a new version of this with my Alignment constants + nz! macro
idea, IMO it helps with the verbosity.

I don't quite understand your point about memory access. The purpose
here is just to be an allocator of IDs, not memory - it's just that we
have some contiguousness and alignment requirements of the IDs
themselves.  The values we're passing in just represent numbers of
channels and constraints on those. I think that callers will naturally
want to allocate a particular number of channels, not a specific amount
of memory that corresponds to some number of channels in some way (e.g.
USERD?). On pre-Blackwell, OpenRM makes channel ID area reservations for
vGPU power of two number of channels and and places them so the base
channel ID is aligned to the number of channels. Sorry if I have
misunderstood your point. Maybe we should rename `alloc_area` to
`reserve_ids` or something like that if it would make it clearer?


  reply	other threads:[~2026-08-17  7:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12  8:51 [PATCH v5 0/5] rust: Add support for reserving of ranges of IDs Eliot Courtney
2026-08-12  8:51 ` [PATCH v5 1/5] rust: bitmap: use function-level cfg on kunit test Eliot Courtney
2026-08-12 22:23   ` Yury Norov
2026-08-12  8:51 ` [PATCH v5 2/5] rust: bitmap: restrict bitmap length to at most i32::MAX Eliot Courtney
2026-08-12 19:44   ` Yury Norov
2026-08-12  8:51 ` [PATCH v5 3/5] rust: bitmap: add contiguous area operations Eliot Courtney
2026-08-12 20:31   ` Yury Norov
2026-08-13  7:27     ` Eliot Courtney
2026-08-12  8:51 ` [PATCH v5 4/5] rust: id_pool: add contiguous area allocation Eliot Courtney
2026-08-12 21:16   ` Yury Norov
2026-08-13  7:29     ` Eliot Courtney
2026-08-12  8:51 ` [PATCH v5 5/5] gpu: nova-core: add ChannelIdPool Eliot Courtney
2026-08-12 22:18   ` Yury Norov
2026-08-13  7:31     ` Eliot Courtney
2026-08-13 18:32       ` Yury Norov
2026-08-13 20:20         ` Miguel Ojeda
2026-08-13 20:48         ` Danilo Krummrich
2026-08-13 20:58           ` Gary Guo
2026-08-13 21:38             ` John Hubbard
2026-08-13 21:44               ` Yury Norov
2026-08-13 21:53                 ` John Hubbard
2026-08-13 21:03           ` Yury Norov
2026-08-14  2:14             ` Eliot Courtney
2026-08-14  4:54               ` Eliot Courtney
2026-08-14  9:08                 ` Yury Norov
2026-08-14 14:53                   ` Yury Norov
2026-08-17  7:03                     ` Eliot Courtney [this message]
2026-08-17 10:54                       ` Gary Guo
2026-08-17 11:18                         ` Danilo Krummrich
2026-08-17 11:49                           ` Eliot Courtney
2026-08-17 12:16                             ` Danilo Krummrich
2026-08-17 12:37                               ` Eliot Courtney
2026-08-17 13:02                               ` Gary Guo
2026-08-17 14:08                                 ` 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=DKR0ZNGYW9IT.37N7TEN97GG3N@nvidia.com \
    --to=ecourtney@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=burak.emir@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel-bounces@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=work@onurozkan.dev \
    --cc=ynorov@nvidia.com \
    --cc=yury.norov@gmail.com \
    --cc=zhiw@nvidia.com \
    /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