[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2d6bf83a-85ad-404a-b34f-c8777e373aaa@arm.com>
Date: Thu, 24 Apr 2025 18:07:37 +0100
From: James Morse <james.morse@....com>
To: Yury Norov <yury.norov@...il.com>, Tony Luck <tony.luck@...el.com>,
Reinette Chatre <reinette.chatre@...el.com>,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>, Rasmus Villemoes
<linux@...musvillemoes.dk>, x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] cpumask: add cpumask_{first,next}_andnot() API
Hi Yury,
On 07/04/2025 16:38, Yury Norov wrote:
> From: Yury Norov [NVIDIA] <yury.norov@...il.com>
>
> With the lack of the functions, client code has to abuse less efficient
> cpumask_nth().
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> index 0f816092c891..9067c3411cd0 100644
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -458,6 +490,33 @@ unsigned int cpumask_any_and_but(const struct cpumask *mask1,
> return cpumask_next_and(cpu, mask1, mask2);
> }
>
> +/**
> + * cpumask_andnot_any_but - pick an arbitrary cpu from *mask1 & ~*mask2, but not this one.
> + * @mask1: the first input cpumask
> + * @mask2: the second input cpumask
> + * @cpu: the cpu to ignore
> + *
> + * If @cpu == -1, the function returns the first matching cpu.
> + * Returns >= nr_cpu_ids if no cpus set.
> + */
> +static __always_inline
> +unsigned int cpumask_andnot_any_but(const struct cpumask *mask1,
> + const struct cpumask *mask2,
> + unsigned int cpu)
Nit: Shouldn't this be named cpumask_any_andnot_but()?
It's any cpu from the first-mask, then 'andnot' the second. This fits with the other
instances of this, e.g. cpumask_any_and_but().
> +{
> + unsigned int i;
> +
> + /* -1 is a legal arg here. */
> + if (cpu != -1)
> + cpumask_check(cpu);
> +
> + i = cpumask_first_andnot(mask1, mask2);
> + if (i != cpu)
> + return i;
> +
> + return cpumask_next_andnot(cpu, mask1, mask2);
> +}
Thanks,
James
Powered by blists - more mailing lists