Skip to contentSkip to conversation

[2.5] is_smp() and can_be_smp()

PATCH New Luca Barbieri 1 participant 1 message Aug 17, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 [2.5] is_smp() and can_be_smp()

Will be used by another patch that I'll post in the near future. For i386 cpucount is used rather than computing the hweight of cpu_online_map since it's faster and already there. Ideally the same should be done for all architectures in both these macros and num_online_cpus and num_possible_cpus.

include/asm-i386/smp.h +4 -0
diff --exclude-from=/home/ldb/src/linux-exclude -urNdp a/include/asm-i386/smp.h b/include/asm-i386/smp.h
@@ -95,6 +95,10 @@ extern inline unsigned int num_online_cp
 	return hweight32(cpu_online_map);
 }
 
+extern int cpucount;
+#define is_smp() (cpucount)
+#define can_be_smp() (cpucount)
+
 extern inline int any_online_cpu(unsigned int mask)
 {
 	if (mask & cpu_online_map)
include/linux/smp.h +15 -0
diff --exclude-from=/home/ldb/src/linux-exclude -urNdp a/include/linux/smp.h b/include/linux/smp.h
@@ -78,6 +78,19 @@ extern int register_cpu_notifier(struct 
 extern void unregister_cpu_notifier(struct notifier_block *nb);
 
 int cpu_up(unsigned int cpu);
+
+#ifndef is_smp
+#define is_smp() (num_online_cpus() > 1)
+#endif
+
+#ifndef can_be_smp
+#ifdef num_possible_cpus
+#define can_be_smp() (num_possible_cpus() > 1)
+#else
+#define can_be_smp() is_smp()
+#endif
+#endif
+
 #else /* !SMP */
 
 /*
@@ -96,6 +109,8 @@ static inline void smp_send_reschedule_a
 #define cpu_online_map				1
 #define cpu_online(cpu)				({ cpu; 1; })
 #define num_online_cpus()			1
+#define is_smp()				0
+#define can_be_smp()				0
 #define __per_cpu_data
 #define per_cpu(var, cpu)			var
 #define this_cpu(var)				var