aboutsummaryrefslogtreecommitdiff
path: root/kernel/cpu.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 15:13:42 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 15:13:42 -0700
commit63add2f2072e69c1eb7a5f6ca8f415122da889b9 (patch)
tree6948de01b65858ae484474d3cbf2c9d7f61b28ca /kernel/cpu.c
parent3684a601e4273692b6c80b86e55c728aef675660 (diff)
parent9e3ee1c39c0cc71222f9980ccbf87fe072897eef (diff)
Merge branch 'cpus4096-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'cpus4096-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: cpu masks: optimize and clean up cpumask_of_cpu() cpumask: export cpumask_of_cpu_map cpumask: change cpumask_of_cpu_ptr to use new cpumask_of_cpu cpumask: put cpumask_of_cpu_map in the initdata section cpumask: make cpumask_of_cpu_map generic
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r--kernel/cpu.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 29510d68338..e202a68d1cc 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -455,3 +455,28 @@ out:
#endif /* CONFIG_PM_SLEEP_SMP */
#endif /* CONFIG_SMP */
+
+/*
+ * cpu_bit_bitmap[] is a special, "compressed" data structure that
+ * represents all NR_CPUS bits binary values of 1<<nr.
+ *
+ * It is used by cpumask_of_cpu() to get a constant address to a CPU
+ * mask value that has a single bit set only.
+ */
+
+/* cpu_bit_bitmap[0] is empty - so we can back into it */
+#define MASK_DECLARE_1(x) [x+1][0] = 1UL << (x)
+#define MASK_DECLARE_2(x) MASK_DECLARE_1(x), MASK_DECLARE_1(x+1)
+#define MASK_DECLARE_4(x) MASK_DECLARE_2(x), MASK_DECLARE_2(x+2)
+#define MASK_DECLARE_8(x) MASK_DECLARE_4(x), MASK_DECLARE_4(x+4)
+
+const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = {
+
+ MASK_DECLARE_8(0), MASK_DECLARE_8(8),
+ MASK_DECLARE_8(16), MASK_DECLARE_8(24),
+#if BITS_PER_LONG > 32
+ MASK_DECLARE_8(32), MASK_DECLARE_8(40),
+ MASK_DECLARE_8(48), MASK_DECLARE_8(56),
+#endif
+};
+EXPORT_SYMBOL_GPL(cpu_bit_bitmap);