History

timers: Track total number of timers in list

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.

Paul E. McKenney committed 12 years ago

Commit fff42151 parent 849401b1 file · +5 −0Browse files

Unified · Split

kernel/timer.c+5−0
@@ -81,6 +81,7 @@ struct tvec_base { · 80 unmodified lines
81 unsigned long timer_jiffies;81 unsigned long timer_jiffies;
82 unsigned long next_timer;82 unsigned long next_timer;
83 unsigned long active_timers;83 unsigned long active_timers;
84 unsigned long all_timers;
84 struct tvec_root tv1;85 struct tvec_root tv1;
85 struct tvec tv2;86 struct tvec tv2;
86 struct tvec tv3;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 base->next_timer = timer->expires;393 base->next_timer = timer->expires;
393 base->active_timers++;394 base->active_timers++;
394 }395 }
396 base->all_timers++;
395}397}
396 398
397#ifdef CONFIG_TIMER_STATS399#ifdef CONFIG_TIMER_STATS
@@ -671,6 +673,7 @@ detach_expired_timer(struct timer_list *timer, struct tvec_base *base) · 273 unmodified lines
671 detach_timer(timer, true);673 detach_timer(timer, true);
672 if (!tbase_get_deferrable(timer->base))674 if (!tbase_get_deferrable(timer->base))
673 base->active_timers--;675 base->active_timers--;
676 base->all_timers--;
674}677}
675 678
676static int detach_if_pending(struct timer_list *timer, struct tvec_base *base,679static 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 if (timer->expires == base->next_timer)688 if (timer->expires == base->next_timer)
686 base->next_timer = base->timer_jiffies;689 base->next_timer = base->timer_jiffies;
687 }690 }
691 base->all_timers--;
688 return 1;692 return 1;
689}693}
690 694
@@ -1559,6 +1563,7 @@ static int init_timers_cpu(int cpu) · 868 unmodified lines
1559 base->timer_jiffies = jiffies;1563 base->timer_jiffies = jiffies;
1560 base->next_timer = base->timer_jiffies;1564 base->next_timer = base->timer_jiffies;
1561 base->active_timers = 0;1565 base->active_timers = 0;
1566 base->all_timers = 0;
1562 return 0;1567 return 0;
1563}1568}
1564 1569