Messages in this thread | | | Subject | Re: [PATCH v3 1/4] cpumask: Fix invalid uniprocessor mask assumption | From | Sander Vanheule <> | Date | Tue, 07 Jun 2022 14:06:38 +0200 |
| |
On Mon, 2022-06-06 at 12:14 -0700, Yury Norov wrote: > On Sun, Jun 05, 2022 at 08:22:38AM +0200, Sander Vanheule wrote: > > On uniprocessor builds, any CPU mask is assumed to contain exactly one > > CPU (cpu0). This assumption ignores the existence of empty masks, > > resulting in incorrect behaviour. > > cpumask_first_zero(), cpumask_next_zero(), and for_each_cpu_not() don't > > provide behaviour matching the assumption that a UP mask is always "1", > > and instead provide behaviour matching the empty mask. > > > > Drop the incorrectly optimised code and use the generic implementations > > in all cases. > > > > Signed-off-by: Sander Vanheule <sander@svanheule.net> > > ---
[...]
> > -static inline unsigned int cpumask_local_spread(unsigned int i, int node) > > -{ > > - return 0; > > -} > > - > > -static inline int cpumask_any_and_distribute(const struct cpumask *src1p, > > - const struct cpumask *src2p) { > > - return cpumask_first_and(src1p, src2p); > > -} > > - > > -static inline int cpumask_any_distribute(const struct cpumask *srcp) > > -{ > > - return cpumask_first(srcp); > > -} > > It looks like cpumask_local_spread, cpumask_any_and_distribute and > cpumask_any_distribute were correct and better optimized in UP case. > cpumask_local_spread - for sure. I think it's worth keeping them > optimized.
Yes, these were correct and we can keep them. I will have to add an #ifded CONFIG_SMP (or #if NR_CPUS > 1) guard in lib/cpumask.c around these functions, so they don't collide with the inlined UP versions.
Best, Sander
| |