Re: [RFC] [PATCH 1/1]: timers: Change add_timer to use add_timer_on

Oleg Nesterov
2008-09-22T14:37:23Z

(add Thomas)

On 09/22, Krishna Kumar wrote:
>
> timer: Change add_timer to not check for existing timer.

Perhaps the changelog should explain why ;)

But, besides the removing BUG_ON(), the patch does something else.

> static inline void add_timer(struct timer_list *timer)
> {
> - BUG_ON(timer_pending(timer));
> - __mod_timer(timer, timer->expires);
> + add_timer_on(timer, raw_smp_processor_id());
> }

This is racy wrt CPU hotplug. The CPU can be cpu_down()'ed right
after raw_smp_processor_id() returns, and before we actually add
the timer.

Another problem is that now it is add_timer() becomes unsafe wrt
concurrent del_timer/del_timer_sync, because add_timer_on() does
not lock the timer, it only locks the target base.

Oleg.