* [PATCH] time: add an offline-cpu check in add_timer_on()
@ 2007-12-14 10:31 Miao Xie
2007-12-14 10:56 ` Andi Kleen
2007-12-14 11:03 ` Thomas Gleixner
0 siblings, 2 replies; 4+ messages in thread
From: Miao Xie @ 2007-12-14 10:31 UTC (permalink / raw)
To: tglx; +Cc: linux-kernel
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().
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
kernel/timer.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/kernel/timer.c b/kernel/timer.c
index a05817c..6189561 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -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);
--
1.5.3.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] time: add an offline-cpu check in add_timer_on()
2007-12-14 10:31 [PATCH] time: add an offline-cpu check in add_timer_on() Miao Xie
@ 2007-12-14 10:56 ` Andi Kleen
2007-12-14 11:05 ` Thomas Gleixner
2007-12-14 11:03 ` Thomas Gleixner
1 sibling, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2007-12-14 10:56 UTC (permalink / raw)
To: miaox; +Cc: tglx, linux-kernel
Miao Xie <miaox@cn.fujitsu.com> writes:
> 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().
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] time: add an offline-cpu check in add_timer_on()
2007-12-14 10:31 [PATCH] time: add an offline-cpu check in add_timer_on() Miao Xie
2007-12-14 10:56 ` Andi Kleen
@ 2007-12-14 11:03 ` Thomas Gleixner
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2007-12-14 11:03 UTC (permalink / raw)
To: Miao Xie; +Cc: linux-kernel
On Fri, 14 Dec 2007, Miao Xie wrote:
> 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().
No, the patch is not fixing the problem. It crashes the machine.
Where did you run into this problem ?
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] time: add an offline-cpu check in add_timer_on()
2007-12-14 10:56 ` Andi Kleen
@ 2007-12-14 11:05 ` Thomas Gleixner
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2007-12-14 11:05 UTC (permalink / raw)
To: Andi Kleen; +Cc: miaox, linux-kernel
On Fri, 14 Dec 2007, Andi Kleen wrote:
> Miao Xie <miaox@cn.fujitsu.com> writes:
>
> > 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().
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-12-14 11:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-14 10:31 [PATCH] time: add an offline-cpu check in add_timer_on() Miao Xie
2007-12-14 10:56 ` Andi Kleen
2007-12-14 11:05 ` Thomas Gleixner
2007-12-14 11:03 ` Thomas Gleixner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.