On Fri, Feb 11, 2022 at 07:54:26AM +0100, Sven Schnelle wrote: > Hi Yury, > > Yury Norov <yury.norov@xxxxxxxxx> writes: > > > cfset_all_start() calls cpumask_weight() to compare the weight of cpumask > > with a given number. We can do it more efficiently with > > cpumask_weight_{eq, ...} because conditional cpumask_weight may stop > > traversing the cpumask earlier, as soon as condition is (or can't be) met. > > > > Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx> > > --- > > arch/s390/kernel/perf_cpum_cf.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c > > index ee8707abdb6a..4d217f7f5ccf 100644 > > --- a/arch/s390/kernel/perf_cpum_cf.c > > +++ b/arch/s390/kernel/perf_cpum_cf.c > > @@ -975,7 +975,7 @@ static int cfset_all_start(struct cfset_request *req) > > return -ENOMEM; > > cpumask_and(mask, &req->mask, cpu_online_mask); > > on_each_cpu_mask(mask, cfset_ioctl_on, &p, 1); > > - if (atomic_read(&p.cpus_ack) != cpumask_weight(mask)) { > > + if (!cpumask_weight_eq(mask, atomic_read(&p.cpus_ack))) { > > on_each_cpu_mask(mask, cfset_ioctl_off, &p, 1); > > rc = -EIO; > > debug_sprintf_event(cf_dbg, 4, "%s CPUs missing", __func__); > > given that you're adding a bunch of these functions - gt,lt,eq and > others, i wonder whether it makes sense to also add cpumask_weight_ne(), > so one could just write: > > if (cpumask_weight_ne(mask, atomic_read(&p.cpus_ack))) { > ... > } > > ? It will have 3 users in cpumask + 1 in nodemask. I have no strong opinion whether we need it or not. Let's see what people say. Thanks, Yury