From: "Jan Beulich" Subject: [PATCH 5/5] domctl: replace cpumask_weight() uses Date: Fri, 23 Aug 2013 08:55:24 +0100 Message-ID: <5217318C02000078000EDE98@nat28.tlf.novell.com> References: <5217309002000078000EDE7D@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part44770C7C.0__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VCmDP-0008BE-Qw for xen-devel@lists.xenproject.org; Fri, 23 Aug 2013 07:55:28 +0000 In-Reply-To: <5217309002000078000EDE7D@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part44770C7C.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -230,15 +230,15 @@ static unsigned int default_vcpu0_locati */ cpumask_copy(&cpu_exclude_map, per_cpu(cpu_sibling_mask, 0)); cpu =3D cpumask_first(&cpu_exclude_map); - if ( cpumask_weight(&cpu_exclude_map) > 1 ) - cpu =3D cpumask_next(cpu, &cpu_exclude_map); - ASSERT(cpu < nr_cpu_ids); + i =3D cpumask_next(cpu, &cpu_exclude_map); + if ( i < nr_cpu_ids ) + cpu =3D i; for_each_cpu(i, online) { if ( cpumask_test_cpu(i, &cpu_exclude_map) ) continue; if ( (i =3D=3D 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)); --=__Part44770C7C.0__= Content-Type: text/plain; name="domctl-replace-cpumask_weight.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="domctl-replace-cpumask_weight.patch" domctl: replace cpumask_weight() uses=0A=0AIn one case it could easily be = replaced by range checking the result of=0Aa subsequent operation, and in = general cpumask_next(), not always=0Aneeding to scan the whole bitmap, is = more efficient than the specific=0Auses of cpumask_weight() here. (When = running on big systems, operations=0Aon CPU masks aren't cheap enough to = use them carelessly.)=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/common/domctl.c=0A+++ b/xen/common/domctl.c=0A@@ -230,15 = +230,15 @@ static unsigned int default_vcpu0_locati=0A */=0A = cpumask_copy(&cpu_exclude_map, per_cpu(cpu_sibling_mask, 0));=0A cpu = =3D cpumask_first(&cpu_exclude_map);=0A- if ( cpumask_weight(&cpu_exclud= e_map) > 1 )=0A- cpu =3D cpumask_next(cpu, &cpu_exclude_map);=0A- = ASSERT(cpu < nr_cpu_ids);=0A+ i =3D cpumask_next(cpu, &cpu_exclude_map)= ;=0A+ if ( i < nr_cpu_ids )=0A+ cpu =3D i;=0A for_each_cpu(i,= online)=0A {=0A if ( cpumask_test_cpu(i, &cpu_exclude_map) = )=0A continue;=0A if ( (i =3D=3D cpumask_first(per_cpu(= cpu_sibling_mask, i))) &&=0A- (cpumask_weight(per_cpu(cpu_sibli= ng_mask, i)) > 1) )=0A+ (cpumask_next(i, per_cpu(cpu_sibling_ma= sk, i)) < nr_cpu_ids) )=0A continue;=0A cpumask_or(&cpu= _exclude_map, &cpu_exclude_map,=0A per_cpu(cpu_sibling_m= ask, i));=0A --=__Part44770C7C.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part44770C7C.0__=--