@@ -831,7 +831,7 @@ static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
831831 /* Forward the time to expire in the future */
832832 hrtimer_forward (& ts -> sched_timer , now , TICK_NSEC );
833833
834- if (ts -> nohz_mode == NOHZ_MODE_HIGHRES ) {
834+ if (tick_sched_flag_test ( ts , TS_FLAG_HIGHRES ) ) {
835835 hrtimer_start_expires (& ts -> sched_timer ,
836836 HRTIMER_MODE_ABS_PINNED_HARD );
837837 } else {
@@ -1040,14 +1040,14 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu)
10401040 * the tick timer.
10411041 */
10421042 if (unlikely (expires == KTIME_MAX )) {
1043- if (ts -> nohz_mode == NOHZ_MODE_HIGHRES )
1043+ if (tick_sched_flag_test ( ts , TS_FLAG_HIGHRES ) )
10441044 hrtimer_cancel (& ts -> sched_timer );
10451045 else
10461046 tick_program_event (KTIME_MAX , 1 );
10471047 return ;
10481048 }
10491049
1050- if (ts -> nohz_mode == NOHZ_MODE_HIGHRES ) {
1050+ if (tick_sched_flag_test ( ts , TS_FLAG_HIGHRES ) ) {
10511051 hrtimer_start (& ts -> sched_timer , expires ,
10521052 HRTIMER_MODE_ABS_PINNED_HARD );
10531053 } else {
@@ -1108,7 +1108,7 @@ static void tick_nohz_full_update_tick(struct tick_sched *ts)
11081108 if (!tick_nohz_full_cpu (smp_processor_id ()))
11091109 return ;
11101110
1111- if (ts -> nohz_mode == NOHZ_MODE_INACTIVE )
1111+ if (! tick_sched_flag_test ( ts , TS_FLAG_NOHZ ) )
11121112 return ;
11131113
11141114 __tick_nohz_full_update_tick (ts , ktime_get ());
@@ -1168,7 +1168,7 @@ static bool can_stop_idle_tick(int cpu, struct tick_sched *ts)
11681168 return false;
11691169 }
11701170
1171- if (unlikely (ts -> nohz_mode == NOHZ_MODE_INACTIVE ))
1171+ if (unlikely (! tick_sched_flag_test ( ts , TS_FLAG_NOHZ ) ))
11721172 return false;
11731173
11741174 if (need_resched ())
@@ -1487,11 +1487,11 @@ static void tick_nohz_lowres_handler(struct clock_event_device *dev)
14871487 tick_program_event (hrtimer_get_expires (& ts -> sched_timer ), 1 );
14881488}
14891489
1490- static inline void tick_nohz_activate (struct tick_sched * ts , int mode )
1490+ static inline void tick_nohz_activate (struct tick_sched * ts )
14911491{
14921492 if (!tick_nohz_enabled )
14931493 return ;
1494- ts -> nohz_mode = mode ;
1494+ tick_sched_flag_set ( ts , TS_FLAG_NOHZ ) ;
14951495 /* One update is enough */
14961496 if (!test_and_set_bit (0 , & tick_nohz_active ))
14971497 timers_update_nohz ();
@@ -1512,7 +1512,7 @@ static void tick_nohz_switch_to_nohz(void)
15121512 * Recycle the hrtimer in 'ts', so we can share the
15131513 * highres code.
15141514 */
1515- tick_setup_sched_timer (NOHZ_MODE_LOWRES );
1515+ tick_setup_sched_timer (false );
15161516}
15171517
15181518static inline void tick_nohz_irq_enter (void )
@@ -1540,7 +1540,7 @@ static inline void tick_nohz_irq_enter(void)
15401540
15411541static inline void tick_nohz_switch_to_nohz (void ) { }
15421542static 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 ) { }
15441544
15451545#endif /* CONFIG_NO_HZ_COMMON */
15461546
@@ -1567,15 +1567,17 @@ early_param("skew_tick", skew_tick);
15671567 * tick_setup_sched_timer - setup the tick emulation timer
15681568 * @mode: tick_nohz_mode to setup for
15691569 */
1570- void tick_setup_sched_timer (int mode )
1570+ void tick_setup_sched_timer (bool hrtimer )
15711571{
15721572 struct tick_sched * ts = this_cpu_ptr (& tick_cpu_sched );
15731573
15741574 /* Emulate tick processing via per-CPU hrtimers: */
15751575 hrtimer_init (& ts -> sched_timer , CLOCK_MONOTONIC , HRTIMER_MODE_ABS_HARD );
15761576
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 );
15781579 ts -> sched_timer .function = tick_nohz_handler ;
1580+ }
15791581
15801582 /* Get the next period (per-CPU) */
15811583 hrtimer_set_expires (& ts -> sched_timer , tick_init_jiffy_update ());
@@ -1589,11 +1591,11 @@ void tick_setup_sched_timer(int mode)
15891591 }
15901592
15911593 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 )
15931595 hrtimer_start_expires (& ts -> sched_timer , HRTIMER_MODE_ABS_PINNED_HARD );
15941596 else
15951597 tick_program_event (hrtimer_get_expires (& ts -> sched_timer ), 1 );
1596- tick_nohz_activate (ts , mode );
1598+ tick_nohz_activate (ts );
15971599}
15981600
15991601void tick_cancel_sched_timer (int cpu )
@@ -1602,7 +1604,7 @@ void tick_cancel_sched_timer(int cpu)
16021604 ktime_t idle_sleeptime , iowait_sleeptime ;
16031605 unsigned long idle_calls , idle_sleeps ;
16041606
1605- if (IS_ENABLED ( CONFIG_HIGH_RES_TIMERS ) && ts -> sched_timer . base )
1607+ if (tick_sched_flag_test ( ts , TS_FLAG_HIGHRES ) )
16061608 hrtimer_cancel (& ts -> sched_timer );
16071609
16081610 idle_sleeptime = ts -> idle_sleeptime ;
@@ -1652,7 +1654,7 @@ int tick_check_oneshot_change(int allow_nohz)
16521654 if (!test_and_clear_bit (0 , & ts -> check_clocks ))
16531655 return 0 ;
16541656
1655- if (ts -> nohz_mode != NOHZ_MODE_INACTIVE )
1657+ if (tick_sched_flag_test ( ts , TS_FLAG_NOHZ ) )
16561658 return 0 ;
16571659
16581660 if (!timekeeping_valid_for_hres () || !tick_is_oneshot_available ())
0 commit comments