Commit ba6edfcd authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] timer initialisation fix

We need the boot CPU's tvec_bases[] entry to be initialised super-early in
boot, for early_serial_setup().  That runs within setup_arch(), before even
per-cpu areas are initialised.

The patch changes tvec_bases to use compile-time initialisation, and adds a
separate array `tvec_base_done' to keep track of which CPU has had its
tvec_bases[] entry initialised (because we can no longer use the zeroness of
that tvec_bases[] entry to determine whether it has been initialised).

Thanks to Eugene Surovegin <ebs@ebshome.net> for diagnosing this.

Cc: Eugene Surovegin <ebs@ebshome.net>
Cc: Jan Beulich <jbeulich@novell.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5246d050
...@@ -81,9 +81,10 @@ struct tvec_t_base_s { ...@@ -81,9 +81,10 @@ struct tvec_t_base_s {
} ____cacheline_aligned_in_smp; } ____cacheline_aligned_in_smp;
typedef struct tvec_t_base_s tvec_base_t; typedef struct tvec_t_base_s tvec_base_t;
static DEFINE_PER_CPU(tvec_base_t *, tvec_bases);
tvec_base_t boot_tvec_bases; tvec_base_t boot_tvec_bases;
EXPORT_SYMBOL(boot_tvec_bases); EXPORT_SYMBOL(boot_tvec_bases);
static DEFINE_PER_CPU(tvec_base_t *, tvec_bases) = { &boot_tvec_bases };
static inline void set_running_timer(tvec_base_t *base, static inline void set_running_timer(tvec_base_t *base,
struct timer_list *timer) struct timer_list *timer)
...@@ -1224,28 +1225,36 @@ static int __devinit init_timers_cpu(int cpu) ...@@ -1224,28 +1225,36 @@ static int __devinit init_timers_cpu(int cpu)
{ {
int j; int j;
tvec_base_t *base; tvec_base_t *base;
static char __devinitdata tvec_base_done[NR_CPUS];
base = per_cpu(tvec_bases, cpu); if (!tvec_base_done[cpu]) {
if (!base) {
static char boot_done; static char boot_done;
/*
* Cannot do allocation in init_timers as that runs before the
* allocator initializes (and would waste memory if there are
* more possible CPUs than will ever be installed/brought up).
*/
if (boot_done) { if (boot_done) {
/*
* The APs use this path later in boot
*/
base = kmalloc_node(sizeof(*base), GFP_KERNEL, base = kmalloc_node(sizeof(*base), GFP_KERNEL,
cpu_to_node(cpu)); cpu_to_node(cpu));
if (!base) if (!base)
return -ENOMEM; return -ENOMEM;
memset(base, 0, sizeof(*base)); memset(base, 0, sizeof(*base));
per_cpu(tvec_bases, cpu) = base;
} else { } else {
base = &boot_tvec_bases; /*
* This is for the boot CPU - we use compile-time
* static initialisation because per-cpu memory isn't
* ready yet and because the memory allocators are not
* initialised either.
*/
boot_done = 1; boot_done = 1;
base = &boot_tvec_bases;
} }
per_cpu(tvec_bases, cpu) = base; tvec_base_done[cpu] = 1;
} else {
base = per_cpu(tvec_bases, cpu);
} }
spin_lock_init(&base->lock); spin_lock_init(&base->lock);
for (j = 0; j < TVN_SIZE; j++) { for (j = 0; j < TVN_SIZE; j++) {
INIT_LIST_HEAD(base->tv5.vec + j); INIT_LIST_HEAD(base->tv5.vec + j);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment