[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251204175405.1511340-12-srikar@linux.ibm.com>
Date: Thu, 4 Dec 2025 23:23:59 +0530
From: Srikar Dronamraju <srikar@...ux.ibm.com>
To: linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
Peter Zijlstra <peterz@...radead.org>
Cc: Ben Segall <bsegall@...gle.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Ingo Molnar <mingo@...nel.org>, Juri Lelli <juri.lelli@...hat.com>,
K Prateek Nayak <kprateek.nayak@....com>,
Madhavan Srinivasan <maddy@...ux.ibm.com>,
Mel Gorman <mgorman@...e.de>, Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>,
Shrikanth Hegde <sshegde@...ux.ibm.com>,
Srikar Dronamraju <srikar@...ux.ibm.com>,
Steven Rostedt <rostedt@...dmis.org>,
Swapnil Sapkal <swapnil.sapkal@....com>,
Thomas Huth <thuth@...hat.com>,
Valentin Schneider <vschneid@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
virtualization@...ts.linux.dev, Yicong Yang <yangyicong@...ilicon.com>,
Ilya Leoshkevich <iii@...ux.ibm.com>
Subject: [PATCH 11/17] pseries/smp: Create soft offline infrastructure for Powerpc shared LPARs.
Create an infrastructure that uses Linux scheduler's new soft
online/offline infrastructure to temporarily enable and disable CPUs.
This utilizes the workqueue mechanism to activate worker functions to
online/offline CPUs as and when requested.
Signed-off-by: Srikar Dronamraju <srikar@...ux.ibm.com>
---
arch/powerpc/platforms/pseries/smp.c | 39 ++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index a36153c959d0..ec1af13670f2 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -122,6 +122,42 @@ static inline int smp_startup_cpu(unsigned int lcpu)
return 1;
}
+#ifdef CONFIG_PPC_SPLPAR
+struct offline_worker {
+ struct work_struct work;
+ int offline;
+ int cpu;
+};
+
+static DEFINE_PER_CPU(struct offline_worker, offline_workers);
+
+static void softoffline_work_fn(struct work_struct *work)
+{
+ struct offline_worker *worker = this_cpu_ptr(&offline_workers);
+
+ set_cpu_softoffline(worker->cpu, worker->offline);
+}
+
+static void softoffline_work_init(void)
+{
+ int cpu;
+
+ if (!is_shared_processor() || is_kvm_guest())
+ return;
+
+ for_each_possible_cpu(cpu) {
+ struct offline_worker *worker = &per_cpu(offline_workers, cpu);
+
+ INIT_WORK(&worker->work, softoffline_work_fn);
+ worker->cpu = cpu;
+ }
+}
+#else
+static void softoffline_work_init(void)
+{
+}
+#endif
+
static void smp_setup_cpu(int cpu)
{
if (xive_enabled())
@@ -260,6 +296,9 @@ static unsigned int pseries_num_available_cores(void)
if (plpar_hcall9(H_GET_PPP, retbuf))
return num_present_cpus() / threads_per_core;
+ if (!entitled_cores)
+ softoffline_work_init();
+
entitled_cores = retbuf[0] / 100;
max_virtual_cores = present_cores;
--
2.43.7
Powered by blists - more mailing lists