Skip to contentSkip to conversation

timer: avoid unnecessary waking up of nohz CPU

PATCH In review Joonwoo Park 4 participants 4 messages Apr 28, 2015 – May 5, 2015 High-resolution timers, timer wheel, clockevents

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 timer: avoid unnecessary waking up of nohz CPU

At present, internal_add_timer() examines flags with 'base' which doesn't contain flags. Examine with 'timer->base' to avoid unnecessary waking up of nohz CPU when timer base has TIMER_DEFERRABLE.

CC Thomas Gleixner <[email protected]>
CC John Stultz <[email protected]>
---
 kernel/time/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/timer.c +1 -1
index 2ece3aa..e5d5733c 100644
@@ -434,7 +434,7 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
 	 * require special care against races with idle_cpu(), lets deal
 	 * with that later.
 	 */
-	if (!tbase_get_deferrable(base) || tick_nohz_full_cpu(base->cpu))
+	if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(base->cpu))
 		wake_up_nohz_cpu(base->cpu);
 }
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw
Quoted 16 lines · Joonwoo Park

At present, internal_add_timer() examines flags with 'base' which doesn't contain flags. Examine with 'timer->base' to avoid unnecessary waking up of nohz CPU when timer base has TIMER_DEFERRABLE.

CC Thomas Gleixner <[email protected]>
CC John Stultz <[email protected]>
---
 kernel/time/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/timer.c +0 -0
index 2ece3aa..e5d5733c 100644

kernel/time/timer.c static void internal_add_timer(struct tvec_base *base, struct timer_list *timer) · line 440

Quoted 8 lines
kernel/time/timer.c +1 -1
@@ -434,7 +434,7 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
 	 * require special care against races with idle_cpu(), lets deal
 	 * with that later.
 	 */
-	if (!tbase_get_deferrable(base) || tick_nohz_full_cpu(base->cpu))
+	if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(base->cpu))
 		wake_up_nohz_cpu(base->cpu);
 }
 

This looks like a fix for commit 9f6d9baaa8ca (timer: Kick dynticks targets on mod_timer*() calls, 2014-06-22) which changed the code to use base instead of timer->base when it moved this condition from add_timer_on() into internal_add_timer(). Is that right?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
Reviewed-by on v1 1/2
#2 lore raw
In reply to Joonwoo Park
Quoted 16 lines · Joonwoo Park

At present, internal_add_timer() examines flags with 'base' which doesn't contain flags. Examine with 'timer->base' to avoid unnecessary waking up of nohz CPU when timer base has TIMER_DEFERRABLE.

CC Thomas Gleixner <[email protected]>
CC John Stultz <[email protected]>
---
 kernel/time/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/timer.c +0 -0
index 2ece3aa..e5d5733c 100644

kernel/time/timer.c static void internal_add_timer(struct tvec_base *base, struct timer_list *timer) · line 439

Quoted 7 lines
kernel/time/timer.c +1 -1
@@ -434,7 +434,7 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
         * require special care against races with idle_cpu(), lets deal
         * with that later.
         */
-       if (!tbase_get_deferrable(base) || tick_nohz_full_cpu(base->cpu))
+       if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(base->cpu))
                wake_up_nohz_cpu(base->cpu);
 }

Oops !!

Fixes 9f6d9baaa8ca ("timer: Kick dynticks targets on mod_timer*() calls")
Cc 3.17+ <[email protected]> # 3.17+
#3 lore raw

[tip:timers/core] timer: Use timer->base for flag checks

In reply to Joonwoo Park
timer: Use timer->base for flag checks
Commit-ID:  781978e6e156101209f62b9ebc8783b70ef248de
Gitweb:     http://git.kernel.org/tip/781978e6e156101209f62b9ebc8783b70ef248de
Author:     Joonwoo Park <[email protected]>
AuthorDate: Mon, 27 Apr 2015 19:21:49 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 5 May 2015 10:40:43 +0200

timer: Use timer->base for flag checks

At present, internal_add_timer() examines flags with 'base' which doesn't contain flags. Examine with 'timer->base' to avoid unnecessary waking up of nohz CPU when timer base has TIMER_DEFERRABLE set.

---
 kernel/time/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/timer.c +1 -1
index 03f926c..d4af7c5 100644
@@ -436,7 +436,7 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
 	 * require special care against races with idle_cpu(), lets deal
 	 * with that later.
 	 */
-	if (!tbase_get_deferrable(base) || tick_nohz_full_cpu(base->cpu))
+	if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(base->cpu))
 		wake_up_nohz_cpu(base->cpu);
 }