time: add an offline-cpu check in add_timer_on()
PATCH 1/1 time: add an offline-cpu check in add_timer_on()
Hi everyone,
I think we need a check in the function add_timer_on() to avoid adding a
timer into the timer list of an offline cpu.
This patch fixes this problem in add_timer_on().
--- kernel/timer.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/timer.c +1 -0
@@ -451,6 +451,7 @@ void add_timer_on(struct timer_list *timer, int cpu)timer_stats_timer_set_start_info (timer);BUG_ON (timer_pending (timer) || !timer->function);spin_lock_irqsave (&base->lock, flags); +BUG_ON (cpu_is_offline (cpu));timer_set_base (timer, base);internal_add_timer (base, timer);spin_unlock_irqrestore (&base->lock, flags);
Signature · 1 line
1.5.3.7
Quoted 5 lines · Miao Xie
Hi everyone,
I think we need a check in the functionadd_timer_on()to avoid adding a
timer into the timer list of an offline cpu.This patch fixes this problem in
add_timer_on().
No it doesn't -- it will just crash if a caller does that. If it's a real problem then you either need to fix the callers or change add_timer_on() to transparently put it onto another CPU.
I don't think it's a real problem though because CPU offlining does a stop machine and that should take care of most such races.
-Andi
Quoted 6 lines · Andi Kleen
Quoted 4 lines · Miao Xie
Hi everyone,
I think we need a check in the functionadd_timer_on()to avoid adding a
timer into the timer list of an offline cpu.
Quoted 8 lines
Quoted 1 line
This patch fixes this problem in
add_timer_on().No it doesn't -- it will just crash if a caller does that. If it's a real problem then you either need to fix the callers or change
add_timer_on()to transparently put it onto another CPU.I don't think it's a real problem though because CPU offlining does a stop machine and that should take care of most such races.
No. CPU offlining does not prevent code to try inserting a timer on a offlined CPU. If there is a real problem with this we need to fix the calling code. We should not insert it somewhere else magically.
Thanks,
tglx
Quoted 5 lines · Miao Xie
Hi everyone,
I think we need a check in the functionadd_timer_on()to avoid adding a
timer into the timer list of an offline cpu.This patch fixes this problem in
add_timer_on().
No, the patch is not fixing the problem. It crashes the machine.
Where did you run into this problem ?
Thanks,
tglx