From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755546AbbCLTSv (ORCPT ); Thu, 12 Mar 2015 15:18:51 -0400 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.228]:37185 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754585AbbCLTOX (ORCPT ); Thu, 12 Mar 2015 15:14:23 -0400 Message-Id: <20150312191412.783756948@goodmis.org> User-Agent: quilt/0.61-1 Date: Thu, 12 Mar 2015 15:13:42 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-rt-users Cc: Thomas Gleixner , Carsten Emde , Sebastian Andrzej Siewior , John Kacur , Paul Gortmaker , "Paul E. McKenney" , Josh Triplett , Peter Zijlstra , Oleg Nesterov , Mike Galbraith Subject: [PATCH RT 35/39] timers: Reduce __run_timers() latency for empty list References: <20150312191307.081068717@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0035-timers-Reduce-__run_timers-latency-for-empty-list.patch X-RR-Connecting-IP: 107.14.168.118:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.14.34-rt32-rc1 stable review patch. If anyone has any objections, please let me know. ------------------ From: "Paul E. McKenney" upstream commit: d550e81dc0ddc04f1b417c179c214103a28e0ee8 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 Reviewed-by: Josh Triplett Acked-by: Peter Zijlstra Reviewed-by: Oleg Nesterov Reviewed-by: Steven Rostedt Tested-by: Mike Galbraith Signed-off-by: Steven Rostedt --- kernel/timer.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel/timer.c b/kernel/timer.c index 251fdacfebdb..9cf70c562fac 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -341,6 +341,20 @@ void set_timer_slack(struct timer_list *timer, int slack_hz) } EXPORT_SYMBOL_GPL(set_timer_slack); +/* + * If the list is empty, catch up ->timer_jiffies to the current time. + * The caller must hold the tvec_base lock. Returns true if the list + * was empty and therefore ->timer_jiffies was updated. + */ +static bool catchup_timer_jiffies(struct tvec_base *base) +{ + if (!base->all_timers) { + base->timer_jiffies = jiffies; + return true; + } + return false; +} + static void __internal_add_timer(struct tvec_base *base, struct timer_list *timer) { @@ -1203,6 +1217,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; -- 2.1.4