lkml.org 
[lkml]   [2022]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 39/49] arch/s390: replace cpumask_weight with cpumask_weight_eq where appropriate
Date
Hi Yury,

Yury Norov <yury.norov@gmail.com> 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@gmail.com>
> ---
> 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))) {
...
}

?

/Sven

\
 
 \ /
  Last update: 2022-02-11 07:55    [W:0.299 / U:0.628 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site