[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87v8y9ijdz.fsf@redhat.com>
Date: Mon, 24 Jan 2022 10:16:08 +0100
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Yury Norov <yury.norov@...il.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Andrew Morton <akpm@...ux-foundation.org>,
Michał Mirosław <mirq-linux@...e.qmqm.pl>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Peter Zijlstra <peterz@...radead.org>,
David Laight <David.Laight@...lab.com>,
Joe Perches <joe@...ches.com>, Dennis Zhou <dennis@...nel.org>,
Emil Renner Berthing <kernel@...il.dk>,
Nicholas Piggin <npiggin@...il.com>,
Matti Vaittinen <matti.vaittinen@...rohmeurope.com>,
Alexey Klimov <aklimov@...hat.com>,
linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Alison Schofield <alison.schofield@...el.com>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>
Subject: Re: [PATCH 41/54] arch/x86: replace cpumask_weight with
cpumask_weight_eq where appropriate
Yury Norov <yury.norov@...il.com> writes:
> smpboot code in somw places 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 met.
I think this is misleading. cpumask_weight_eq() with any implementation
can only stop earlier if the condition is NOT met (when the number of
set bits is already higher than needed), to check for equality all bits
always need to be examined.
>
> Signed-off-by: Yury Norov <yury.norov@...il.com>
> ---
> arch/x86/kernel/smpboot.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 617012f4619f..e851e9945eb5 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -1608,7 +1608,7 @@ static void remove_siblinginfo(int cpu)
> /*/
> * last thread sibling in this cpu core going down
> */
> - if (cpumask_weight(topology_sibling_cpumask(cpu)) == 1)
> + if (cpumask_weight_eq(topology_sibling_cpumask(cpu), 1))
> cpu_data(sibling).booted_cores--;
> }
>
> @@ -1617,7 +1617,7 @@ static void remove_siblinginfo(int cpu)
>
> for_each_cpu(sibling, topology_sibling_cpumask(cpu)) {
> cpumask_clear_cpu(cpu, topology_sibling_cpumask(sibling));
> - if (cpumask_weight(topology_sibling_cpumask(sibling)) == 1)
> + if (cpumask_weight_eq(topology_sibling_cpumask(sibling), 1))
> cpu_data(sibling).smt_active = false;
> }
--
Vitaly
Powered by blists - more mailing lists