Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312377
b: refs/heads/master
c: 99d5f3a
h: refs/heads/master
i:
  312375: ea8e03a
v: v3
  • Loading branch information
Thomas Gleixner committed Jun 6, 2012
1 parent 5644a78 commit 8a38aba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: facbb4a7efbd658046bf615f03cd97a1504785d8
refs/heads/master: 99d5f3aac674fe081ffddd2dbb8946ccbc14c410
31 changes: 23 additions & 8 deletions trunk/kernel/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct tvec_base {
struct timer_list *running_timer;
unsigned long timer_jiffies;
unsigned long next_timer;
unsigned long active_timers;
struct tvec_root tv1;
struct tvec tv2;
struct tvec tv3;
Expand Down Expand Up @@ -377,11 +378,13 @@ static void internal_add_timer(struct tvec_base *base, struct timer_list *timer)
{
__internal_add_timer(base, timer);
/*
* Update base->next_timer if this is the earliest one.
* Update base->active_timers and base->next_timer
*/
if (time_before(timer->expires, base->next_timer) &&
!tbase_get_deferrable(timer->base))
base->next_timer = timer->expires;
if (!tbase_get_deferrable(timer->base)) {
if (time_before(timer->expires, base->next_timer))
base->next_timer = timer->expires;
base->active_timers++;
}
}

#ifdef CONFIG_TIMER_STATS
Expand Down Expand Up @@ -678,16 +681,26 @@ static inline void detach_timer(struct timer_list *timer, bool clear_pending)
entry->prev = LIST_POISON2;
}

static inline void
detach_expired_timer(struct timer_list *timer, struct tvec_base *base)
{
detach_timer(timer, true);
if (!tbase_get_deferrable(timer->base))
timer->base->active_timers--;
}

static int detach_if_pending(struct timer_list *timer, struct tvec_base *base,
bool clear_pending)
{
if (!timer_pending(timer))
return 0;

detach_timer(timer, clear_pending);
if (timer->expires == base->next_timer &&
!tbase_get_deferrable(timer->base))
base->next_timer = base->timer_jiffies;
if (!tbase_get_deferrable(timer->base)) {
timer->base->active_timers--;
if (timer->expires == base->next_timer)
base->next_timer = base->timer_jiffies;
}
return 1;
}

Expand Down Expand Up @@ -1175,7 +1188,7 @@ static inline void __run_timers(struct tvec_base *base)
timer_stats_account_timer(timer);

base->running_timer = timer;
detach_timer(timer, true);
detach_expired_timer(timer, base);

spin_unlock_irq(&base->lock);
call_timer_fn(timer, fn, data);
Expand Down Expand Up @@ -1701,6 +1714,7 @@ static int __cpuinit init_timers_cpu(int cpu)

base->timer_jiffies = jiffies;
base->next_timer = base->timer_jiffies;
base->active_timers = 0;
return 0;
}

Expand All @@ -1711,6 +1725,7 @@ static void migrate_timer_list(struct tvec_base *new_base, struct list_head *hea

while (!list_empty(head)) {
timer = list_first_entry(head, struct timer_list, entry);
/* We ignore the accounting on the dying cpu */
detach_timer(timer, false);
timer_set_base(timer, new_base);
internal_add_timer(new_base, timer);
Expand Down

0 comments on commit 8a38aba

Please sign in to comment.