@@ -544,8 +544,7 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk,
544
544
}
545
545
546
546
static void
547
- trigger_dyntick_cpu (struct timer_base * base , struct timer_list * timer ,
548
- unsigned long bucket_expiry )
547
+ trigger_dyntick_cpu (struct timer_base * base , struct timer_list * timer )
549
548
{
550
549
if (!is_timers_nohz_active ())
551
550
return ;
@@ -565,23 +564,8 @@ trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer,
565
564
* timer is not deferrable. If the other CPU is on the way to idle
566
565
* then it can't set base->is_idle as we hold the base lock:
567
566
*/
568
- if (!base -> is_idle )
569
- return ;
570
-
571
- /*
572
- * Check whether this is the new first expiring timer. The
573
- * effective expiry time of the timer is required here
574
- * (bucket_expiry) instead of timer->expires.
575
- */
576
- if (time_after_eq (bucket_expiry , base -> next_expiry ))
577
- return ;
578
-
579
- /*
580
- * Set the next expiry time and kick the CPU so it can reevaluate the
581
- * wheel:
582
- */
583
- base -> next_expiry = bucket_expiry ;
584
- wake_up_nohz_cpu (base -> cpu );
567
+ if (base -> is_idle )
568
+ wake_up_nohz_cpu (base -> cpu );
585
569
}
586
570
587
571
/*
@@ -592,12 +576,26 @@ trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer,
592
576
static void enqueue_timer (struct timer_base * base , struct timer_list * timer ,
593
577
unsigned int idx , unsigned long bucket_expiry )
594
578
{
579
+
595
580
hlist_add_head (& timer -> entry , base -> vectors + idx );
596
581
__set_bit (idx , base -> pending_map );
597
582
timer_set_idx (timer , idx );
598
583
599
584
trace_timer_start (timer , timer -> expires , timer -> flags );
600
- trigger_dyntick_cpu (base , timer , bucket_expiry );
585
+
586
+ /*
587
+ * Check whether this is the new first expiring timer. The
588
+ * effective expiry time of the timer is required here
589
+ * (bucket_expiry) instead of timer->expires.
590
+ */
591
+ if (time_before (bucket_expiry , base -> next_expiry )) {
592
+ /*
593
+ * Set the next expiry time and kick the CPU so it
594
+ * can reevaluate the wheel:
595
+ */
596
+ base -> next_expiry = bucket_expiry ;
597
+ trigger_dyntick_cpu (base , timer );
598
+ }
601
599
}
602
600
603
601
static void internal_add_timer (struct timer_base * base , struct timer_list * timer )
@@ -1493,7 +1491,6 @@ static int __collect_expired_timers(struct timer_base *base,
1493
1491
return levels ;
1494
1492
}
1495
1493
1496
- #ifdef CONFIG_NO_HZ_COMMON
1497
1494
/*
1498
1495
* Find the next pending bucket of a level. Search from level start (@offset)
1499
1496
* + @clk upwards and if nothing there, search from start of the level
@@ -1585,6 +1582,7 @@ static unsigned long __next_timer_interrupt(struct timer_base *base)
1585
1582
return next ;
1586
1583
}
1587
1584
1585
+ #ifdef CONFIG_NO_HZ_COMMON
1588
1586
/*
1589
1587
* Check, if the next hrtimer event is before the next timer wheel
1590
1588
* event:
@@ -1790,6 +1788,7 @@ static inline void __run_timers(struct timer_base *base)
1790
1788
1791
1789
levels = collect_expired_timers (base , heads );
1792
1790
base -> clk ++ ;
1791
+ base -> next_expiry = __next_timer_interrupt (base );
1793
1792
1794
1793
while (levels -- )
1795
1794
expire_timers (base , heads + levels );
@@ -2042,6 +2041,7 @@ static void __init init_timer_cpu(int cpu)
2042
2041
base -> cpu = cpu ;
2043
2042
raw_spin_lock_init (& base -> lock );
2044
2043
base -> clk = jiffies ;
2044
+ base -> next_expiry = base -> clk + NEXT_TIMER_MAX_DELTA ;
2045
2045
timer_base_init_expiry_lock (base );
2046
2046
}
2047
2047
}
0 commit comments