cpumask: Use &cpu_mask_all instead of CPU_MASK_ALL_PTR.

Make cpu_mask_all always exist (and put it in kernel/cpu.c), and use
it in place of CPU_MASK_ALL_PTR.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 include/linux/cpumask.h |    9 +++------
 init/main.c             |    7 +------
 kernel/cpu.c            |    9 +++++++++
 kernel/kmod.c           |    2 +-
 kernel/kthread.c        |    4 ++--
 kernel/sched.c          |    2 +-
 6 files changed, 17 insertions(+), 16 deletions(-)

diff -r a2187f30be6b include/linux/cpumask.h
--- a/include/linux/cpumask.h	Sun Sep 28 22:56:20 2008 +1000
+++ b/include/linux/cpumask.h	Sun Sep 28 23:06:46 2008 +1000
@@ -138,6 +138,7 @@ typedef struct cpumask cpumask_t;
 typedef struct cpumask cpumask_t;
 extern cpumask_t _unused_cpumask_arg_;
 
+#define CPU_MASK_ALL_PTR	(&cpu_mask_all)
 #define cpu_set(cpu, dst) cpumask_set_cpu((cpu), &(dst))
 #define cpu_clear(cpu, dst) cpumask_clear_cpu((cpu), &(dst))
 #define cpu_test_and_set(cpu, mask) cpumask_test_and_set_cpu((cpu), &(mask))
@@ -384,8 +385,6 @@ static inline const cpumask_t *get_cpu_m
 	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD			\
 } }
 
-#define CPU_MASK_ALL_PTR	(&CPU_MASK_ALL)
-
 #else
 
 #define CPU_MASK_ALL							\
@@ -394,11 +393,9 @@ static inline const cpumask_t *get_cpu_m
 	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD			\
 } }
 
-/* cpu_mask_all is in init/main.c */
-extern cpumask_t cpu_mask_all;
-#define CPU_MASK_ALL_PTR	(&cpu_mask_all)
+#endif
 
-#endif
+extern const struct cpumask cpu_mask_all;
 
 #define CPU_MASK_NONE							\
 (cpumask_t) { {								\
diff -r a2187f30be6b init/main.c
--- a/init/main.c	Sun Sep 28 22:56:20 2008 +1000
+++ b/init/main.c	Sun Sep 28 23:06:46 2008 +1000
@@ -363,11 +363,6 @@ static inline void smp_prepare_cpus(unsi
 static inline void smp_prepare_cpus(unsigned int maxcpus) { }
 
 #else
-
-#if NR_CPUS > BITS_PER_LONG
-cpumask_t cpu_mask_all __read_mostly = CPU_MASK_ALL;
-EXPORT_SYMBOL(cpu_mask_all);
-#endif
 
 /* Setup number of possible processor ids */
 /* nr_cpu_ids is a real variable for large NR_CPUS. */
@@ -847,7 +842,7 @@ static int __init kernel_init(void * unu
 	/*
 	 * init can run on any cpu.
 	 */
-	set_cpus_allowed_ptr(current, CPU_MASK_ALL_PTR);
+	set_cpus_allowed_ptr(current, &cpu_mask_all);
 	/*
 	 * Tell the world that we're going to be the grim
 	 * reaper of innocent orphaned children.
diff -r a2187f30be6b kernel/cpu.c
--- a/kernel/cpu.c	Sun Sep 28 22:56:20 2008 +1000
+++ b/kernel/cpu.c	Sun Sep 28 23:06:46 2008 +1000
@@ -479,3 +479,12 @@ const unsigned long cpu_bit_bitmap[BITS_
 #endif
 };
 EXPORT_SYMBOL_GPL(cpu_bit_bitmap);
+
+const struct cpumask cpu_mask_all = { {
+#if NR_CPUS > BITS_PER_LONG
+		[0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL,
+#endif
+		[BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS),
+	} };
+EXPORT_SYMBOL(cpu_mask_all);
+
diff -r a2187f30be6b kernel/kmod.c
--- a/kernel/kmod.c	Sun Sep 28 22:56:20 2008 +1000
+++ b/kernel/kmod.c	Sun Sep 28 23:06:46 2008 +1000
@@ -166,7 +166,7 @@ static int ____call_usermodehelper(void 
 	}
 
 	/* We can run anywhere, unlike our parent keventd(). */
-	set_cpus_allowed_ptr(current, CPU_MASK_ALL_PTR);
+	set_cpus_allowed_ptr(current, &cpu_mask_all);
 
 	/*
 	 * Our parent is keventd, which runs with elevated scheduling priority.
diff -r a2187f30be6b kernel/kthread.c
--- a/kernel/kthread.c	Sun Sep 28 22:56:20 2008 +1000
+++ b/kernel/kthread.c	Sun Sep 28 23:06:46 2008 +1000
@@ -106,7 +106,7 @@ static void create_kthread(struct kthrea
 		 */
 		sched_setscheduler(create->result, SCHED_NORMAL, &param);
 		set_user_nice(create->result, KTHREAD_NICE_LEVEL);
-		set_cpus_allowed_ptr(create->result, CPU_MASK_ALL_PTR);
+		set_cpus_allowed_ptr(create->result, &cpu_mask_all);
 	}
 	complete(&create->done);
 }
@@ -233,7 +233,7 @@ int kthreadd(void *unused)
 	set_task_comm(tsk, "kthreadd");
 	ignore_signals(tsk);
 	set_user_nice(tsk, KTHREAD_NICE_LEVEL);
-	set_cpus_allowed_ptr(tsk, CPU_MASK_ALL_PTR);
+	set_cpus_allowed_ptr(tsk, &cpu_mask_all);
 
 	current->flags |= PF_NOFREEZE | PF_FREEZER_NOSIG;
 
diff -r a2187f30be6b kernel/sched.c
--- a/kernel/sched.c	Sun Sep 28 22:56:20 2008 +1000
+++ b/kernel/sched.c	Sun Sep 28 23:06:46 2008 +1000
@@ -6100,7 +6100,7 @@ static void move_task_off_dead_cpu(int d
  */
 static void migrate_nr_uninterruptible(struct rq *rq_src)
 {
-	struct rq *rq_dest = cpu_rq(any_online_cpu(*CPU_MASK_ALL_PTR));
+	struct rq *rq_dest = cpu_rq(any_online_cpu(cpu_mask_all));
 	unsigned long flags;
 
 	local_irq_save(flags);
