* [PATCH] timers: avoid an unnecessory iteration in __run_timers()
@ 2017-10-09 3:55 Zhenzhong Duan
2017-10-17 15:33 ` Anna-Maria Gleixner
2017-10-18 13:33 ` [tip:timers/core] timers: Avoid an unnecessary " tip-bot for Zhenzhong Duan
0 siblings, 2 replies; 3+ messages in thread
From: Zhenzhong Duan @ 2017-10-09 3:55 UTC (permalink / raw)
To: sboyd, tglx, john.stultz, anna-maria
Cc: Srinivas REDDY Eeda, Joe Jin, linux-kernel
When we know next expired timer is later than current jiffies, we don't need to
call collect_expired_timers() again checking empty hlists.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
---
kernel/time/timer.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index f2674a0..02be824 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1560,8 +1560,7 @@ 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;
+ base->clk = jiffies;
return 0;
}
base->clk = next;
--
1.7.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] timers: avoid an unnecessory iteration in __run_timers()
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:timers/core] timers: Avoid an unnecessary " tip-bot for Zhenzhong Duan
1 sibling, 0 replies; 3+ messages in thread
From: Anna-Maria Gleixner @ 2017-10-17 15:33 UTC (permalink / raw)
To: Zhenzhong Duan
Cc: sboyd, tglx, john.stultz, Srinivas REDDY Eeda, Joe Jin, linux-kernel
On Sun, 8 Oct 2017, Zhenzhong Duan wrote:
> When we know next expired timer is later than current jiffies, we don't need to
> call collect_expired_timers() again checking empty hlists.
>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Acked-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Thanks,
Anna-Maria
> ---
> kernel/time/timer.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/time/timer.c b/kernel/time/timer.c
> index f2674a0..02be824 100644
> --- a/kernel/time/timer.c
> +++ b/kernel/time/timer.c
> @@ -1560,8 +1560,7 @@ 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;
> + base->clk = jiffies;
> return 0;
> }
> base->clk = next;
> --
> 1.7.3
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:timers/core] timers: Avoid an unnecessary iteration in __run_timers()
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
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Zhenzhong Duan @ 2017-10-18 13:33 UTC (permalink / raw)
To: linux-tip-commits
Cc: joe.jin, linux-kernel, zhenzhong.duan, anna-maria, tglx, mingo,
srinivas.eeda, hpa
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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-18 13:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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:timers/core] timers: Avoid an unnecessary " tip-bot for Zhenzhong Duan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).