From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754211AbdJRNfB (ORCPT ); Wed, 18 Oct 2017 09:35:01 -0400 Received: from terminus.zytor.com ([65.50.211.136]:57077 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754170AbdJRNe6 (ORCPT ); Wed, 18 Oct 2017 09:34:58 -0400 Date: Wed, 18 Oct 2017 06:33:48 -0700 From: tip-bot for Zhenzhong Duan Message-ID: Cc: joe.jin@oracle.com, linux-kernel@vger.kernel.org, zhenzhong.duan@oracle.com, anna-maria@linutronix.de, tglx@linutronix.de, mingo@kernel.org, srinivas.eeda@oracle.com, hpa@zytor.com Reply-To: hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de, srinivas.eeda@oracle.com, anna-maria@linutronix.de, linux-kernel@vger.kernel.org, zhenzhong.duan@oracle.com, joe.jin@oracle.com In-Reply-To: <7086a857-f90c-4616-bbe8-f7696f21626c@default> References: <7086a857-f90c-4616-bbe8-f7696f21626c@default> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/core] timers: Avoid an unnecessary iteration in __run_timers() Git-Commit-ID: c310ce4dcb9df9b2f1be82caff7dae609fe53f72 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c310ce4dcb9df9b2f1be82caff7dae609fe53f72 Gitweb: https://git.kernel.org/tip/c310ce4dcb9df9b2f1be82caff7dae609fe53f72 Author: Zhenzhong Duan AuthorDate: Sun, 8 Oct 2017 20:55:59 -0700 Committer: Thomas Gleixner CommitDate: Wed, 18 Oct 2017 15:29:33 +0200 timers: Avoid an unnecessary iteration in __run_timers() If the base clock is behind jiffies in the soft irq expiry code then the next timer is retrieved by get_next_timer_interrupt() to avoid incrementing base clock one by one. If the next timer interrupt is past current jiffies then the base clock is set to jiffies - 1. At the call site this is incremented and another iteration through the expiry loop is executed which checks empty hash buckets. That's a pointless excercise because it's already known that the next timer is past jiffies. Set the base clock in that case to jiffies directly so it gets incremented to jiffies + 1 at the call site resulting in immediate termination of the expiry loop. [ tglx: Massaged changelog and added comment to the code ] Signed-off-by: Zhenzhong Duan Signed-off-by: Thomas Gleixner Acked-by: Anna-Maria Gleixner Cc: Joe Jin Cc: sboyd@codeaurora.org Cc: Srinivas Reddy Eeda Cc: john.stultz@linaro.org Link: https://lkml.kernel.org/r/7086a857-f90c-4616-bbe8-f7696f21626c@default --- kernel/time/timer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 38613ce..ee1a88d 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1560,8 +1560,11 @@ static int collect_expired_timers(struct timer_base *base, * jiffies, otherwise forward to the next expiry time: */ if (time_after(next, jiffies)) { - /* The call site will increment clock! */ - base->clk = jiffies - 1; + /* + * The call site will increment base->clk and then + * terminate the expiry loop immediately. + */ + base->clk = jiffies; return 0; } base->clk = next;