diff options
| author | Andrew Morton <akpm@digeo.com> | 2003-03-22 07:34:50 -0800 |
|---|---|---|
| committer | David S. Miller <davem@kernel.bkbits.net> | 2003-03-22 07:34:50 -0800 |
| commit | ff0cbc7881e74bd5a7f6ee864d6474a3fd0213bb (patch) | |
| tree | 0ca2c877b8b2a20a0f0dc5af866f2e7768883d0f | |
| parent | c6e7381d7827b5186d516127af520e3006607be8 (diff) | |
[PATCH] simplify the timer lockup avoidance code
From: george anzinger <george@mvista.com>
The recently-added code which avoids a lockup when a timer handler re-adds
the timer right now can be simplified.
If we change __run_timers() to increment base->timer_jiffies _before_ running
the timers, then any re-additions will not be inserted in the list which
__run_timers is presently walking.
| -rw-r--r-- | kernel/timer.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/kernel/timer.c b/kernel/timer.c index 7b277a899e04..5bee9f921b67 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -55,7 +55,6 @@ struct tvec_t_base_s { spinlock_t lock; unsigned long timer_jiffies; struct timer_list *running_timer; - struct list_head *run_timer_list_running; tvec_root_t tv1; tvec_t tv2; tvec_t tv3; @@ -100,12 +99,6 @@ static inline void check_timer(struct timer_list *timer) check_timer_failed(timer); } -/* - * If a timer handler re-adds the timer with expires == jiffies, the timer - * running code can lock up. So here we detect that situation and park the - * timer onto base->run_timer_list_running. It will be added to the main timer - * structures later, by __run_timers(). - */ static void internal_add_timer(tvec_base_t *base, struct timer_list *timer) { @@ -113,9 +106,7 @@ static void internal_add_timer(tvec_base_t *base, struct timer_list *timer) unsigned long idx = expires - base->timer_jiffies; struct list_head *vec; - if (base->run_timer_list_running) { - vec = base->run_timer_list_running; - } else if (idx < TVR_SIZE) { + if (idx < TVR_SIZE) { int i = expires & TVR_MASK; vec = base->tv1.vec + i; } else if (idx < 1 << (TVR_BITS + TVN_BITS)) { @@ -405,7 +396,6 @@ static inline void __run_timers(tvec_base_t *base) spin_lock_irq(&base->lock); while (time_after_eq(jiffies, base->timer_jiffies)) { - LIST_HEAD(deferred_timers); struct list_head *head; int index = base->timer_jiffies & TVR_MASK; @@ -417,7 +407,7 @@ static inline void __run_timers(tvec_base_t *base) (!cascade(base, &base->tv3, INDEX(1))) && !cascade(base, &base->tv4, INDEX(2))) cascade(base, &base->tv5, INDEX(3)); - base->run_timer_list_running = &deferred_timers; + ++base->timer_jiffies; repeat: head = base->tv1.vec + index; if (!list_empty(head)) { @@ -436,14 +426,6 @@ repeat: spin_lock_irq(&base->lock); goto repeat; } - base->run_timer_list_running = NULL; - ++base->timer_jiffies; - while (!list_empty(&deferred_timers)) { - timer = list_entry(deferred_timers.prev, - struct timer_list, entry); - list_del(&timer->entry); - internal_add_timer(base, timer); - } } set_running_timer(base, NULL); spin_unlock_irq(&base->lock); |
