Skip to contentSkip to conversation

cpumask: prepare for iterators to only go to nr_cpu_ids/nr_cpumask_bits.: core

PATCH In review Rusty Russell 2 participants 2 messages Dec 1, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cpumask: prepare for iterators to only go to nr_cpu_ids/nr_cpumask_bits.: core

Impact: cleanup

In future, all cpumask ops will only be valid (in general) for bit numbers < nr_cpu_ids. So use that instead of NR_CPUS in iterators and other comparisons.

This is always safe: no cpu number can be >= nr_cpu_ids, and nr_cpu_ids is initialized to NR_CPUS at boot.

---
 kernel/kexec.c               |    2 +-
 kernel/smp.c                 |    2 +-
 security/selinux/selinuxfs.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
kernel/kexec.c +1 -1
diff -r bb80787e9617 kernel/kexec.c
@@ -1116,7 +1116,7 @@ void crash_save_cpu(struct pt_regs *regs
 	struct elf_prstatus prstatus;
 	u32 *buf;
 
-	if ((cpu < 0) || (cpu >= NR_CPUS))
+	if ((cpu < 0) || (cpu >= nr_cpu_ids))
 		return;
 
 	/* Using ELF notes here is opportunistic.
kernel/smp.c +1 -1
diff -r bb80787e9617 kernel/smp.c
@@ -222,7 +222,7 @@ int smp_call_function_single(int cpu, vo
 		local_irq_save(flags);
 		func(info);
 		local_irq_restore(flags);
-	} else if ((unsigned)cpu < NR_CPUS && cpu_online(cpu)) {
+	} else if ((unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) {
 		struct call_single_data *data = NULL;
 
 		if (!wait) {
security/selinux/selinuxfs.c +1 -1
diff -r bb80787e9617 security/selinux/selinuxfs.c
@@ -1206,7 +1206,7 @@ static struct avc_cache_stats *sel_avc_g
 {
 	int cpu;
 
-	for (cpu = *idx; cpu < NR_CPUS; ++cpu) {
+	for (cpu = *idx; cpu < nr_cpu_ids; ++cpu) {
 		if (!cpu_possible(cpu))
 			continue;
 		*idx = cpu + 1;
Acked-by on v1 1/2
#1 lore raw
Quoted 7 lines · Rusty Russell

Impact: cleanup

In future, all cpumask ops will only be valid (in general) for bit numbers < nr_cpu_ids. So use that instead of NR_CPUS in iterators and other comparisons.

Quoted 8 lines

This is always safe: no cpu number can be >= nr_cpu_ids, and nr_cpu_ids is initialized to NR_CPUS at boot.

Signature · 2 lines
James Morris
<[email protected]>