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

From: Oleg Nesterov
Date: Mon Sep 22 2008 - 10:37:25 EST


(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.

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