lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220125190531.GA31998@alpha.franken.de>
Date:   Tue, 25 Jan 2022 20:05:31 +0100
From:   Thomas Bogendoerfer <tsbogend@...ha.franken.de>
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, Mark Rutland <mark.rutland@....com>,
        Marc Zyngier <maz@...nel.org>, linux-mips@...r.kernel.org
Subject: Re: [PATCH 38/54] arch/mips: replace cpumask_weight with
 cpumask_weight_{eq, ...} where appropriate

On Sun, Jan 23, 2022 at 10:39:09AM -0800, Yury Norov wrote:
> Mips code uses 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.
> 
> Signed-off-by: Yury Norov <yury.norov@...il.com>
> ---
>  arch/mips/cavium-octeon/octeon-irq.c | 4 ++--
>  arch/mips/kernel/crash.c             | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
> index 844f882096e6..914871f15fb7 100644
> --- a/arch/mips/cavium-octeon/octeon-irq.c
> +++ b/arch/mips/cavium-octeon/octeon-irq.c
> @@ -763,7 +763,7 @@ static void octeon_irq_cpu_offline_ciu(struct irq_data *data)
>  	if (!cpumask_test_cpu(cpu, mask))
>  		return;
>  
> -	if (cpumask_weight(mask) > 1) {
> +	if (cpumask_weight_gt(mask, 1)) {
>  		/*
>  		 * It has multi CPU affinity, just remove this CPU
>  		 * from the affinity set.
> @@ -795,7 +795,7 @@ static int octeon_irq_ciu_set_affinity(struct irq_data *data,
>  	 * This removes the need to do locking in the .ack/.eoi
>  	 * functions.
>  	 */
> -	if (cpumask_weight(dest) != 1)
> +	if (!cpumask_weight_eq(dest, 1))
>  		return -EINVAL;
>  
>  	if (!enable_one)
> diff --git a/arch/mips/kernel/crash.c b/arch/mips/kernel/crash.c
> index 81845ba04835..5b690d52491f 100644
> --- a/arch/mips/kernel/crash.c
> +++ b/arch/mips/kernel/crash.c
> @@ -72,7 +72,7 @@ static void crash_kexec_prepare_cpus(void)
>  	 */
>  	pr_emerg("Sending IPI to other cpus...\n");
>  	msecs = 10000;
> -	while ((cpumask_weight(&cpus_in_crash) < ncpus) && (--msecs > 0)) {
> +	while (cpumask_weight_lt(&cpus_in_crash, ncpus) && (--msecs > 0)) {
>  		cpu_relax();
>  		mdelay(1);
>  	}
> -- 
> 2.30.2

Acked-by: Thomas Bogendoerfer <tsbogend@...ha.franken.de>

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ