All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gary Guo" <gary@garyguo.net>
Cc: ojeda@kernel.org, "Alexandre Courbot" <acourbot@nvidia.com>,
	dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org,
	"Danilo Krummrich" <dakr@kernel.org>
Subject: Re: [PATCH v2 04/16] rust: io: register: handle one register at a time
Date: Wed, 05 Aug 2026 16:43:40 +0000	[thread overview]
Message-ID: <20260805164341.7E2511F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-typed_register-v2-4-c3ca142220a0@garyguo.net>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The refactored `register!` macro uses a tail-recursive TT-muncher pattern, which increases macro recursion depth linearly with the number of registers defined. This can cause compilation failures (reaching rustc's recursion limit) for macro blocks defining a large number of registers.
--

--- Patch [4]: [PATCH v2 04/16] rust: io: register: handle one register at a time ---
commit 8ec2a5aa6d4bcb8811ecb0ce6d13218a169b562d
Author: Gary Guo <gary@garyguo.net>

rust: io: register: handle one register at a time

This commit refactors the register! macro to match and handle one register
definition at a time using a recursive pattern. It aims to simplify the rule
definitions by avoiding a single catch-all repetition rule.

> diff --git a/rust/kernel/io/register.rs b/rust/kernel/io/register.rs
> index d898b2b46d521..91804c1ca117d 100644
> --- a/rust/kernel/io/register.rs
> +++ b/rust/kernel/io/register.rs
[ ... ]
> @@ -786,44 +786,25 @@ fn into_io_op(self) -> (FixedRegisterLoc<T>, T) {
>  /// ```
>  #[macro_export]
>  macro_rules! register {
[ ... ]
> -    // All the rules below are private helpers.
> +    () => {};
>  
>      // Creates a register at a fixed offset of the MMIO space.
>      (
> -        @reg $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty) @ $offset:literal
> +        $(#[$attr:meta])* $vis:vis $name:ident ($storage:ty) @ $offset:literal
>              { $($fields:tt)* }
> +        $($rest:tt)*
>      ) => {
>          $crate::register!(@bitfield $(#[$attr])* $vis struct $name($storage) { $($fields)* });
>          $crate::register!(@io_base $name @ $offset);
>          $crate::register!(@io_fixed $(#[$attr])* $vis $name);
> +        $crate::register!($($rest)*);

[Severity: Low]
Does this recursive pattern increase the macro recursion depth linearly with
the number of registers defined?

If a single register! block contains a large number of registers, this tail
recursion might exceed rustc's default recursion limit and cause compilation
failures. While this can be worked around by splitting the definitions into
multiple register! invocations, it is a regression compared to the previous
repetition pattern.

>      };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-typed_register-v2-0-c3ca142220a0@garyguo.net?part=4

  reply	other threads:[~2026-08-05 16:43 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 16:35 [PATCH v2 00/16] rust: io: support register projections and remove relative registers Gary Guo
2026-08-05 16:35 ` [PATCH v2 01/16] rust: io: add static `cast()` method for views Gary Guo
2026-08-05 16:50   ` sashiko-bot
2026-08-10  9:29   ` Alexandre Courbot
2026-08-05 16:35 ` [PATCH v2 02/16] rust: io: add `IoRepr` trait Gary Guo
2026-08-05 16:46   ` sashiko-bot
2026-08-10  9:30   ` Alexandre Courbot
2026-08-10 11:21     ` Gary Guo
2026-08-12  4:51       ` Alexandre Courbot
2026-08-05 16:35 ` [PATCH v2 03/16] rust: io: support register projections Gary Guo
2026-08-05 16:42   ` sashiko-bot
2026-08-10  9:30   ` Alexandre Courbot
2026-08-10 11:23     ` Gary Guo
2026-08-05 16:35 ` [PATCH v2 04/16] rust: io: register: handle one register at a time Gary Guo
2026-08-05 16:43   ` sashiko-bot [this message]
2026-08-10  9:30   ` Alexandre Courbot
2026-08-05 16:35 ` [PATCH v2 05/16] rust: io: register extract offset computation to helper rules Gary Guo
2026-08-05 16:42   ` sashiko-bot
2026-08-10  9:31   ` Alexandre Courbot
2026-08-05 16:35 ` [PATCH v2 06/16] rust: io: register: allow explicit base type specification Gary Guo
2026-08-05 16:43   ` sashiko-bot
2026-08-10  9:32   ` Alexandre Courbot
2026-08-05 16:35 ` [PATCH v2 07/16] gpu: nova-core: specify base type for registers Gary Guo
2026-08-05 16:42   ` sashiko-bot
2026-08-05 16:35 ` [PATCH v2 08/16] drm/tyr: " Gary Guo
2026-08-05 16:47   ` sashiko-bot
2026-08-05 16:59   ` Gary Guo
2026-08-05 16:35 ` [PATCH v2 09/16] samples: rust: pci: " Gary Guo
2026-08-05 16:41   ` sashiko-bot
2026-08-05 16:35 ` [PATCH v2 10/16] rust: io: register: make register have a typed base Gary Guo
2026-08-05 16:43   ` sashiko-bot
2026-08-05 16:35 ` [PATCH v2 11/16] rust: io: register: support fixed offset register without bitfield Gary Guo
2026-08-05 16:50   ` sashiko-bot
2026-08-05 17:05     ` Gary Guo
2026-08-12  9:01   ` Alexandre Courbot
2026-08-05 16:35 ` [PATCH v2 12/16] gpu: nova-core: use projection for PFALCON and PFALCON2 registers Gary Guo
2026-08-05 16:46   ` sashiko-bot
2026-08-05 16:35 ` [PATCH v2 13/16] gpu: nova-core: convert hshub0 from relative register to projection Gary Guo
2026-08-05 16:48   ` sashiko-bot
2026-08-05 16:35 ` [PATCH v2 14/16] rust: io: register: remove relative registers Gary Guo
2026-08-05 16:51   ` sashiko-bot
2026-08-05 16:35 ` [PATCH v2 15/16] rust: io: register: remove `Register` trait and cleanup macro Gary Guo
2026-08-05 16:48   ` sashiko-bot
2026-08-05 16:35 ` [PATCH v2 16/16] rust: io: register: unify handling of register with/without bitfields Gary Guo
2026-08-05 16:51   ` sashiko-bot

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=20260805164341.7E2511F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=linux-pci@vger.kernel.org \
    --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.