Currently, the tvec_base structure's ->active_timers field tracks only the non-deferrable timers, which means that even if ->active_timers is zero, there might well be deferrable timers in the list. This commit therefore adds an ->all_timers field to track all the timers, whether deferrable or not.
Showing the changes to kernel/timer.c (1 of 1 file). Show all
Unified · Split
| @@ -81,6 +81,7 @@ struct tvec_base { · 80 unmodified lines | ||
| 81 | 81 | unsigned long timer_jiffies; |
| 82 | 82 | unsigned long next_timer; |
| 83 | 83 | unsigned long active_timers; |
| 84 | + unsigned long all_timers; | |
| 84 | 85 | struct tvec_root tv1; |
| 85 | 86 | struct tvec tv2; |
| 86 | 87 | struct tvec tv3; |
| @@ -392,6 +393,7 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer) · 305 unmodified lines | ||
| 392 | 393 | base->next_timer = timer->expires; |
| 393 | 394 | base->active_timers++; |
| 394 | 395 | } |
| 396 | + base->all_timers++; | |
| 395 | 397 | } |
| 396 | 398 | |
| 397 | 399 | #ifdef CONFIG_TIMER_STATS |
| @@ -671,6 +673,7 @@ detach_expired_timer(struct timer_list *timer, struct tvec_base *base) · 273 unmodified lines | ||
| 671 | 673 | detach_timer(timer, true); |
| 672 | 674 | if (!tbase_get_deferrable(timer->base)) |
| 673 | 675 | base->active_timers--; |
| 676 | + base->all_timers--; | |
| 674 | 677 | } |
| 675 | 678 | |
| 676 | 679 | static int detach_if_pending(struct timer_list *timer, struct tvec_base *base, |
| @@ -685,6 +688,7 @@ static int detach_if_pending(struct timer_list *timer, struct tvec_base *base, · 8 unmodified lines | ||
| 685 | 688 | if (timer->expires == base->next_timer) |
| 686 | 689 | base->next_timer = base->timer_jiffies; |
| 687 | 690 | } |
| 691 | + base->all_timers--; | |
| 688 | 692 | return 1; |
| 689 | 693 | } |
| 690 | 694 | |
| @@ -1559,6 +1563,7 @@ static int init_timers_cpu(int cpu) · 868 unmodified lines | ||
| 1559 | 1563 | base->timer_jiffies = jiffies; |
| 1560 | 1564 | base->next_timer = base->timer_jiffies; |
| 1561 | 1565 | base->active_timers = 0; |
| 1566 | + base->all_timers = 0; | |
| 1562 | 1567 | return 0; |
| 1563 | 1568 | } |
| 1564 | 1569 | |