public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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 09/15] tick: Move broadcast cancellation up to CPUHP_AP_TICK_DYING
Date: Thu,  1 Feb 2024 00:11:14 +0100	[thread overview]
Message-ID: <20240131231120.12006-10-frederic@kernel.org> (raw)
In-Reply-To: <20240131231120.12006-1-frederic@kernel.org>

The broadcast shutdown code is executed through a random explicit call
within stop machine from the outgoing CPU.

However the tick broadcast is a midware between the tick callback and
the clocksource, therefore it makes more sense to shut it down after the
tick callback and before the clocksource drivers.

Move it instead to the common tick shutdown CPU hotplug state where
related operations can be ordered from highest to lowest level.

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 include/linux/tick.h        | 6 ------
 kernel/cpu.c                | 2 --
 kernel/time/tick-common.c   | 3 +++
 kernel/time/tick-internal.h | 2 ++
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/include/linux/tick.h b/include/linux/tick.h
index afff4c207bd8..c7840ae8ebaf 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -73,12 +73,6 @@ extern void tick_broadcast_control(enum tick_broadcast_mode mode);
 static inline void tick_broadcast_control(enum tick_broadcast_mode mode) { }
 #endif /* BROADCAST */
 
-#if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) && defined(CONFIG_HOTPLUG_CPU)
-extern void tick_offline_cpu(unsigned int cpu);
-#else
-static inline void tick_offline_cpu(unsigned int cpu) { }
-#endif
-
 #ifdef CONFIG_GENERIC_CLOCKEVENTS
 extern int tick_broadcast_oneshot_control(enum tick_broadcast_state state);
 #else
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 263508073da8..5a8ad4f5ccf3 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1324,8 +1324,6 @@ static int take_cpu_down(void *_param)
 	 */
 	cpuhp_invoke_callback_range_nofail(false, cpu, st, target);
 
-	/* Remove CPU from timer broadcasting */
-	tick_offline_cpu(cpu);
 	/* Park the stopper thread */
 	stop_machine_park(cpu);
 	return 0;
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index b4af8c743b73..522414089c0d 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -412,6 +412,9 @@ int tick_cpu_dying(unsigned int dying_cpu)
 
 	tick_cancel_sched_timer(dying_cpu);
 
+	/* Remove CPU from timer broadcasting */
+	tick_offline_cpu(dying_cpu);
+
 	return 0;
 }
 
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index 481b7ab65e2c..a939ff6de97c 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -137,8 +137,10 @@ static inline bool tick_broadcast_oneshot_available(void) { return tick_oneshot_
 #endif /* !(BROADCAST && ONESHOT) */
 
 #if defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) && defined(CONFIG_HOTPLUG_CPU)
+extern void tick_offline_cpu(unsigned int cpu);
 extern void tick_broadcast_offline(unsigned int cpu);
 #else
+static inline void tick_offline_cpu(unsigned int cpu) { }
 static inline void tick_broadcast_offline(unsigned int cpu) { }
 #endif
 
-- 
2.43.0


  parent reply	other threads:[~2024-01-31 23:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31 23:11 [PATCH 00/15 v2] timers/nohz cleanups and hotplug reorganization Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 01/15] tick/nohz: Remove duplicate between tick_nohz_switch_to_nohz() and tick_setup_sched_timer() Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 02/15] tick/nohz: Remove duplicate between lowres and highres handlers Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 03/15] tick: Remove useless oneshot ifdeffery Frederic Weisbecker
2024-02-01  9:40   ` Anna-Maria Behnsen
2024-02-01 13:16     ` Frederic Weisbecker
2024-02-01 14:04       ` Anna-Maria Behnsen
2024-01-31 23:11 ` [PATCH 04/15] tick: Use IS_ENABLED() whenever possible Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 05/15] tick: s/tick_nohz_stop_sched_tick/tick_nohz_full_stop_tick Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 06/15] tick: No need to clear ts->next_tick again Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 07/15] tick: Start centralizing tick related CPU hotplug operations Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 08/15] tick: Move tick cancellation up to CPUHP_AP_TICK_DYING Frederic Weisbecker
2024-01-31 23:11 ` Frederic Weisbecker [this message]
2024-01-31 23:11 ` [PATCH 10/15] tick: Assume the tick can't be stopped in NOHZ_MODE_INACTIVE mode Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 11/15] tick: Move got_idle_tick away from common flags Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 12/15] tick: Move individual bit features to debuggable mask accesses Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 13/15] tick: Split nohz and highres features from nohz_mode Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 14/15] tick: Shut down low-res tick from dying CPU Frederic Weisbecker
2024-01-31 23:11 ` [PATCH 15/15] tick: Assume timekeeping is correctly handed over upon last offline idle call Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2024-01-24 17:04 [PATCH 00/15] timers/nohz cleanups and hotplug reorganization Frederic Weisbecker
2024-01-24 17:04 ` [PATCH 09/15] tick: Move broadcast cancellation up to CPUHP_AP_TICK_DYING Frederic Weisbecker
2024-01-25  9:38   ` Thomas Gleixner

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=20240131231120.12006-10-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