Skip to content

Commit a2c348f

Browse files
Oleg NesterovLinus Torvalds
authored andcommitted
[PATCH] __mod_timer: simplify ->base changing
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>
1 parent 3691c51 commit a2c348f

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎kernel/timer.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,19 @@ int __mod_timer(struct timer_list *timer, unsigned long expires)
215215
* handler yet has not finished. This also guarantees that
216216
* the timer is serialized wrt itself.
217217
*/
218-
if (unlikely(base->running_timer == timer)) {
219-
/* The timer remains on a former base */
220-
new_base = base;
221-
} else {
218+
if (likely(base->running_timer != timer)) {
222219
/* See the comment in lock_timer_base() */
223220
timer->base = NULL;
224221
spin_unlock(&base->lock);
225-
spin_lock(&new_base->lock);
226-
timer->base = new_base;
222+
base = new_base;
223+
spin_lock(&base->lock);
224+
timer->base = base;
227225
}
228226
}
229227

230228
timer->expires = expires;
231-
internal_add_timer(new_base, timer);
232-
spin_unlock_irqrestore(&new_base->lock, flags);
229+
internal_add_timer(base, timer);
230+
spin_unlock_irqrestore(&base->lock, flags);
233231

234232
return ret;
235233
}

0 commit comments

Comments
 (0)