Skip to content

Commit

Permalink
[PATCH] __mod_timer: simplify ->base changing
Browse files Browse the repository at this point in the history
Since base and new_base are of the same type now, we can save one 'if'
branch and simplify the code a bit.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Mar 31, 2006
1 parent 3691c51 commit a2c348f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions kernel/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,19 @@ int __mod_timer(struct timer_list *timer, unsigned long expires)
* handler yet has not finished. This also guarantees that
* the timer is serialized wrt itself.
*/
if (unlikely(base->running_timer == timer)) {
/* The timer remains on a former base */
new_base = base;
} else {
if (likely(base->running_timer != timer)) {
/* See the comment in lock_timer_base() */
timer->base = NULL;
spin_unlock(&base->lock);
spin_lock(&new_base->lock);
timer->base = new_base;
base = new_base;
spin_lock(&base->lock);
timer->base = base;
}
}

timer->expires = expires;
internal_add_timer(new_base, timer);
spin_unlock_irqrestore(&new_base->lock, flags);
internal_add_timer(base, timer);
spin_unlock_irqrestore(&base->lock, flags);

return ret;
}
Expand Down

0 comments on commit a2c348f

Please sign in to comment.