Re: [PATCH 1/2] rust: Add cpumask helpers
From: Yury Norov
Date: Mon Feb 24 2025 - 14:40:40 EST
On Mon, Feb 24, 2025 at 02:26:13PM +0530, Viresh Kumar wrote:
> Hi Yury,
>
> On 21-02-25, 15:56, Yury Norov wrote:
> > Question: zalloc_cpumask_war() is a convenient wrapper around
> > alloc_cpumask_var_node(). Maybe rust can use the latter directly as it's
> > a true outlined function? There's more flexibility, if you need it, but
> > also a higher risk that the API will change: ~40 users vs 180 for zalloc
> > thing. Up to you guys. I can send v2 if needed.
>
> I looked at the APIs again and here is what I feel:
>
> - I am not sure if the Rust code will have any users of the *_node()
> APIs in the near future. i.e. There is no need for the Rust code to
> implement Cpumask::new_node() version for now.
>
> - I have missed implementing the uninitialized version earlier,
> alloc_cpumask_var(), which I think should be implemented right away.
> Bindings for alloc_cpumask_var() are required to be added for this
> though.
>
> - One advantage of using zalloc_cpumask_var() instead of
> alloc_cpumask_var() is that we don't need to open code it in the
> Rust code, specifically for the !CONFIG_CPUMASK_OFFSTACK case where
> we need to call cpumask_clear() separately.
>
> - The Rust side can have following abstractions for now:
>
> pub fn new() -> Result<Self>;
> pub fn new_zeroed() -> Result<Self>;
>
> --
> viresh
OK, if you need both I'll export both. I'll send it in v2 together
with clarifications from discussion with Miguel.