lkml.org 
[lkml]   [2014]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH tip/core/timers 1/3] timers: Reduce __run_timers() latency for empty list
Date
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>

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>
---
kernel/timer.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/kernel/timer.c b/kernel/timer.c
index 6582b82fa966..21849275828f 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -337,6 +337,17 @@ void set_timer_slack(struct timer_list *timer, int slack_hz)
}
EXPORT_SYMBOL_GPL(set_timer_slack);

+static bool catchup_timer_jiffies(struct tvec_base *base)
+{
+#ifdef CONFIG_NO_HZ_FULL
+ if (!base->active_timers) {
+ base->timer_jiffies = jiffies;
+ return 1;
+ }
+#endif /* #ifdef CONFIG_NO_HZ_FULL */
+ return 0;
+}
+
static void
__internal_add_timer(struct tvec_base *base, struct timer_list *timer)
{
@@ -1146,6 +1157,10 @@ static inline void __run_timers(struct tvec_base *base)
struct timer_list *timer;

spin_lock_irq(&base->lock);
+ if (catchup_timer_jiffies(base)) {
+ spin_unlock_irq(&base->lock);
+ return;
+ }
while (time_after_eq(jiffies, base->timer_jiffies)) {
struct list_head work_list;
struct list_head *head = &work_list;
--
1.8.1.5


\
 
 \ /
  Last update: 2014-01-14 06:01    [W:0.607 / U:0.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site