All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eliot Courtney" <ecourtney@nvidia.com>
Cc: "Alexandre Courbot" <acourbot@nvidia.com>,
	ojeda@kernel.org, dri-devel@lists.freedesktop.org,
	"Danilo Krummrich" <dakr@kernel.org>
Subject: Re: [PATCH 3/4] rust: id_pool: add contiguous area allocation
Date: Fri, 03 Jul 2026 10:25:54 +0000	[thread overview]
Message-ID: <20260703102556.152721F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703-chid-v1-3-84fe8259e46e@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The construction of `UnusedArea` is missing the required `// INVARIANT:` comment.
--

commit dec3af2ba5f37136507d9a42f30fab7e3072db7f
Author: Eliot Courtney <ecourtney@nvidia.com>

rust: id_pool: add contiguous area allocation

This commit adds support for contiguous area allocation to the ID pool by
introducing a new UnusedArea type that follows the same pattern as UnusedId.

> diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
> index 384753fe0e44a..b471bfd974875 100644
> --- a/rust/kernel/id_pool.rs
> +++ b/rust/kernel/id_pool.rs
[ ... ]
> @@ -240,6 +245,33 @@ pub fn find_unused_id(&mut self, offset: usize) -> Option<UnusedId<'_>> {
>      pub fn release_id(&mut self, id: usize) {
>          self.map.clear_bit(id);
>      }
> +
> +    /// Finds a contiguous area of `count` unused IDs at or after `offset`.
> +    ///
> +    /// `align_mask` must be `0` (no alignment) or one less than a power of two, in which case the
> +    /// start of the returned area is a multiple of that power of two.
> +    ///
> +    /// Returns an [`UnusedArea`] upon success, or [`None`] if no such area could be found.
> +    #[inline]
> +    #[must_use]
> +    pub fn find_unused_area(
> +        &mut self,
> +        offset: usize,
> +        count: NonZero<usize>,
> +        align_mask: usize,
> +    ) -> Option<UnusedArea<'_>> {
> +        let start = self.map.next_zero_area(offset, count.get(), align_mask)?;
> +        Some(UnusedArea {
> +            range: start..start + count.get(),
> +            pool: self,
> +        })

[Severity: Low]
This isn't a bug, but should this UnusedArea instantiation include an
// INVARIANT: comment?

The Rust subsystem guidelines state that when a struct with an # Invariants
documentation section is constructed, the code should have an // INVARIANT:
comment explaining why the invariants are satisfied.

UnusedArea defines the invariant range.start <= range.end <= pool.map.len().
Would it be appropriate to add a comment here detailing why the bounds
guaranteed by next_zero_area() satisfy this invariant?

> +    }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260703-chid-v1-0-84fe8259e46e@nvidia.com?part=3

  reply	other threads:[~2026-07-03 10:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 10:16 [PATCH 0/4] rust: Add support for reserving of ranges of IDs Eliot Courtney
2026-07-03 10:16 ` [PATCH 1/4] rust: bitmap: use function-level cfg on kunit test Eliot Courtney
2026-07-03 10:16 ` [PATCH 2/4] rust: bitmap: add contiguous area operations Eliot Courtney
2026-07-03 10:30   ` sashiko-bot
2026-07-06 16:29   ` Yury Norov
2026-07-06 17:21     ` Alice Ryhl
2026-07-06 18:22       ` Gary Guo
2026-07-03 10:16 ` [PATCH 3/4] rust: id_pool: add contiguous area allocation Eliot Courtney
2026-07-03 10:25   ` sashiko-bot [this message]
2026-07-03 10:31   ` Greg KH
2026-07-07 13:25     ` Eliot Courtney
2026-07-03 10:16 ` [PATCH 4/4] gpu: nova-core: add ChannelIdPool Eliot Courtney
2026-07-06 11:48 ` [PATCH 0/4] rust: Add support for reserving of ranges of IDs Alice Ryhl
2026-07-06 11:53   ` Gary Guo
2026-07-06 12:46     ` Alice Ryhl
2026-07-07 13:26   ` Eliot Courtney
2026-07-07 13:32     ` Alice Ryhl

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=20260703102556.152721F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.