Skip to content

Commit 27dc080

Browse files
Frederic WeisbeckerKAGA-KOKO
authored andcommitted
tick: Use IS_ENABLED() whenever possible
Avoid ifdeferry if it can be converted to IS_ENABLED() whenever possible Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20240225225508.11587-5-frederic@kernel.org
1 parent 3aedb7f commit 27dc080

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

kernel/time/tick-common.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,13 @@ void tick_handle_periodic(struct clock_event_device *dev)
111111

112112
tick_periodic(cpu);
113113

114-
#if defined(CONFIG_HIGH_RES_TIMERS) || defined(CONFIG_NO_HZ_COMMON)
115114
/*
116115
* The cpu might have transitioned to HIGHRES or NOHZ mode via
117116
* update_process_times() -> run_local_timers() ->
118117
* hrtimer_run_queues().
119118
*/
120-
if (dev->event_handler != tick_handle_periodic)
119+
if (IS_ENABLED(CONFIG_TICK_ONESHOT) && dev->event_handler != tick_handle_periodic)
121120
return;
122-
#endif
123121

124122
if (!clockevent_state_oneshot(dev))
125123
return;

kernel/time/tick-sched.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ static void tick_sched_do_timer(struct tick_sched *ts, ktime_t now)
186186
{
187187
int cpu = smp_processor_id();
188188

189-
#ifdef CONFIG_NO_HZ_COMMON
190189
/*
191190
* Check if the do_timer duty was dropped. We don't care about
192191
* concurrency: This happens only when the CPU in charge went
@@ -197,13 +196,13 @@ static void tick_sched_do_timer(struct tick_sched *ts, ktime_t now)
197196
* If nohz_full is enabled, this should not happen because the
198197
* 'tick_do_timer_cpu' CPU never relinquishes.
199198
*/
200-
if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE)) {
199+
if (IS_ENABLED(CONFIG_NO_HZ_COMMON) &&
200+
unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE)) {
201201
#ifdef CONFIG_NO_HZ_FULL
202202
WARN_ON_ONCE(tick_nohz_full_running);
203203
#endif
204204
tick_do_timer_cpu = cpu;
205205
}
206-
#endif
207206

208207
/* Check if jiffies need an update */
209208
if (tick_do_timer_cpu == cpu)
@@ -230,7 +229,6 @@ static void tick_sched_do_timer(struct tick_sched *ts, ktime_t now)
230229

231230
static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
232231
{
233-
#ifdef CONFIG_NO_HZ_COMMON
234232
/*
235233
* When we are idle and the tick is stopped, we have to touch
236234
* the watchdog as we might not schedule for a really long
@@ -239,7 +237,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
239237
* idle" jiffy stamp so the idle accounting adjustment we do
240238
* when we go busy again does not account too many ticks.
241239
*/
242-
if (ts->tick_stopped) {
240+
if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && ts->tick_stopped) {
243241
touch_softlockup_watchdog_sched();
244242
if (is_idle_task(current))
245243
ts->idle_jiffies++;
@@ -250,7 +248,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
250248
*/
251249
ts->next_tick = 0;
252250
}
253-
#endif
251+
254252
update_process_times(user_mode(regs));
255253
profile_tick(CPU_PROFILING);
256254
}
@@ -1587,10 +1585,8 @@ void tick_cancel_sched_timer(int cpu)
15871585
ktime_t idle_sleeptime, iowait_sleeptime;
15881586
unsigned long idle_calls, idle_sleeps;
15891587

1590-
# ifdef CONFIG_HIGH_RES_TIMERS
1591-
if (ts->sched_timer.base)
1588+
if (IS_ENABLED(CONFIG_HIGH_RES_TIMERS) && ts->sched_timer.base)
15921589
hrtimer_cancel(&ts->sched_timer);
1593-
# endif
15941590

15951591
idle_sleeptime = ts->idle_sleeptime;
15961592
iowait_sleeptime = ts->iowait_sleeptime;

0 commit comments

Comments
 (0)