Skip to contentSkip to conversation

__mod_timer: simplify ->base changing

PATCH In review Oleg Nesterov 2 participants 2 messages Mar 25, 2006 – Mar 26, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 __mod_timer: simplify ->base changing

On top of
kill-__init_timer_base-in-favor-of-boot_tvec_bases.patch

Since base and new_base are of the same type now, we can save one 'if' branch and simplify the code a bit.

kernel/timer.c renamed from kernel/timer.c~ +6 -8
@@ -215,21 +215,19 @@ int __mod_timer(struct timer_list *timer
 		 * 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;
 }