@@ -831,7 +831,7 @@ static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
831
831
/* Forward the time to expire in the future */
832
832
hrtimer_forward (& ts -> sched_timer , now , TICK_NSEC );
833
833
834
- if (ts -> nohz_mode == NOHZ_MODE_HIGHRES ) {
834
+ if (tick_sched_flag_test ( ts , TS_FLAG_HIGHRES ) ) {
835
835
hrtimer_start_expires (& ts -> sched_timer ,
836
836
HRTIMER_MODE_ABS_PINNED_HARD );
837
837
} else {
@@ -1040,14 +1040,14 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu)
1040
1040
* the tick timer.
1041
1041
*/
1042
1042
if (unlikely (expires == KTIME_MAX )) {
1043
- if (ts -> nohz_mode == NOHZ_MODE_HIGHRES )
1043
+ if (tick_sched_flag_test ( ts , TS_FLAG_HIGHRES ) )
1044
1044
hrtimer_cancel (& ts -> sched_timer );
1045
1045
else
1046
1046
tick_program_event (KTIME_MAX , 1 );
1047
1047
return ;
1048
1048
}
1049
1049
1050
- if (ts -> nohz_mode == NOHZ_MODE_HIGHRES ) {
1050
+ if (tick_sched_flag_test ( ts , TS_FLAG_HIGHRES ) ) {
1051
1051
hrtimer_start (& ts -> sched_timer , expires ,
1052
1052
HRTIMER_MODE_ABS_PINNED_HARD );
1053
1053
} else {
@@ -1108,7 +1108,7 @@ static void tick_nohz_full_update_tick(struct tick_sched *ts)
1108
1108
if (!tick_nohz_full_cpu (smp_processor_id ()))
1109
1109
return ;
1110
1110
1111
- if (ts -> nohz_mode == NOHZ_MODE_INACTIVE )
1111
+ if (! tick_sched_flag_test ( ts , TS_FLAG_NOHZ ) )
1112
1112
return ;
1113
1113
1114
1114
__tick_nohz_full_update_tick (ts , ktime_get ());
@@ -1168,7 +1168,7 @@ static bool can_stop_idle_tick(int cpu, struct tick_sched *ts)
1168
1168
return false;
1169
1169
}
1170
1170
1171
- if (unlikely (ts -> nohz_mode == NOHZ_MODE_INACTIVE ))
1171
+ if (unlikely (! tick_sched_flag_test ( ts , TS_FLAG_NOHZ ) ))
1172
1172
return false;
1173
1173
1174
1174
if (need_resched ())
@@ -1487,11 +1487,11 @@ static void tick_nohz_lowres_handler(struct clock_event_device *dev)
1487
1487
tick_program_event (hrtimer_get_expires (& ts -> sched_timer ), 1 );
1488
1488
}
1489
1489
1490
- static inline void tick_nohz_activate (struct tick_sched * ts , int mode )
1490
+ static inline void tick_nohz_activate (struct tick_sched * ts )
1491
1491
{
1492
1492
if (!tick_nohz_enabled )
1493
1493
return ;
1494
- ts -> nohz_mode = mode ;
1494
+ tick_sched_flag_set ( ts , TS_FLAG_NOHZ ) ;
1495
1495
/* One update is enough */
1496
1496
if (!test_and_set_bit (0 , & tick_nohz_active ))
1497
1497
timers_update_nohz ();
@@ -1512,7 +1512,7 @@ static void tick_nohz_switch_to_nohz(void)
1512
1512
* Recycle the hrtimer in 'ts', so we can share the
1513
1513
* highres code.
1514
1514
*/
1515
- tick_setup_sched_timer (NOHZ_MODE_LOWRES );
1515
+ tick_setup_sched_timer (false );
1516
1516
}
1517
1517
1518
1518
static inline void tick_nohz_irq_enter (void )
@@ -1540,7 +1540,7 @@ static inline void tick_nohz_irq_enter(void)
1540
1540
1541
1541
static inline void tick_nohz_switch_to_nohz (void ) { }
1542
1542
static inline void tick_nohz_irq_enter (void ) { }
1543
- static inline void tick_nohz_activate (struct tick_sched * ts , int mode ) { }
1543
+ static inline void tick_nohz_activate (struct tick_sched * ts ) { }
1544
1544
1545
1545
#endif /* CONFIG_NO_HZ_COMMON */
1546
1546
@@ -1567,15 +1567,17 @@ early_param("skew_tick", skew_tick);
1567
1567
* tick_setup_sched_timer - setup the tick emulation timer
1568
1568
* @mode: tick_nohz_mode to setup for
1569
1569
*/
1570
- void tick_setup_sched_timer (int mode )
1570
+ void tick_setup_sched_timer (bool hrtimer )
1571
1571
{
1572
1572
struct tick_sched * ts = this_cpu_ptr (& tick_cpu_sched );
1573
1573
1574
1574
/* Emulate tick processing via per-CPU hrtimers: */
1575
1575
hrtimer_init (& ts -> sched_timer , CLOCK_MONOTONIC , HRTIMER_MODE_ABS_HARD );
1576
1576
1577
- if (IS_ENABLED (CONFIG_HIGH_RES_TIMERS ) && mode == NOHZ_MODE_HIGHRES )
1577
+ if (IS_ENABLED (CONFIG_HIGH_RES_TIMERS ) && hrtimer ) {
1578
+ tick_sched_flag_set (ts , TS_FLAG_HIGHRES );
1578
1579
ts -> sched_timer .function = tick_nohz_handler ;
1580
+ }
1579
1581
1580
1582
/* Get the next period (per-CPU) */
1581
1583
hrtimer_set_expires (& ts -> sched_timer , tick_init_jiffy_update ());
@@ -1589,11 +1591,11 @@ void tick_setup_sched_timer(int mode)
1589
1591
}
1590
1592
1591
1593
hrtimer_forward_now (& ts -> sched_timer , TICK_NSEC );
1592
- if (IS_ENABLED (CONFIG_HIGH_RES_TIMERS ) && mode == NOHZ_MODE_HIGHRES )
1594
+ if (IS_ENABLED (CONFIG_HIGH_RES_TIMERS ) && hrtimer )
1593
1595
hrtimer_start_expires (& ts -> sched_timer , HRTIMER_MODE_ABS_PINNED_HARD );
1594
1596
else
1595
1597
tick_program_event (hrtimer_get_expires (& ts -> sched_timer ), 1 );
1596
- tick_nohz_activate (ts , mode );
1598
+ tick_nohz_activate (ts );
1597
1599
}
1598
1600
1599
1601
void tick_cancel_sched_timer (int cpu )
@@ -1602,7 +1604,7 @@ void tick_cancel_sched_timer(int cpu)
1602
1604
ktime_t idle_sleeptime , iowait_sleeptime ;
1603
1605
unsigned long idle_calls , idle_sleeps ;
1604
1606
1605
- if (IS_ENABLED ( CONFIG_HIGH_RES_TIMERS ) && ts -> sched_timer . base )
1607
+ if (tick_sched_flag_test ( ts , TS_FLAG_HIGHRES ) )
1606
1608
hrtimer_cancel (& ts -> sched_timer );
1607
1609
1608
1610
idle_sleeptime = ts -> idle_sleeptime ;
@@ -1652,7 +1654,7 @@ int tick_check_oneshot_change(int allow_nohz)
1652
1654
if (!test_and_clear_bit (0 , & ts -> check_clocks ))
1653
1655
return 0 ;
1654
1656
1655
- if (ts -> nohz_mode != NOHZ_MODE_INACTIVE )
1657
+ if (tick_sched_flag_test ( ts , TS_FLAG_NOHZ ) )
1656
1658
return 0 ;
1657
1659
1658
1660
if (!timekeeping_valid_for_hres () || !tick_is_oneshot_available ())
0 commit comments