Re: [PATCH 1/2] rust: Add initial cpumask abstractions
From: Alice Ryhl
Date: Tue Feb 25 2025 - 12:18:30 EST
On Tue, Feb 25, 2025 at 6:02 PM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
>
> On Tue, 25 Feb 2025 at 17:23, Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> > Is it a problem if a value of type struct cpumask is moved? It looks
> > like it is just an array of longs?
>
> With the current code, if I replace the Box with an on-stack variable,
> the kernel crashes.
>
> In my usecase, the pointer to the cpumask array is sent to the OPP
> core, which may update the content, though it doesn't save the pointer.
>
> But for another usecase, the C code may end up saving the pointer.
I don't think that case applies here. Variables that could be stashed
like that need a destructor that removes the pointer from the relevant
C structures. This is because pinning only prevents the owner from
moving the variable - it doesn't prevent the owner from destroying it.
Alice