From nobody Wed Dec 17 03:44:51 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5CF91D79A6 for ; Thu, 15 May 2025 16:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747328357; cv=none; b=s8SxUoJK9o5Za7Igx5EPwZnDfAJnkvjCWj5YsRL5bmfhfYESnkhVsbqfmXEDjgdb8fR1/0ET1QsxlfNyWXCODngCXrunY+V+C54I8PuH4QDJYQtZLDtFvWuiXrpZvGnzZHAW6nP549aqRwTZbZdel8LeOm18KQtjB+ghTupCmQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747328357; c=relaxed/simple; bh=vtEX+tby2YJ2pOPcdR51Y1KkK1mbVViW56g/GcRwsqM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jfnjd2X8qVwMRupPd/gXgl8CA3gN6vRpthDmSCqXVRCrxYI2KTAaF0qx+f4/1CJ0G/00GNXmJA6UXVsQtXeRvRipzvUewGFweSe/Rw+MOYjoKGRS8srcEvsaNZTaY06rBwRDponvHHFUUiRPHwl1/u5ut3e/QzgGTV5z38n/tgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87D4B1595; Thu, 15 May 2025 09:59:03 -0700 (PDT) Received: from merodach.members.linode.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E318E3F63F; Thu, 15 May 2025 09:59:11 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Rex Nie , Dave Martin , Koba Ko , Shanker Donthineni , fenghuay@nvidia.com, "Yury Norov [NVIDIA]" , Tony Luck Subject: [PATCH v12 01/25] cpumask: relax cpumask_any_but() Date: Thu, 15 May 2025 16:58:31 +0000 Message-Id: <20250515165855.31452-2-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250515165855.31452-1-james.morse@arm.com> References: <20250515165855.31452-1-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Yury Norov [NVIDIA]" Similarly to other cpumask search functions, accept -1, and consider it as 'any cpu' hint. This helps users to avoid coding special cases. Tested-by: James Morse Tested-by: Tony Luck Reviewed-by: James Morse Reviewed-by: Reinette Chatre Reviewed-by: Fenghua Yu Signed-off-by: Yury Norov [NVIDIA] Signed-off-by: James Morse --- include/linux/cpumask.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index f9a868384083..a3ee875df508 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -413,14 +413,18 @@ unsigned int cpumask_next_wrap(int n, const struct cp= umask *src) * @cpu: the cpu to ignore. * * Often used to find any cpu but smp_processor_id() in a mask. + * If @cpu =3D=3D -1, the function is equivalent to cpumask_any(). * Return: >=3D 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; =20 - cpumask_check(cpu); + /* -1 is a legal arg here. */ + if (cpu !=3D -1) + cpumask_check(cpu); + for_each_cpu(i, mask) if (i !=3D cpu) break; @@ -433,16 +437,20 @@ unsigned int cpumask_any_but(const struct cpumask *ma= sk, unsigned int cpu) * @mask2: the second input cpumask * @cpu: the cpu to ignore * + * If @cpu =3D=3D -1, the function is equivalent to cpumask_any_and(). * Returns >=3D 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; =20 - cpumask_check(cpu); + /* -1 is a legal arg here. */ + if (cpu !=3D -1) + cpumask_check(cpu); + i =3D cpumask_first_and(mask1, mask2); if (i !=3D cpu) return i; --=20 2.39.5