Skip to content

Commit d14e99b

Browse files
jones-drewpalmer-dabbelt
authored andcommitted
RISC-V: Fix /proc/cpuinfo cpumask warning
Commit 78e5a33 ("cpumask: fix checking valid cpu range") has started issuing warnings[*] when cpu indices equal to nr_cpu_ids - 1 are passed to cpumask_next* functions. seq_read_iter() and cpuinfo's start and next seq operations implement a pattern like n = cpumask_next(n - 1, mask); show(n); while (1) { ++n; n = cpumask_next(n - 1, mask); if (n >= nr_cpu_ids) break; show(n); } which will issue the warning when reading /proc/cpuinfo. Ensure no warning is generated by validating the cpu index before calling cpumask_next(). [*] Warnings will only appear with DEBUG_PER_CPU_MAPS enabled. Signed-off-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Tested-by: Conor Dooley <[email protected]> Acked-by: Yury Norov <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ Fixes: 78e5a33 ("cpumask: fix checking valid cpu range") Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 952b64d commit d14e99b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/riscv/kernel/cpu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ static void print_mmu(struct seq_file *f)
213213

214214
static void *c_start(struct seq_file *m, loff_t *pos)
215215
{
216+
if (*pos == nr_cpu_ids)
217+
return NULL;
218+
216219
*pos = cpumask_next(*pos - 1, cpu_online_mask);
217220
if ((*pos) < nr_cpu_ids)
218221
return (void *)(uintptr_t)(1 + *pos);

0 commit comments

Comments
 (0)