Skip to contentSkip to conversation

s390/cpuinfo: prevent warning when reading /proc/cpuinfo

PATCH In review Alexander Gordeev 3 participants 3 messages Oct 14, 2022 s390

lore
Share & tools
lore

Alexander Gordeev

author maintainer
#0 lore raw

PATCH 1/1 s390/cpuinfo: prevent warning when reading /proc/cpuinfo

Commit 78e5a3399421 ("cpumask: fix checking valid cpu range") has started issuing warnings when reading /proc/cpuinfo and config DEBUG_PER_CPU_MAPS is enabled. Avoid calling cpumask_next() with the cpu index equal to nr_cpu_ids - 1 and ensure no warning is generated.

---
 arch/s390/kernel/processor.c | 2 ++
 1 file changed, 2 insertions(+)
arch/s390/kernel/processor.c +2 -0
index a194611ba88c..908a0be900ea 100644
@@ -334,6 +334,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 static inline void *c_update(loff_t *pos)
 {
+	if (*pos >= nr_cpu_ids)
+		return NULL;
 	if (*pos)
 		*pos = cpumask_next(*pos - 1, cpu_online_mask);
 	else
Signature · 1 line
2.34.1
#1 lore raw
Quoted 19 lines · Alexander Gordeev

Commit 78e5a3399421 ("cpumask: fix checking valid cpu range") has started issuing warnings when reading /proc/cpuinfo and config DEBUG_PER_CPU_MAPS is enabled. Avoid calling cpumask_next() with the cpu index equal to nr_cpu_ids - 1 and ensure no warning is generated.

---
 arch/s390/kernel/processor.c | 2 ++
 1 file changed, 2 insertions(+)
arch/s390/kernel/processor.c +0 -0
index a194611ba88c..908a0be900ea 100644

arch/s390/kernel/processor.c static int show_cpuinfo(struct seq_file *m, void *v) · line 341

Quoted 8 lines
arch/s390/kernel/processor.c +2 -0
@@ -334,6 +334,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 static inline void *c_update(loff_t *pos)
 {
+       if (*pos >= nr_cpu_ids)
+               return NULL;
        if (*pos)
                *pos = cpumask_next(*pos - 1, cpu_online_mask);
        else

This silences the warning entirely. If you don't need it, I'd suggest using find_next_bit()
instead. But from the discussion to similar patch, I think you need to allow nr_cpu_ids
only:
+ if (*pos == nr_cpu_ids)
+ return NULL;

#2 lore raw
Quoted 22 lines · Yury Norov
Quoted 20 lines · Alexander Gordeev

Commit 78e5a3399421 ("cpumask: fix checking valid cpu range") has started issuing warnings when reading /proc/cpuinfo and config DEBUG_PER_CPU_MAPS is enabled. Avoid calling cpumask_next() with the cpu index equal to nr_cpu_ids - 1 and ensure no warning is generated.

---
 arch/s390/kernel/processor.c | 2 ++
 1 file changed, 2 insertions(+)
arch/s390/kernel/processor.c +0 -0
index a194611ba88c..908a0be900ea 100644
@@ -334,6 +334,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
Quoted 15 lines

arch/s390/kernel/processor.c static int show_cpuinfo(struct seq_file *m, void *v) · line 341

Quoted 7 lines
arch/s390/kernel/processor.c +2 -0
 static inline void *c_update(loff_t *pos)
 {
+       if (*pos >= nr_cpu_ids)
+               return NULL;
        if (*pos)
                *pos = cpumask_next(*pos - 1, cpu_online_mask);
        else

This silences the warning entirely. If you don't need it, I'd suggest using find_next_bit()
instead. But from the discussion to similar patch, I think you need to allow nr_cpu_ids
only:
+ if (*pos == nr_cpu_ids)
+ return NULL;

Yes, and I'll post my v3's with this change for x86 and riscv now.

Thanks,
drew