timers: Check timer_pending() before reading bucket index
PATCH 1/1 timers: Check timer_pending() before reading bucket index
Only read the cached wheel index when the timer is still queued. No functional change.
Signed-off-by Liang Hao <[email protected]>
--- kernel/time/timer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/time/timer.c +3 -1
@@ -897,11 +897,13 @@ static inline void detach_timer(struct timer_list *timer, bool clear_pending)static int detach_if_pending (struct timer_list *timer,struct timer_base *base,bool clear_pending) { -unsigned idx =timer_get_idx (timer); +unsigned int idx;if (!timer_pending (timer))return 0 ; + idx =timer_get_idx (timer); +if (hlist_is_singular_node (&timer->entry, base->vectors + idx)) {__clear_bit (idx, base->pending_map); base->next_expiry_recalc = true;
Signature · 1 line
2.50.1 (Apple Git-155)
Thomas Gleixner
maintainerQuoted 2 lines · Liang Hao
Only read the cached wheel index when the timer is still queued. No functional change.
Which problem is actually solved by this?
Quoted 1 line · Thomas Gleixner
Which problem is actually solved by this?
None that shows up as a bug. The index is never used when the timer is not queued; I only reordered the checks. I'll drop it.
Thanks,
Liang Hao