[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72=WpuGELzLbH-fxdOeJy9fiDFwatz6ynERDh=HP2z2MBw@mail.gmail.com>
Date: Mon, 9 Jun 2025 14:01:27 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Viresh Kumar <viresh.kumar@...aro.org>
Cc: Boqun Feng <boqun.feng@...il.com>, "Rafael J. Wysocki" <rafael@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, Peter Zijlstra <peterz@...radead.org>,
Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <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>,
Danilo Krummrich <dakr@...nel.org>, Vincent Guittot <vincent.guittot@...aro.org>,
Yury Norov <yury.norov@...il.com>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH V2 1/2] rust: cpu: Introduce CpuId abstraction
On Mon, Jun 9, 2025 at 12:51 PM Viresh Kumar <viresh.kumar@...aro.org> wrote:
>
> +/// Represents a CPU identifier as a wrapper around an `u32`.
[`u32`]
> +/// # Invariants
> +///
> +/// The CPU ID must always lie within the range `[0, nr_cpu_ids())`.
I think we can simplify to "ID lies", i.e. "must always" is not needed
(but we use it elsewhere form time to time, though we may end up
cleaning those too).
> +/// ## Examples
Single `#`.
> + pub unsafe fn from_i32_unchecked(id: i32) -> Self {
Why do we need the `i32` versions?
Is it just for `bios_limit_callback`? If so, I would just convert there.
>From a quick look at the C side, it seems that could be an `u32` -- I
am not suggesting to change the C side now since we don't want to
complicate the fix, but perhaps something to consider in the future,
assuming there is no reason to have a signed integer there (e.g. an
unsigned integer is used in the policy struct).
Relatedly, why isn't that callback's type `c_int` on the Rust side?
I also opened a "good first issue" for a docs bit:
https://github.com/Rust-for-Linux/linux/issues/1169. I can open one
for the C FFI types if you think it should be changed.
Finally, can we add a `debug_assert!()` on the `_unchecked()` variant,
since it is something we can easily check?
Thanks!
Cheers,
Miguel
Powered by blists - more mailing lists