The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Eliot Courtney" <ecourtney@nvidia.com>
To: "Yury Norov" <ynorov@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>
Cc: "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>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"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 v2 0/4] rust: Add support for reserving of ranges of IDs
Date: Wed, 29 Jul 2026 14:58:12 +0900	[thread overview]
Message-ID: <DKATP1C14JRZ.1A2PCWTGAVAHY@nvidia.com> (raw)
In-Reply-To: <amN_ZfhoV9eF03Jr@yury>

On Sat Jul 25, 2026 at 12:06 AM JST, Yury Norov wrote:
> On Thu, Jul 23, 2026 at 05:59:09PM +0900, Eliot Courtney wrote:
>> Add support for reserving of ranges of IDs, with a usage in nova-core
>> for channel IDs. This entails adding bindings for the C bitmap
>> API for ranges of bits, then users of that in `IdPool`, and finally a
>> user of `IdPool` in nova-core, `ChannelIdPool`.
>> 
>> Channel ID tracking is needed for allotting ranges of channel IDs to
>> vGPU guests, and later for regular host channel ID reservation.
>> nova-core needs allocation of a contiguous sequence of IDs with a
>> specific length and sometimes a specific alignment [1].
>> 
>> About the tradeoffs between different data structures:
>> - IDA/xarray do not support allocating a contiguous sequence of IDs
>>   (ida_alloc_range() allocates a single ID within a range, not a contiguous
>>   sequence).
>> - A maple tree works, but is not as good a fit. The ID space is small
>>   (limited to 2048) and aligned allocation needs an alloc_range()+erase() retry
>>   loop (plus a Mutex around it, or new mas_empty_area() bindings) that
>>   essentially reimplements bitmap_find_next_zero_area(). See the maple tree
>>   version at [2]. For 2048 IDs a bitmap is also considerably faster and smaller
>>   [3].
>> - The bitmap API natively supports aligned contiguous area allocation
>>   (bitmap_find_next_zero_area()).
>> 
>> This is based on drm-rust-next.
>> 
>> [1]: https://lore.kernel.org/all/84bc8bd2-e292-4b84-9580-a1b5df4c5bdc@nvidia.com/
>> [2]: https://lore.kernel.org/all/20260710-chid-maple-v1-1-4ee869055268@nvidia.com/
>> [3]: https://lore.kernel.org/all/20260717053241.916441-1-ynorov@nvidia.com/
>
> If you refer my test, I'd like to make sure you've reviewed it and
> tested in your environment. Please send the appropriate tags.

Have done so - thank you for your help in benchmarking!

> Also, would you like to add it to your series? I can to move it myself,
> but I can defer it to you if you prefer.

Happy for you to take it yourself unless you would prefer me to.

>
> Thanks,
> Yury
>  
>> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
>> ---
>> Changes in v2:
>> - Collected Alice's Reviewed-by on patch 1.
>> - Address Yury's comments w.r.t. using __bitmap_set etc directly.
>> - Address Yury's comments w.r.t. following the C names
>> - Additionally check for an overflow case that causes a hang
>> - Added more info to cover letter + patch 4 w.r.t. channel ID allottment
>>   requirements
>> - Add align parameter to ChannelIdPool::alloc_area() plus an aligned
>>   allocation test
>> - Add missing INVARIANT comment when constructing UnusedArea
>> - Link to v1:
>>   https://patch.msgid.link/20260703-chid-v1-0-84fe8259e46e@nvidia.com
>> 
>> ---
>> Eliot Courtney (4):
>>       rust: bitmap: use function-level cfg on kunit test
>>       rust: bitmap: add contiguous area operations
>>       rust: id_pool: add contiguous area allocation
>>       gpu: nova-core: add ChannelIdPool
>> 
>>  drivers/gpu/nova-core/gpu.rs         |   2 +
>>  drivers/gpu/nova-core/gpu/channel.rs | 182 ++++++++++++++++++++++++++
>>  rust/kernel/bitmap.rs                | 242 +++++++++++++++++++++++++++++++++--
>>  rust/kernel/id_pool.rs               |  69 ++++++++++
>>  4 files changed, 481 insertions(+), 14 deletions(-)
>> ---
>> base-commit: 71d4e7233f235871b13553e504e591ace6b54373
>> change-id: 20260608-chid-18fa943c6d6c
>> 
>> Best regards,
>> --  
>> Eliot Courtney <ecourtney@nvidia.com>


      reply	other threads:[~2026-07-29  5:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  8:59 [PATCH v2 0/4] rust: Add support for reserving of ranges of IDs Eliot Courtney
2026-07-23  8:59 ` [PATCH v2 1/4] rust: bitmap: use function-level cfg on kunit test Eliot Courtney
2026-07-23  8:59 ` [PATCH v2 2/4] rust: bitmap: add contiguous area operations Eliot Courtney
     [not found]   ` <amHtZeAl3VFsibE1@google.com>
2026-07-29  5:35     ` Eliot Courtney
2026-07-23  8:59 ` [PATCH v2 3/4] rust: id_pool: add contiguous area allocation Eliot Courtney
2026-07-23  8:59 ` [PATCH v2 4/4] gpu: nova-core: add ChannelIdPool Eliot Courtney
2026-07-24 15:06 ` [PATCH v2 0/4] rust: Add support for reserving of ranges of IDs Yury Norov
2026-07-29  5:58   ` Eliot Courtney [this message]

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=DKATP1C14JRZ.1A2PCWTGAVAHY@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