diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2013-12-16 08:57:10 -0500 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-02-25 15:39:00 -0500 |
commit | d550e81dc0ddc04f1b417c179c214103a28e0ee8 (patch) | |
tree | a873c6b1a980500c59af7b194374d604e3dba1eb | |
parent | fff421580f512fc044cc7421fdff31a7a6997350 (diff) |
timers: Reduce __run_timers() latency for empty list
The __run_timers() function currently steps through the list one jiffy at
a time in order to update the timer wheel. However, if the timer wheel
is empty, no adjustment is needed other than updating ->timer_jiffies.
In this case, which is likely to be common for NO_HZ_FULL kernels, the
kernel currently incurs a large latency for no good reason. This commit
therefore short-circuits this case.
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Tested-by: Mike Galbraith <bitbucket@online.de>
-rw-r--r-- | kernel/timer.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/timer.c b/kernel/timer.c index fdc43834f3af..c8bc7091d8f3 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -338,6 +338,20 @@ void set_timer_slack(struct timer_list *timer, int slack_hz) | |||
338 | } | 338 | } |
339 | EXPORT_SYMBOL_GPL(set_timer_slack); | 339 | EXPORT_SYMBOL_GPL(set_timer_slack); |
340 | 340 | ||
341 | /* | ||
342 | * If the list is empty, catch up ->timer_jiffies to the current time. | ||
343 | * The caller must hold the tvec_base lock. Returns true if the list | ||
344 | * was empty and therefore ->timer_jiffies was updated. | ||
345 | */ | ||
346 | static bool catchup_timer_jiffies(struct tvec_base *base) | ||
347 | { | ||
348 | if (!base->all_timers) { | ||
349 | base->timer_jiffies = jiffies; | ||
350 | return true; | ||
351 | } | ||
352 | return false; | ||
353 | } | ||
354 | |||
341 | static void | 355 | static void |
342 | __internal_add_timer(struct tvec_base *base, struct timer_list *timer) | 356 | __internal_add_timer(struct tvec_base *base, struct timer_list *timer) |
343 | { | 357 | { |
@@ -1150,6 +1164,10 @@ static inline void __run_timers(struct tvec_base *base) | |||
1150 | struct timer_list *timer; | 1164 | struct timer_list *timer; |
1151 | 1165 | ||
1152 | spin_lock_irq(&base->lock); | 1166 | spin_lock_irq(&base->lock); |
1167 | if (catchup_timer_jiffies(base)) { | ||
1168 | spin_unlock_irq(&base->lock); | ||
1169 | return; | ||
1170 | } | ||
1153 | while (time_after_eq(jiffies, base->timer_jiffies)) { | 1171 | while (time_after_eq(jiffies, base->timer_jiffies)) { |
1154 | struct list_head work_list; | 1172 | struct list_head work_list; |
1155 | struct list_head *head = &work_list; | 1173 | struct list_head *head = &work_list; |