linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] timers: fix offset calculation when the expires align with LVL_GRAN
@ 2018-07-27  5:33 Xu YiPing
  2018-07-30 11:03 ` Thomas Gleixner
  0 siblings, 1 reply; 8+ messages in thread
From: Xu YiPing @ 2018-07-27  5:33 UTC (permalink / raw)
  To: xuyiping, tglx, john.stultz, sboyd; +Cc: linux-kernel

when the expires of timer is align with LVL_GRAN(n), it will be trigged
in 'expires + LVL_GRAN(n)'.

Some drivers like power runtime use the timer to start a power down
of device, it could saves power if the timer is triggerd in time,
especially when LEVEL=0 with low expires.

Signed-off-by: Xu YiPing <xuyiping@hisilicon.com>
---
 kernel/time/timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index cc2d23e..76655e2 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -487,7 +487,8 @@ static inline void timer_set_idx(struct timer_list *timer, unsigned int idx)
  */
 static inline unsigned calc_index(unsigned expires, unsigned lvl)
 {
-	expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl);
+	expires = (expires + LVL_GRAN(lvl) - 1) >> LVL_SHIFT(lvl);
+
 	return LVL_OFFS(lvl) + (expires & LVL_MASK);
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-08-01  7:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27  5:33 [PATCH] timers: fix offset calculation when the expires align with LVL_GRAN Xu YiPing
2018-07-30 11:03 ` Thomas Gleixner
2018-07-31 12:37   ` Xu YiPing
2018-07-31 13:45   ` Xu YiPing
2018-07-31 14:22     ` Thomas Gleixner
2018-07-31 14:34       ` Thomas Gleixner
2018-08-01  2:45         ` Xu YiPing
2018-08-01  7:10           ` Thomas Gleixner

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).