[PATCH]Timer list init is done AFTER use

From: george anzinger (george@mvista.com)
Date: Fri Dec 20 2002 - 03:43:11 EST


On SMP systems the timer list init is done by way of a
cpu_notifier call. This has two problems:

1.) Timers are started WAY before the cpu_notifier call
chain is executed. In particular the console blanking timer
is deleted and inserted every time printk() is called. That
this does not fail is only because the kernel has yet to
protect location zero.

2.) This notifier is called when a cpu comes up. I suspect
that initializing the timer list when a hot swap of a cpu is
done is NOT the right thing to do. In any case, if this is
a desired action, the list still needs to be initialized
prior to its use.

The attached patch initializes all the timer lists at
init_timers time and does not put code in the notify list.

--
George Anzinger   george@mvista.com
High-res-timers: 
http://sourceforge.net/projects/high-res-timers/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml

--- linux-2.5.52-bk4-org/kernel/timer.c~ Thu Dec 19 12:13:18 2002 +++ linux/kernel/timer.c Fri Dec 20 00:38:15 2002 @@ -1150,7 +1150,7 @@ return 0; } -static void __devinit init_timers_cpu(int cpu) +static void __init init_timers_cpu(int cpu) { int j; tvec_base_t *base; @@ -1167,29 +1167,12 @@ INIT_LIST_HEAD(base->tv1.vec + j); } -static int __devinit timer_cpu_notify(struct notifier_block *self, - unsigned long action, void *hcpu) -{ - long cpu = (long)hcpu; - switch(action) { - case CPU_UP_PREPARE: - init_timers_cpu(cpu); - break; - default: - break; - } - return NOTIFY_OK; -} - -static struct notifier_block __devinitdata timers_nb = { - .notifier_call = timer_cpu_notify, -}; - void __init init_timers(void) { - timer_cpu_notify(&timers_nb, (unsigned long)CPU_UP_PREPARE, - (void *)(long)smp_processor_id()); - register_cpu_notifier(&timers_nb); + int cpu; + for (cpu = 0; cpu < NR_CPUS; cpu++){ + init_timers_cpu(cpu); + } open_softirq(TIMER_SOFTIRQ, run_timer_softirq, NULL); }

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Dec 23 2002 - 22:00:26 EST