[PATCH] timers: Make the lower-level timer function first call than higher-level
From: Muchun Song
Date: Mon Nov 19 2018 - 09:10:25 EST
The elements of the heads array are a linked list of timer events that
expire at the current time. And it can contain up to LVL_DEPTH levels
and the lower the level represents the smaller the time granularity.
Now the result is that the function, which will be called when the timer
expires, in the higher-level is called first than the lower-level function.
I think it might be better to call the lower-level timer function first
than the higher-level function. Because the lower-level has the smaller
granularity and delay has less impact on higher-level. So fix it.
Signed-off-by: Muchun Song <smuchun@xxxxxxxxx>
---
kernel/time/timer.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index fa49cd753dea..7c757b27aa58 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1674,12 +1674,13 @@ static inline void __run_timers(struct timer_base *base)
base->must_forward_clk = false;
while (time_after_eq(jiffies, base->clk)) {
+ int i;
levels = collect_expired_timers(base, heads);
base->clk++;
- while (levels--)
- expire_timers(base, heads + levels);
+ for (i = 0; i < levels; i++)
+ expire_timers(base, heads + i);
}
base->running_timer = NULL;
raw_spin_unlock_irq(&base->lock);
--
2.17.1