From: Jan Beulich Date: Fri, 23 Aug 2013 13:07:00 +0000 (+0200) Subject: domctl: replace cpumask_weight() uses X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~6463 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=30e9a840b822ea57319abc0d136945a150fb915b;p=xen.git domctl: replace cpumask_weight() uses In one case it could easily be replaced by range checking the result of a subsequent operation, and in general cpumask_next(), not always needing to scan the whole bitmap, is more efficient than the specific uses of cpumask_weight() here. (When running on big systems, operations on CPU masks aren't cheap enough to use them carelessly.) Signed-off-by: Jan Beulich Acked-by: Keir Fraser --- diff --git a/xen/common/domctl.c b/xen/common/domctl.c index c653efb74b..9760d50955 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -230,15 +230,15 @@ static unsigned int default_vcpu0_location(cpumask_t *online) */ cpumask_copy(&cpu_exclude_map, per_cpu(cpu_sibling_mask, 0)); cpu = cpumask_first(&cpu_exclude_map); - if ( cpumask_weight(&cpu_exclude_map) > 1 ) - cpu = cpumask_next(cpu, &cpu_exclude_map); - ASSERT(cpu < nr_cpu_ids); + i = cpumask_next(cpu, &cpu_exclude_map); + if ( i < nr_cpu_ids ) + cpu = i; for_each_cpu(i, online) { if ( cpumask_test_cpu(i, &cpu_exclude_map) ) continue; if ( (i == cpumask_first(per_cpu(cpu_sibling_mask, i))) && - (cpumask_weight(per_cpu(cpu_sibling_mask, i)) > 1) ) + (cpumask_next(i, per_cpu(cpu_sibling_mask, i)) < nr_cpu_ids) ) continue; cpumask_or(&cpu_exclude_map, &cpu_exclude_map, per_cpu(cpu_sibling_mask, i));