Skip to content

Commit 0975fb5

Browse files
Frederic WeisbeckerKAGA-KOKO
authored andcommitted
timers: Remove must_forward_clk
There is no reason to keep this guard around. The code makes sure that base->clk remains sane and won't be forwarded beyond jiffies nor set backward. Signed-off-by: Frederic Weisbecker <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Juri Lelli <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d4f7dae commit 0975fb5

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

kernel/time/timer.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ struct timer_base {
205205
unsigned long next_expiry;
206206
unsigned int cpu;
207207
bool is_idle;
208-
bool must_forward_clk;
209208
DECLARE_BITMAP(pending_map, WHEEL_SIZE);
210209
struct hlist_head vectors[WHEEL_SIZE];
211210
} ____cacheline_aligned;
@@ -888,12 +887,13 @@ get_target_base(struct timer_base *base, unsigned tflags)
888887

889888
static inline void forward_timer_base(struct timer_base *base)
890889
{
891-
unsigned long jnow;
890+
unsigned long jnow = READ_ONCE(jiffies);
892891

893-
if (!base->must_forward_clk)
894-
return;
895-
896-
jnow = READ_ONCE(jiffies);
892+
/*
893+
* No need to forward if we are close enough below jiffies.
894+
* Also while executing timers, base->clk is 1 offset ahead
895+
* of jiffies to avoid endless requeuing to current jffies.
896+
*/
897897
if ((long)(jnow - base->clk) < 2)
898898
return;
899899

@@ -1722,24 +1722,15 @@ static inline void __run_timers(struct timer_base *base)
17221722
timer_base_lock_expiry(base);
17231723
raw_spin_lock_irq(&base->lock);
17241724

1725-
/*
1726-
* timer_base::must_forward_clk must be cleared before running
1727-
* timers so that any timer functions that call mod_timer() will
1728-
* not try to forward the base.
1729-
*/
1730-
base->must_forward_clk = false;
1731-
17321725
while (time_after_eq(jiffies, base->clk) &&
17331726
time_after_eq(jiffies, base->next_expiry)) {
1734-
17351727
levels = collect_expired_timers(base, heads);
17361728
base->clk++;
17371729
base->next_expiry = __next_timer_interrupt(base);
17381730

17391731
while (levels--)
17401732
expire_timers(base, heads + levels);
17411733
}
1742-
base->must_forward_clk = true;
17431734
raw_spin_unlock_irq(&base->lock);
17441735
timer_base_unlock_expiry(base);
17451736
}
@@ -1935,7 +1926,6 @@ int timers_prepare_cpu(unsigned int cpu)
19351926
base->clk = jiffies;
19361927
base->next_expiry = base->clk + NEXT_TIMER_MAX_DELTA;
19371928
base->is_idle = false;
1938-
base->must_forward_clk = true;
19391929
}
19401930
return 0;
19411931
}

0 commit comments

Comments
 (0)