Re: [PATCH 1/2] rust: Add initial cpumask abstractions

From: Viresh Kumar
Date: Fri Feb 28 2025 - 02:10:16 EST


On 27-02-25, 13:19, Alice Ryhl wrote:
> On Thu, Feb 27, 2025 at 11:46 AM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
> > impl Cpumask {
> > - /// Creates a reference to an existing `struct cpumask` pointer.
> > + /// Creates a mutable reference to an existing `struct cpumask` pointer.
> > ///
> > /// # Safety
> > ///
> > /// The caller must ensure that `ptr` is valid for writing and remains valid for the lifetime
> > /// of the returned reference.
> > - pub unsafe fn from_raw_mut<'a>(ptr: *mut bindings::cpumask) -> &'a mut Self {
> > + pub unsafe fn from_raw_mut<'a>(ptr: *mut bindings::cpumask_var_t) -> &'a mut Self {
>
> Why?

cpufreq core has a pointer to cpumask_var_t.

> Perhaps put this on the CpumaskBox and keep the `struct cpumask` one here?

Yeah, that worked. I think we will anyway have both type of users and
its better to have both implemented.

--
viresh