netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "cpumask: fix checking valid cpu range"
@ 2022-10-15 13:05 guoren
  2022-10-15 16:50 ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: guoren @ 2022-10-15 13:05 UTC (permalink / raw)
  To: andriy.shevchenko, davem, edumazet, kuba, pabeni, linux,
	yury.norov, caraitto, willemb, jonolson, amritha.nambiar
  Cc: linux-kernel, netdev, Guo Ren, Guo Ren

From: Guo Ren <guoren@linux.alibaba.com>

This reverts commit 78e5a3399421ad79fc024e6d78e2deb7809d26af.

------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:110 cpumask_next_wrap+0x5c/0x80

Let's back this out and retry with a larger clean up in -next.

Fixes: 78e5a3399421 ("cpumask: fix checking valid cpu range")
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Guo Ren <guoren@kernel.org>
Cc: Jakub Kicinski <kuba@kernel.org>
---
 include/linux/cpumask.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 2f065ad97541..c2aa0aa26b45 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -174,8 +174,9 @@ static inline unsigned int cpumask_last(const struct cpumask *srcp)
 static inline
 unsigned int cpumask_next(int n, const struct cpumask *srcp)
 {
-	/* n is a prior cpu */
-	cpumask_check(n + 1);
+	/* -1 is a legal arg here. */
+	if (n != -1)
+		cpumask_check(n);
 	return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1);
 }
 
@@ -188,8 +189,9 @@ unsigned int cpumask_next(int n, const struct cpumask *srcp)
  */
 static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
 {
-	/* n is a prior cpu */
-	cpumask_check(n + 1);
+	/* -1 is a legal arg here. */
+	if (n != -1)
+		cpumask_check(n);
 	return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
 }
 
@@ -229,8 +231,9 @@ static inline
 unsigned int cpumask_next_and(int n, const struct cpumask *src1p,
 		     const struct cpumask *src2p)
 {
-	/* n is a prior cpu */
-	cpumask_check(n + 1);
+	/* -1 is a legal arg here. */
+	if (n != -1)
+		cpumask_check(n);
 	return find_next_and_bit(cpumask_bits(src1p), cpumask_bits(src2p),
 		nr_cpumask_bits, n + 1);
 }
@@ -260,8 +263,8 @@ static inline
 unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap)
 {
 	cpumask_check(start);
-	/* n is a prior cpu */
-	cpumask_check(n + 1);
+	if (n != -1)
+		cpumask_check(n);
 
 	/*
 	 * Return the first available CPU when wrapping, or when starting before cpu0,
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-18  1:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-15 13:05 [PATCH] Revert "cpumask: fix checking valid cpu range" guoren
2022-10-15 16:50 ` Guenter Roeck
2022-10-16  2:58   ` Guo Ren
2022-10-16  3:49     ` Guenter Roeck
2022-10-17  2:56       ` Guo Ren
2022-10-17 19:53         ` Jakub Kicinski
2022-10-18  1:56           ` Guo Ren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).