Commit 189572bf authored by Yury Norov [NVIDIA]'s avatar Yury Norov [NVIDIA] Committed by Borislav Petkov (AMD)
Browse files

cpumask: Relax cpumask_any_but()



Similarly to other cpumask search functions, accept -1, and consider it as
'any CPU' hint. This helps users to avoid coding special cases.

Signed-off-by: default avatarYury Norov [NVIDIA] <yury.norov@gmail.com>
Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarJames Morse <james.morse@arm.com>
Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Reviewed-by: default avatarFenghua Yu <fenghuay@nvidia.com>
Tested-by: default avatarJames Morse <james.morse@arm.com>
Tested-by: default avatarTony Luck <tony.luck@intel.com>
Tested-by: default avatarFenghua Yu <fenghuay@nvidia.com>
Link: https://lore.kernel.org/20250515165855.31452-2-james.morse@arm.com
parent 82f2b0b9
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -413,14 +413,18 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *src)
 * @cpu: the cpu to ignore.
 *
 * Often used to find any cpu but smp_processor_id() in a mask.
 * If @cpu == -1, the function is equivalent to cpumask_any().
 * Return: >= nr_cpu_ids if no cpus set.
 */
static __always_inline
unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
unsigned int cpumask_any_but(const struct cpumask *mask, int cpu)
{
	unsigned int i;

	/* -1 is a legal arg here. */
	if (cpu != -1)
		cpumask_check(cpu);

	for_each_cpu(i, mask)
		if (i != cpu)
			break;
@@ -433,16 +437,20 @@ unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
 * @mask2: the second input cpumask
 * @cpu: the cpu to ignore
 *
 * If @cpu == -1, the function is equivalent to cpumask_any_and().
 * Returns >= nr_cpu_ids if no cpus set.
 */
static __always_inline
unsigned int cpumask_any_and_but(const struct cpumask *mask1,
				 const struct cpumask *mask2,
				 unsigned int cpu)
				 int cpu)
{
	unsigned int i;

	/* -1 is a legal arg here. */
	if (cpu != -1)
		cpumask_check(cpu);

	i = cpumask_first_and(mask1, mask2);
	if (i != cpu)
		return i;