From nobody Tue Dec 2 02:29:42 2025 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CACE731813A for ; Wed, 19 Nov 2025 06:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763533376; cv=none; b=h3p5aGlIy98fyNqRTrr1jNOQYdv08bBt1GwkSA3f6kkbvXaA0UCnMEqxUKT6HIMM8/D//3dXdpejjEkaoJo0snbdLojykBHBtW6nEMJLahOXBAWiY5PgYiDMNFlDyxvnX6709W4u2czlGqmmOxKCXn42gxWhsfKHwXMd775i/wE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763533376; c=relaxed/simple; bh=ZWFiw1WkjitXmooiWdi6xgpQBNIjAv38fadGk/gbT6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tpRPy1pBYzfs9CaquV7oQX9xn1jfDb7bwy/nukvDmgB4Kti24uJwsWc1IYxyokWHnXD0xiS0eAI7RgBt/UYo679UmZmIueReMQ25E7YSNTRNEUAcffcwpoq8HKwQTSSgaWRjl2JhPNyk6elUhSRJZ0RyqAOVn9Njqy4NwHkbnjM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Wtw4idbn; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Wtw4idbn" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AIH95Yx007244; Wed, 19 Nov 2025 06:22:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=wOwoUo4qjbz//wAJI 96uYffqcZQY/DCaFaTR3O887dM=; b=Wtw4idbn4IYj5jGfbb4fOYkFE1PIHnkWh 1SvLlL2uuykmB5q21yUGvuysUV+SYX8Dn2iXGDveyq/LzTpE3Cwi7J9A+UzB4CuL aCB6HUQ0yLmyeXYSErWN5EHKAoG2z16IqmlM5J+8iYrOdse4W3d7MHRjZuV9k4PD g1jXCFPaR3hBGgIXxoaZ1ToqF+DuW5FWBSFYpXCrAx5JWxcAWvoXjFqr9foWoJjD bYyLr3AfCcWHHQAqcfzoXovEMifnrDPP8JB3wLpWjXSyh3rfQV0G2KCc96VeqahN ZyZTDB8sVRU0fzo8RtfUegfftyCjU54lVVO6i/jE67P9h1ILDKFTg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aejmsp753-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 06:22:28 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5AJ6FcPM021942; Wed, 19 Nov 2025 06:22:27 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aejmsp750-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 06:22:27 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5AJ3nIk4022386; Wed, 19 Nov 2025 06:22:26 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4af4umy582-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 06:22:26 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5AJ6MMtG42533180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 06:22:22 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B4A6020043; Wed, 19 Nov 2025 06:22:22 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CDDBC20040; Wed, 19 Nov 2025 06:22:18 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.25.220]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 19 Nov 2025 06:22:18 +0000 (GMT) From: Shrikanth Hegde To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: sshegde@linux.ibm.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, tglx@linutronix.de, yury.norov@gmail.com, maddy@linux.ibm.com, srikar@linux.ibm.com, gregkh@linuxfoundation.org, pbonzini@redhat.com, seanjc@google.com, kprateek.nayak@amd.com, vschneid@redhat.com, iii@linux.ibm.com, huschle@linux.ibm.com, rostedt@goodmis.org, dietmar.eggemann@arm.com, christophe.leroy@csgroup.eu Subject: [RFC PATCH v4 12/17] powerpc: method to initialize ec and vp cores Date: Wed, 19 Nov 2025 11:50:55 +0530 Message-ID: <20251119062100.1112520-13-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251119062100.1112520-1-sshegde@linux.ibm.com> References: <20251119062100.1112520-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: RcA5oI_GTH1HZ8tTpOCw9BrZ-01IWvyE X-Authority-Analysis: v=2.4 cv=Rv3I7SmK c=1 sm=1 tr=0 ts=691d6224 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=hFzEoIDDEV05iifXiegA:9 X-Proofpoint-GUID: _YD4V2LkBDLl101SYN0komU049C5iWlc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMiBTYWx0ZWRfX+KLvdG9ORbST E+g1yERHe1xU4vPcbdY6y7T6h8loNAy4QJMO90KuBGCj/bNrkJbwJqgHxScLR4YZ7XKyYFsFsMU 5XdHcRSDd2hxM+QYeJW5kksU28pXhVXAkjT+bb77M/oEy7wZ0+MU4whjcz+Khm4x78RF5EHbFiF Uyv3cS/ew4EoURYVntzasDp0/yNZMf34BN2GjLWVqbDxwSpV+2Hy1mJx0TimlObatXfYyNeUeWz ycQfYdK+f1C0JZSNaXFBK8O6+2XLGWnpwt4+b8gLkb1q2vgRApKGatusrQvCR11RKdT/rIKQLEy Hku15Q/L39yc/wZMTB9hNnrExPTyHYEtudN99r1AgZID94/TUzdtJzGFBGaUL3AMf/Pv+G1xDxN 1hdxOj634J3I4MCUvoBz+7V3Uc55Jg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-19_01,2025-11-18_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 clxscore=1015 phishscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511150032 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Shrikanth Hegde --- 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; =20 extern void __early_start(void); +void pseries_init_ec_vp_cores(void); #endif /* __ASSEMBLER__ */ =20 #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) =20 dump_numa_cpu_topology(); build_sched_topology(); + pseries_init_ec_vp_cores(); } =20 /* 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 =3D=3D num_present_cpus() / threads_= per_core) + return; + + /* Get EC values from hcall */ + ret =3D plpar_hcall9(H_GET_PPP, retbuf); + WARN_ON_ONCE(ret !=3D 0); + if (ret) + return; + + entitled_cores =3D retbuf[0] / 100; + virtual_procs =3D num_present_cpus() / threads_per_core; + + /* Initialize the available cores to all VP initially */ + available_cores =3D max(entitled_cores, virtual_procs); +} +#else +void pseries_init_ec_vp_cores(void) { return; } +#endif --=20 2.47.3