From: tip-bot for Zhenzhong Duan <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
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
Subject: [tip:timers/core] timers: Avoid an unnecessary iteration in __run_timers()
Date: Wed, 18 Oct 2017 06:33:48 -0700 [thread overview]
Message-ID: <tip-c310ce4dcb9df9b2f1be82caff7dae609fe53f72@git.kernel.org> (raw)
In-Reply-To: <7086a857-f90c-4616-bbe8-f7696f21626c@default>
Commit-ID: c310ce4dcb9df9b2f1be82caff7dae609fe53f72
Gitweb: https://git.kernel.org/tip/c310ce4dcb9df9b2f1be82caff7dae609fe53f72
Author: Zhenzhong Duan <zhenzhong.duan@oracle.com>
AuthorDate: Sun, 8 Oct 2017 20:55:59 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
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 <zhenzhong.duan@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Cc: Joe Jin <joe.jin@oracle.com>
Cc: sboyd@codeaurora.org
Cc: Srinivas Reddy Eeda <srinivas.eeda@oracle.com>
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;
prev parent reply other threads:[~2017-10-18 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 3:55 [PATCH] timers: avoid an unnecessory iteration in __run_timers() Zhenzhong Duan
2017-10-17 15:33 ` Anna-Maria Gleixner
2017-10-18 13:33 ` tip-bot for Zhenzhong Duan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-c310ce4dcb9df9b2f1be82caff7dae609fe53f72@git.kernel.org \
--to=tipbot@zytor.com \
--cc=anna-maria@linutronix.de \
--cc=hpa@zytor.com \
--cc=joe.jin@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=srinivas.eeda@oracle.com \
--cc=tglx@linutronix.de \
--cc=zhenzhong.duan@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox