From: Frederic Weisbecker <frederic@kernel.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Peng Liu <liupeng17@lenovo.com>,
Joel Fernandes <joel@joelfernandes.org>
Subject: [PATCH 04/15] tick: Use IS_ENABLED() whenever possible
Date: Wed, 24 Jan 2024 18:04:48 +0100 [thread overview]
Message-ID: <20240124170459.24850-5-frederic@kernel.org> (raw)
In-Reply-To: <20240124170459.24850-1-frederic@kernel.org>
Avoid ifdeferry if it can be converted to IS_ENABLED() whenever possible
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
kernel/time/tick-common.c | 4 +---
kernel/time/tick-sched.c | 14 +++++---------
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index e9138cd7a0f5..0084e1ae2583 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -111,15 +111,13 @@ void tick_handle_periodic(struct clock_event_device *dev)
tick_periodic(cpu);
-#if defined(CONFIG_HIGH_RES_TIMERS) || defined(CONFIG_NO_HZ_COMMON)
/*
* The cpu might have transitioned to HIGHRES or NOHZ mode via
* update_process_times() -> run_local_timers() ->
* hrtimer_run_queues().
*/
- if (dev->event_handler != tick_handle_periodic)
+ if (IS_ENABLED(CONFIG_TICK_ONESHOT) && dev->event_handler != tick_handle_periodic)
return;
-#endif
if (!clockevent_state_oneshot(dev))
return;
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 75385b9a233e..c311b7388685 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -186,7 +186,6 @@ static void tick_sched_do_timer(struct tick_sched *ts, ktime_t now)
{
int cpu = smp_processor_id();
-#ifdef CONFIG_NO_HZ_COMMON
/*
* Check if the do_timer duty was dropped. We don't care about
* 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)
* If nohz_full is enabled, this should not happen because the
* 'tick_do_timer_cpu' CPU never relinquishes.
*/
- if (unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE)) {
+ if (IS_ENABLED(CONFIG_NO_HZ_COMMON) &&
+ unlikely(tick_do_timer_cpu == TICK_DO_TIMER_NONE)) {
#ifdef CONFIG_NO_HZ_FULL
WARN_ON_ONCE(tick_nohz_full_running);
#endif
tick_do_timer_cpu = cpu;
}
-#endif
/* Check if jiffies need an update */
if (tick_do_timer_cpu == cpu)
@@ -230,7 +229,6 @@ static void tick_sched_do_timer(struct tick_sched *ts, ktime_t now)
static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
{
-#ifdef CONFIG_NO_HZ_COMMON
/*
* When we are idle and the tick is stopped, we have to touch
* 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)
* idle" jiffy stamp so the idle accounting adjustment we do
* when we go busy again does not account too many ticks.
*/
- if (ts->tick_stopped) {
+ if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && ts->tick_stopped) {
touch_softlockup_watchdog_sched();
if (is_idle_task(current))
ts->idle_jiffies++;
@@ -250,7 +248,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
*/
ts->next_tick = 0;
}
-#endif
+
update_process_times(user_mode(regs));
profile_tick(CPU_PROFILING);
}
@@ -1551,10 +1549,8 @@ void tick_cancel_sched_timer(int cpu)
struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
ktime_t idle_sleeptime, iowait_sleeptime;
-# ifdef CONFIG_HIGH_RES_TIMERS
- if (ts->sched_timer.base)
+ if (IS_ENABLED(CONFIG_HIGH_RES_TIMERS) && ts->sched_timer.base)
hrtimer_cancel(&ts->sched_timer);
-# endif
idle_sleeptime = ts->idle_sleeptime;
iowait_sleeptime = ts->iowait_sleeptime;
--
2.43.0
next prev parent reply other threads:[~2024-01-24 17:05 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 17:04 [PATCH 00/15] timers/nohz cleanups and hotplug reorganization Frederic Weisbecker
2024-01-24 17:04 ` [PATCH 01/15] tick/nohz: Remove duplicate between tick_nohz_switch_to_nohz() and tick_setup_sched_timer() Frederic Weisbecker
2024-01-25 9:12 ` Thomas Gleixner
2024-01-25 11:57 ` Frederic Weisbecker
2024-01-25 13:34 ` Thomas Gleixner
2024-01-25 14:35 ` Frederic Weisbecker
2024-01-24 17:04 ` [PATCH 02/15] tick/nohz: Remove duplicate between lowres and highres handlers Frederic Weisbecker
2024-01-25 9:32 ` Thomas Gleixner
2024-01-25 11:58 ` Frederic Weisbecker
2024-01-25 13:30 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 03/15] tick: Remove useless oneshot ifdeffery Frederic Weisbecker
2024-01-25 9:32 ` Thomas Gleixner
2024-01-24 17:04 ` Frederic Weisbecker [this message]
2024-01-25 9:33 ` [PATCH 04/15] tick: Use IS_ENABLED() whenever possible Thomas Gleixner
2024-01-24 17:04 ` [PATCH 05/15] tick: s/tick_nohz_stop_sched_tick/tick_nohz_full_stop_tick Frederic Weisbecker
2024-01-25 9:33 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 06/15] tick: No need to clear ts->next_tick again Frederic Weisbecker
2024-01-25 9:33 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 07/15] tick: Start centralizing tick related CPU hotplug operations Frederic Weisbecker
2024-01-25 9:36 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 08/15] tick: Move tick cancellation up to CPUHP_AP_TICK_DYING Frederic Weisbecker
2024-01-25 9:37 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 09/15] tick: Move broadcast " Frederic Weisbecker
2024-01-25 9:38 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 10/15] tick: Assume the tick can't be stopped in NOHZ_MODE_INACTIVE mode Frederic Weisbecker
2024-01-25 9:39 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 11/15] tick: Move got_idle_tick away from common flags Frederic Weisbecker
2024-01-25 9:40 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 12/15] tick: Move individual bit features to debuggable mask accesses Frederic Weisbecker
2024-01-25 9:41 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 13/15] tick: Split nohz and highres features from nohz_mode Frederic Weisbecker
2024-01-25 9:42 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 14/15] tick: Shut down low-res tick from dying CPU Frederic Weisbecker
2024-01-25 9:43 ` Thomas Gleixner
2024-01-24 17:04 ` [PATCH 15/15] tick: Assume timekeeping is correctly handed over upon last offline idle call Frederic Weisbecker
2024-01-25 9:43 ` Thomas Gleixner
-- strict thread matches above, loose matches on Subject: below --
2024-01-31 23:11 [PATCH 00/15 v2] timers/nohz cleanups and hotplug reorganization Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 04/15] tick: Use IS_ENABLED() whenever possible Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240124170459.24850-5-frederic@kernel.org \
--to=frederic@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liupeng17@lenovo.com \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox