Re: [PATCH v5 04/24] cpumask: Introduce cpu_preferred_mask
From: Yury Norov
Date: Fri Jun 26 2026 - 09:21:25 EST
On Fri, Jun 26, 2026 at 06:39:48PM +0530, Shrikanth Hegde wrote:
> Hi Peter, Yury.
>
> On 6/26/26 3:11 PM, Peter Zijlstra wrote:
> > On Fri, Jun 26, 2026 at 11:39:01AM +0200, Peter Zijlstra wrote:
> > > On Thu, Jun 25, 2026 at 06:16:28PM +0530, Shrikanth Hegde wrote:
> > >
> > > > diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> > > > index 80211900f373..5a643d608ea6 100644
> > > > --- a/include/linux/cpumask.h
> > > > +++ b/include/linux/cpumask.h
> > > > @@ -120,12 +120,20 @@ extern struct cpumask __cpu_enabled_mask;
> > > > extern struct cpumask __cpu_present_mask;
> > > > extern struct cpumask __cpu_active_mask;
> > > > extern struct cpumask __cpu_dying_mask;
> > > > +
> > > > +#ifdef CONFIG_PREFERRED_CPU
> > > > +extern struct cpumask __cpu_preferred_mask;
> > > > +#else
> > > > +#define __cpu_preferred_mask __cpu_active_mask
> > > > +#endif
> > >
> > > This is cure, but does it not result in set_cpu_preferred() changing
> > s/cure/cute/
> > > active mask, and it that not somewhat unexpected behaviour?
> > s/it/is/
> >
>
> Yes. I thought about this, but i didn't see anything bad happening apart from
> setting it twice. But I do agree, it is an eyesore when CONFIG_PREFERRED_CPU=n.
>
> > Typing hard, clearly. Also hitting 30C before noon :-(
> >
>
> Take care. Even we should have had monsoon by now.
> But its bright sunshine :(
>
> >
>
> For this reason, i had it as a function instead of macro in v4.
> Do you think we can still fallback to it?
>
> only caveat is it won't be a macro. But since it is still compile
> time optimized due to IS_ENABLED, it should be relatively ok right?
>
> +void set_cpu_preferred(unsigned int cpu, bool preferred)
> +{
> + if (!IS_ENABLED(CONFIG_PREFERRED_CPU))
> + return;
> +
> + assign_cpu((cpu), &__cpu_preferred_mask, (preferred));
> +}
#ifdef CONFIG_PREFERRED_CPU
#define set_cpu_preferred(cpu, preferred) assign_cpu((cpu), &__cpu_preferred_mask, (preferred))
#else
#define set_cpu_preferred(cpu, preferred) {}
#endif