lkml.org 
[lkml]   [2022]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@gmail.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@alpha.franken.de>

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

\
 
 \ /
  Last update: 2022-01-25 23:51    [W:0.737 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site