[RFC PATCH v4 12/17] powerpc: method to initialize ec and vp cores
Shrikanth Hegde
sshegde at linux.ibm.com
Wed Nov 19 17:20:55 AEDT 2025
During system init, capture the number of EC and VP cores on Shared
Processor LPARs(aka VM). (SPLPAR )
EC - Entitled Cores - Hypervisor(PowerVM) guarantees this many cores
worth of cycles.
VP - Virtual Processor Cores - Total logical cores present in the LPAR.
In SPLPAR's typically there is overcommit of vCPUs. i.e VP > EC.
These values will be used in subsequent patches to calculate number of
cores to use when there is steal time.
Note: DLPAR specific method need to call this again. Yet to be done.
Originally-by: Srikar Dronamraju <srikar at linux.ibm.com>
Signed-off-by: Shrikanth Hegde <sshegde at linux.ibm.com>
---
arch/powerpc/include/asm/smp.h | 1 +
arch/powerpc/kernel/smp.c | 1 +
arch/powerpc/platforms/pseries/lpar.c | 30 +++++++++++++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index e41b9ea42122..5a52c6952195 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -266,6 +266,7 @@ extern char __secondary_hold;
extern unsigned int booting_thread_hwid;
extern void __early_start(void);
+void pseries_init_ec_vp_cores(void);
#endif /* __ASSEMBLER__ */
#endif /* __KERNEL__ */
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 68edb66c2964..5a3b52dd625b 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1732,6 +1732,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
dump_numa_cpu_topology();
build_sched_topology();
+ pseries_init_ec_vp_cores();
}
/*
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 6a415febc53b..935fced6e127 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -2029,3 +2029,33 @@ static int __init vpa_debugfs_init(void)
}
machine_arch_initcall(pseries, vpa_debugfs_init);
#endif /* CONFIG_DEBUG_FS */
+
+#ifdef CONFIG_PARAVIRT
+
+static unsigned int virtual_procs __read_mostly;
+static unsigned int entitled_cores __read_mostly;
+static unsigned int available_cores;
+
+void pseries_init_ec_vp_cores(void)
+{
+ unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
+ int ret;
+
+ if (available_cores && virtual_procs == num_present_cpus() / threads_per_core)
+ return;
+
+ /* Get EC values from hcall */
+ ret = plpar_hcall9(H_GET_PPP, retbuf);
+ WARN_ON_ONCE(ret != 0);
+ if (ret)
+ return;
+
+ entitled_cores = retbuf[0] / 100;
+ virtual_procs = num_present_cpus() / threads_per_core;
+
+ /* Initialize the available cores to all VP initially */
+ available_cores = max(entitled_cores, virtual_procs);
+}
+#else
+void pseries_init_ec_vp_cores(void) { return; }
+#endif
--
2.47.3
More information about the Linuxppc-dev
mailing list