lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251204175405.1511340-6-srikar@linux.ibm.com>
Date: Thu,  4 Dec 2025 23:23:53 +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 05/17] pseries/smp: Query and set entitlements

This defines num_available_cores callback for pseries.  On pseries system,
query the hypervisor for hard entitlement using H_GET_PPP hcall. At boot,
soft entitlement(available_cores) is set to the maximum number of virtual
cores in the shared LPAR. In subsequent changes, soft entitlement will be
updated based on steal time. If the number of virtual processors attached to
this LPAR changes, then update entitlements as required. Soft entitilement
will oscillate between hard entitilement and maximum virtual processors
available on the shared LPAR.

Signed-off-by: Srikar Dronamraju <srikar@...ux.ibm.com>
---
 arch/powerpc/platforms/pseries/smp.c | 38 ++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index db99725e752b..a36153c959d0 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -42,6 +42,7 @@
 #include <asm/text-patching.h>
 #include <asm/svm.h>
 #include <asm/kvm_guest.h>
+#include <asm/hvcall.h>
 
 #include "pseries.h"
 
@@ -239,6 +240,40 @@ static __init void pSeries_smp_probe(void)
 	smp_ops->cause_ipi = dbell_or_ic_cause_ipi;
 }
 
+#ifdef CONFIG_PPC_SPLPAR
+static unsigned int max_virtual_cores __read_mostly;
+static unsigned int entitled_cores __read_mostly;
+static unsigned int available_cores;
+
+/* Get pseries soft entitlement limit */
+static unsigned int pseries_num_available_cores(void)
+{
+	unsigned int present_cores = num_present_cpus() / threads_per_core;
+	unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
+
+	if (!is_shared_processor() || is_kvm_guest())
+		return present_cores;
+
+	if (entitled_cores && max_virtual_cores == present_cores)
+		return available_cores;
+
+	if (plpar_hcall9(H_GET_PPP, retbuf))
+		return num_present_cpus() / threads_per_core;
+
+	entitled_cores = retbuf[0] / 100;
+	max_virtual_cores = present_cores;
+
+	if (!available_cores)
+		available_cores = max_virtual_cores;
+	else if (available_cores < entitled_cores)
+		available_cores = entitled_cores;
+	else if (available_cores > max_virtual_cores)
+		available_cores = max_virtual_cores;
+
+	return available_cores;
+}
+#endif
+
 static struct smp_ops_t pseries_smp_ops = {
 	.message_pass	= NULL,	/* Use smp_muxed_ipi_message_pass */
 	.cause_ipi	= NULL,	/* Filled at runtime by pSeries_smp_probe() */
@@ -248,6 +283,9 @@ static struct smp_ops_t pseries_smp_ops = {
 	.kick_cpu	= smp_pSeries_kick_cpu,
 	.setup_cpu	= smp_setup_cpu,
 	.cpu_bootable	= smp_generic_cpu_bootable,
+#ifdef CONFIG_PPC_SPLPAR
+	.num_available_cores = pseries_num_available_cores,
+#endif
 };
 
 /* This is called very early */
-- 
2.43.7


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ