On Wed, 5 Jul 2023 19:12:45 +0100 Valentin Schneider <vschneid@xxxxxxxxxx> wrote: > +/* Optimisation of do_filter_cpumask() for scalar values */ > +static inline int > +do_filter_cpumask_scalar(int op, unsigned int cpu, const struct cpumask *mask) > +{ > + switch (op) { > + case OP_EQ: > + return cpumask_equal(mask, cpumask_of(cpu)); > + case OP_NE: > + return !cpumask_equal(mask, cpumask_of(cpu)); The above two can be optimized much more if the cpu is a scalar. If mask is anything but a single CPU, then EQ will always be false, and NE will always be true. If the mask contains a single CPU, then we should convert the mask into the scalar CPU and just do: case OP_EQ: return mask_cpu == cpu; case op_NE: return maks_cpu != cpu; -- Steve > + case OP_BAND: > + return cpumask_test_cpu(cpu, mask); > + default: > + return 0; > + } > +}