Thread (10 messages) 10 messages, 7 authors, 2025-12-27

Re: [PATCH v2] powerpc/kexec: Enable SMT before waking offline CPUs

From: Nysal Jan K.A. <hidden>
Date: 2025-10-29 03:37:02
Also in: lkml, stable

hi Shrikanth,

On Tue, Oct 28, 2025 at 10:56:05PM +0530, Shrikanth Hegde wrote:
Hi Nysal.

On 10/28/25 4:25 PM, Nysal Jan K.A. wrote:
[snip]
quoted
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -202,6 +202,23 @@ static void kexec_prepare_cpus_wait(int wait_state)
  	mb();
  }
+
+/*
+ * The add_cpu() call in wake_offline_cpus() can fail as cpu_bootable()
+ * returns false for CPUs that fail the cpu_smt_thread_allowed() check
+ * or non primary threads if SMT is disabled. Re-enable SMT and set the
+ * number of SMT threads to threads per core.
+ */
+static void kexec_smt_reenable(void)
+{
+#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
+	lock_device_hotplug();
I was looking at usage of lock_device_hotplug, looks like a good candidate for
guard() use case. Could be done on its own patch/series.
Agree, we can look at it as a separate patch.
quoted
+	cpu_smt_num_threads = threads_per_core;
+	cpu_smt_control = CPU_SMT_ENABLED;
+	unlock_device_hotplug();
+#endif
+}

Will this work too? It might be better since we anyway going to bring that CPU up
by doing add_cpu afterwords.

	cpu_smt_num_threads = threads_per_core;
	cpuhp_smt_enable()
There is some reasoning in 4d37cc2dc3df, which made the switch to use the core
device API, against calling cpu_up() directly. The other issue is 
cpuhp_smt_enable() can skip bringing up a CPU in certain cases, for example
when a core is offline.
quoted
+
  /*
   * We need to make sure each present CPU is online.  The next kernel will scan
   * the device tree and assume primary threads are online and query secondary
@@ -216,6 +233,8 @@ static void wake_offline_cpus(void)
  {
  	int cpu = 0;
+	kexec_smt_reenable();
+
If we do above, just change the below logic to complain if any present CPU is offline.
quoted
  	for_each_present_cpu(cpu) {
  		if (!cpu_online(cpu)) {
  			printk(KERN_INFO "kexec: Waking offline cpu %d.\n",
Thanks for the review.

--Nysal
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help