lkml.org 
[lkml]   [2022]   [Oct]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH bitmap-for-next 2/4] lib/cpumask: Fix cpumask_check() warning in cpumask_next_wrap*()
Date
Invoking cpumask_next*() with n==nr_cpu_ids-1 triggers a warning as there
are (obviously) no more valid CPU ids after that. This is however undesired
for the cpumask_next_wrap*() family which needs to wrap around reaching
this condition.

Don't invoke cpumask_next*() when n==nr_cpu_ids, go for the wrapping (if
any) instead.

NOTE: this only fixes the NR_CPUS>1 variants.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
---
lib/cpumask.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/cpumask.c b/lib/cpumask.c
index 6e576485c84f..f8174fa3d752 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -12,11 +12,11 @@
unsigned int next; \
\
again: \
- next = (FETCH_NEXT); \
+ next = n == nr_cpu_ids - 1 ? nr_cpu_ids : (FETCH_NEXT); \
\
if (wrap && n < start && next >= start) { \
- next = nr_cpumask_bits; \
- } else if (next >= nr_cpumask_bits) { \
+ next = nr_cpu_ids; \
+ } else if (next >= nr_cpu_ids) { \
wrap = true; \
n = -1; \
goto again; \
--
2.31.1
\
 
 \ /
  Last update: 2022-10-06 14:22    [W:0.078 / U:1.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site