From nobody Sun Feb 8 01:31:26 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 CAA7B352FB7 for ; Thu, 4 Dec 2025 17:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870963; cv=none; b=aIkgmPQcnTzRfAVTIy9NWby2KM1ugI8O6zVWfriYA1CvpUihcLqnhVcmhos8nJSS8mta7DQiUOtdoAd1VhiMatRqLCvaTCEt/j8ZU9zm2W8LKfzW2F718zTRWrzi1iHvOPoGl9N89sacLIl/46NbkTrha7EoJwFeo/K+qUV9Exo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870963; c=relaxed/simple; bh=UsJjbkrA1yFknceQNtrGoMEFEsPTGlFYNCNU21QGB2I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bPY+sluWKxkHXhY6j57OuyZtWkz6960AYNIqhvw7eT6B1oDRxQgo05RIm2hO5j+CniPjRBXcMMvcuA8QSVDhg0unsK4cgZW4n+6CxjvJhSqQaxdEWXIVlx8myrI2LITqlWOiZJYcFhB0niSyqknkuCUuJ27kDROmK9kT5fu/Wnc= 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=dSz3Qteo; arc=none smtp.client-ip=148.163.156.1 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="dSz3Qteo" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4EhQnB026734; Thu, 4 Dec 2025 17:55:23 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=C6cLDbx1EBc/TgbiE 7lRqMqL23tRUH4UTqj083YxY7I=; b=dSz3QteoZihaY3G63NlGo3QkcuW2nD2wm JsgDWdWJbOrEw0GjWOtKVfz2vobB5UCWaKVuLYBIHAEkYXp9rKZ6mNXrexb2k+fl rD6ffuU4Q57Y7FZGd6A7YMK0QV34jf0Io+RpI9M+TKtQT42YhNP/nNcmpDBvJAmu mS3YcMeUJ/s5+yURNVoQRt4sbxHz35giM/XoSsUE9OAASjUJN3kkQNPVk+rLw7Ou 71ws1NM1/8LwI3/Ge8+SNVJ+bkqaeDhotK4d2rW6cMqviSPO9JTu4+a1/1FIdFBT RAUnY9XjZhklNhQMCP4ndbRYSbh6w0ZYP0dnfTh08tg9nMNyUIn+Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrh79vs1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:23 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4Hg50o026211; Thu, 4 Dec 2025 17:55:22 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 4aqrh79vrw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:22 +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 5B4GHegC021731; Thu, 4 Dec 2025 17:55:21 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4at8c6jb88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:21 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HtHg536176220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:17 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 501FF20043; Thu, 4 Dec 2025 17:55:17 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD5CF20040; Thu, 4 Dec 2025 17:55:13 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:13 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 01/17] sched/fair: Enable group_asym_packing in find_idlest_group Date: Thu, 4 Dec 2025 23:23:49 +0530 Message-ID: <20251204175405.1511340-2-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Authority-Analysis: v=2.4 cv=dK+rWeZb c=1 sm=1 tr=0 ts=6931cb0b cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=ckJkcgXifS0MwuEMmiIA:9 X-Proofpoint-GUID: p4N8cC9Ej_pjMTdg3tr_-fwWHO81rS5E X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX0K8Nzru4dAWO R21IXfvwbKS6T23j3HTsfBhZDUgKtDtSPvyQwaLvwmvQoWurdWjAK1orhWzXRb6zLZkMkqtagbh cwQQSnroNmxxRlKg5UpvOyEFMz71lfnTcFvu+LsFfltRoXaEBU6S4ogQySOieivCEEaswIQkoyr 6N1yeWfz8uPTXAD2Z0/bzmRK7eqh96GJYdOrhiIgGZwHSeDQhoa/YUQBNsz4w0i8L91ha7qCUCU J1A7miRZn29e9BCBXq11G1DzPLzNJKPoN8KO3NPfL75CFcykn1lNsswjHJC0lLz1tsmsOtjFFzY Pgh2RdtQUmwSSC2lum0ojc2AloRjrQt1SEGN191igbdM3zJq5+kQa+fxBZAFlJWaiIwf6vYaWgK xPCRX7MjiFjLn/yXO3dMMSVh3KfXow== X-Proofpoint-ORIG-GUID: 343_fIdgCxRbnqSTtODuZ3sGy1Qu_OmJ 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 clxscore=1011 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" Current scheduler code doesn't handle SD_ASYM_PACKING in the find_idlest_cpu path. On few architectures, like Powerpc, cache is at a core. Moving threads across cores may end up in cache misses. While asym_packing can be enabled above SMT level, enabling Asym packing across cores could result in poorer performance due to cache misses. However if the initial task placement via find_idlest_cpu does take asym_packing into consideration, then scheduler can avoid asym_packing migrations. This will result in lesser migrations and better packing and better overall performance. Previous version was posted at https://lore.kernel.org/all/20231018155036.2314342-1-srikar@linux.vnet.ibm.= com/t Signed-off-by: Srikar Dronamraju --- kernel/sched/fair.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5b752324270b..979c3e333fba 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10664,11 +10664,13 @@ static int idle_cpu_without(int cpu, struct task_= struct *p) * @group: sched_group whose statistics are to be updated. * @sgs: variable to hold the statistics for this group. * @p: The task for which we look for the idlest group/CPU. + * @this_cpu: current cpu */ static inline void update_sg_wakeup_stats(struct sched_domain *sd, struct sched_group *group, struct sg_lb_stats *sgs, - struct task_struct *p) + struct task_struct *p, + int asym_prefer_cpu) { int i, nr_running; =20 @@ -10705,6 +10707,12 @@ static inline void update_sg_wakeup_stats(struct s= ched_domain *sd, =20 } =20 + if (asym_prefer_cpu !=3D READ_ONCE(group->asym_prefer_cpu) && + sched_asym(sd, READ_ONCE(group->asym_prefer_cpu), + READ_ONCE(asym_prefer_cpu))) { + sgs->group_asym_packing =3D 1; + } + sgs->group_capacity =3D group->sgc->capacity; =20 sgs->group_weight =3D group->group_weight; @@ -10721,7 +10729,8 @@ static inline void update_sg_wakeup_stats(struct sc= hed_domain *sd, sgs->group_capacity; } =20 -static bool update_pick_idlest(struct sched_group *idlest, +static bool update_pick_idlest(struct sched_domain *sd, + struct sched_group *idlest, struct sg_lb_stats *idlest_sgs, struct sched_group *group, struct sg_lb_stats *sgs) @@ -10745,8 +10754,11 @@ static bool update_pick_idlest(struct sched_group = *idlest, return false; break; =20 - case group_imbalanced: case group_asym_packing: + return sched_asym(sd, READ_ONCE(group->asym_prefer_cpu), + READ_ONCE(idlest->asym_prefer_cpu)); + + case group_imbalanced: case group_smt_balance: /* Those types are not used in the slow wakeup path */ return false; @@ -10790,6 +10802,7 @@ sched_balance_find_dst_group(struct sched_domain *s= d, struct task_struct *p, int .avg_load =3D UINT_MAX, .group_type =3D group_overloaded, }; + int asym_prefer_cpu; =20 do { int local_group; @@ -10812,10 +10825,12 @@ sched_balance_find_dst_group(struct sched_domain = *sd, struct task_struct *p, int } else { sgs =3D &tmp_sgs; } + if (!local || local_group) + asym_prefer_cpu =3D READ_ONCE(group->asym_prefer_cpu); =20 - update_sg_wakeup_stats(sd, group, sgs, p); + update_sg_wakeup_stats(sd, group, sgs, p, asym_prefer_cpu); =20 - if (!local_group && update_pick_idlest(idlest, &idlest_sgs, group, sgs))= { + if (!local_group && update_pick_idlest(sd, idlest, &idlest_sgs, group, s= gs)) { idlest =3D group; idlest_sgs =3D *sgs; } @@ -10845,6 +10860,14 @@ sched_balance_find_dst_group(struct sched_domain *= sd, struct task_struct *p, int if (local_sgs.group_type > idlest_sgs.group_type) return idlest; =20 + if (idlest_sgs.group_type =3D=3D group_asym_packing) { + if (sched_asym(sd, READ_ONCE(idlest->asym_prefer_cpu), + READ_ONCE(local->asym_prefer_cpu))) { + return idlest; + } + return NULL; + } + switch (local_sgs.group_type) { case group_overloaded: case group_fully_busy: --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 31A7E355034 for ; Thu, 4 Dec 2025 17:56:04 +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=1764870971; cv=none; b=Vr4mb3I9bUR1n7loU5LY5v1Rb1BRBw9ug8WPUsPbO8e8x8ZQ78082zZiMjTbfueyTNrP3G6p9CjILI4byx5SjWLB+WW6FbtgYcuXV7uCiNA97z/jlAtbI56BPJuZPuVhBq33ep78uNUE6otdjm6coalETam0ekLW4Ew2JDQHE3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870971; c=relaxed/simple; bh=pOfRnL8M589Hvunwaq/C5RBx/uts33gTbrAoqF30fp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VN9FDdSv2QbKl23fYyZFz+J5N8ETTkSzwh4x5vfGdCmmDwC6L9iE3BOPvpCeXkS1RAeHIQflDO6cLP86gLyORocIrjnqaetVjy8TnN0yeq6SWZrU/QDCHPQQhZ20FDBdswaZWP+i7F3TtpS0GbgblJKXJaJHVoRH1fSO2LZWABg= 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=na0PXfMC; 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="na0PXfMC" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4E8tkP001931; Thu, 4 Dec 2025 17:55:26 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=cGvV2EyuoGRv/Qbas Iead7YLzTxiH5r0RDBU1Y5c1ew=; b=na0PXfMCOj4egkHS1AnM7MZa/zFKanMzf OTOOSSeoxyEENcBNpcH3g4m8dpLW5Y07z1BhlJLaQi79U7B4aMcXRvGUjc476nvM Ygh+0Vyv8cb0/J1p0Aq4c6vhwY8RV9xclDpwGZ5BbeCkmmxeDzeNTd8i7sdwcdav QdLOU00hqeOXb76ghAO1uqZcrf67tHt82jC7HJiSqNXgE+npZiRC4icEUcWeUL2S YEt9jMaO1t5tOLyGyi7Vcsp25z+LMoOJkOCKFTiy+5dC+h4ssXQx+Hn26JRaffoU cqDJ7rRZ7qKjWqexrXk3Z1zVLOBnbij3grnkSqQzqv7leZl16tGCg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:26 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4HfL8g021218; Thu, 4 Dec 2025 17:55:26 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e35-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:26 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4FGjN4010284; Thu, 4 Dec 2025 17:55:25 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arcnkh2r6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:25 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HtL5S22479462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:21 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27E9720043; Thu, 4 Dec 2025 17:55:21 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 950C720040; Thu, 4 Dec 2025 17:55:17 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:17 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 02/17] powerpc/lpar: Reorder steal accounting calculation Date: Thu, 4 Dec 2025 23:23:50 +0530 Message-ID: <20251204175405.1511340-3-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfX9sEvZAI+B/Jc nMnAj/OgAv6Xv/l0nKq5wp+q+tELpkIfT7Hat1oHlo6S3/jfWq2SGjbcr1eV1/z2htIk/Om44DG bXN9MTsSTcCDxh7DTy5TS0bt+yl4k9OlXGfV0iD3YJStOigQref0ykS1peL4aVal4OsW8eGQ1o+ LmOwmkXIKz03eUauY/I3Kq0o8a4CpYKTDkJBgksA/GpR6svaxbn1ArPqhNmZWFLi6fOWHY6gb4T PcvL3jkgj9lx2AiD/MvMzaG+BDpLZ/AjGbZbCZ1wg86aefrkC68ob9fzp6/nqPpOyeIgyKoE1Rt KHrKaD+h17D0eT62iuVt8HkzSJme1YHgviRrGX4mmaFltB34j84HBUlr3WK0m3TJ5t7AxybETnK tatfJNRNH+oLgQOFZ3MQVjCesECOUw== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=6931cb0e cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=e-Ya-t4VmWCOyrdcCoEA:9 X-Proofpoint-ORIG-GUID: YlIRh_9WmKkJVYFswaUNP2EkDVsRXSDq X-Proofpoint-GUID: kVUXudLvu6logZnZqfTueeVQHP8bpJho 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1011 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 Content-Type: text/plain; charset="utf-8" There is no functional change. Calculated steal could be used in the subsequent changes. Hence reordering the function. Signed-off-by: Srikar Dronamraju --- arch/powerpc/platforms/pseries/lpar.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms= /pseries/lpar.c index 6a415febc53b..dde12b27ba60 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -662,15 +662,20 @@ machine_device_initcall(pseries, vcpudispatch_stats_p= rocfs_init); u64 pseries_paravirt_steal_clock(int cpu) { struct lppaca *lppaca =3D &lppaca_of(cpu); + unsigned long steal; + + steal =3D be64_to_cpu(READ_ONCE(lppaca->ready_enqueue_tb)); + steal +=3D be64_to_cpu(READ_ONCE(lppaca->enqueue_dispatch_tb)); =20 /* * VPA steal time counters are reported at TB frequency. Hence do a - * conversion to ns before returning + * conversion to ns before using. */ - return tb_to_ns(be64_to_cpu(READ_ONCE(lppaca->enqueue_dispatch_tb)) + - be64_to_cpu(READ_ONCE(lppaca->ready_enqueue_tb))); + steal =3D tb_to_ns(steal); + + return steal; } -#endif +#endif /* CONFIG_PARAVIRT_TIME_ACCOUNTING */ =20 #endif /* CONFIG_PPC_SPLPAR */ =20 --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 23CEE354AC8 for ; Thu, 4 Dec 2025 17:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870968; cv=none; b=qz75bPkJivCJxqWP9gGYYzsV86EOiWA3R0V30Cer7D/ZOxACUmvXfQR/tTIqh/YNDFohTkPMX1Kegta6xEK2p0U7jI3egoB308tYxpCTEoVqDzoHVlBWUskse5I1Q1fIhxMgDpivYEZixMdEJSckw7B+fZ5FWWZb+yw9he/+Chs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870968; c=relaxed/simple; bh=cuiNxgDnkjMr3+t6t512SY9lSI9f9xq66dsB7a+A0dY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eKRotVPfd60CBt4JpfWntBLfpKQfoLmpXk7jy7cNVtOp+gnwO6CDjtmDYZNXf7+Douf6XnDwExf0uAjSPi7F5EJ0HuVJIbc5t4pJSRKLwEruf+zYwt7omVwwcUqfmpj0qbz8UQwDsGtgawQsOCxAp26BcyBLT91vBQe4VyDmV7s= 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=g6jtrhxD; arc=none smtp.client-ip=148.163.156.1 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="g6jtrhxD" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4Daton006081; Thu, 4 Dec 2025 17:55:30 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=fbQTfFT/PIPbdoYiC V2JGcsZoVdZC5l+iaIv04MhFIc=; b=g6jtrhxDMWL2mCmJjhdrCXUTtYgiZ2jje xa8TLgQeeOjj6VIXl4Axtj5H00h7qbjf35EDzJvDmvLxLDnSeopz+B13YvWscG6I c66M3wiKToMhZobGSc1hTvzk/QFK2+MnLWZs+sZ0TFLyfgsfMFUTvPbYR7LOIWRk 8Qt3OkUyVPnRwfPdAezYHOjv2yaUHD+zEaH9NGNO/dPBCdQcedY2Arwv+hDRgOdj liqtdF1fQAdh95hnZeFY7JA3Nf3TzoGXhYB9sKw2YC6H8vqP5p1zvkpU0TXWgxAd jTu+joylfvP8c7jFcqNkGCuYAMWe5xvR1v89YREU5jVgW2UztaQwQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja1t8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:30 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4Hmgc7028947; Thu, 4 Dec 2025 17:55:29 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja1t8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:29 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4FtTO4003864; Thu, 4 Dec 2025 17:55:28 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardck0x3s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:28 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HtPLj52167138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:25 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EAB522004D; Thu, 4 Dec 2025 17:55:24 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70F7120040; Thu, 4 Dec 2025 17:55:21 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:21 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 03/17] pseries/lpar: Process steal metrics Date: Thu, 4 Dec 2025 23:23:51 +0530 Message-ID: <20251204175405.1511340-4-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-GUID: PDJchYl4t_BHLdsDo034nr6fkaKJRJgb X-Proofpoint-ORIG-GUID: pUgg4ZLiPm4NqPH0eoO3lYS8onZPQH9L X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX9zF4ujQNz521 84jncEtnzCSCFqxbljRwBhkCsp3heo2acBrr+U0mind6N9vR3kKOUUgkb1oQNo3et4ed4DKlI8g wljpwmIlD0CV3SzhmhKC/3CKcLkjnCq9lZJdv4+docEOlAI9sCUWEndlqMO/nzFn6vvf8gZ171l HH1B+SnJIj49oVxx7pvzNiawdHUUxhjOJ4uT2+5e1qI/6Bu9OyWgkQL8Z70I2rF/lR/Oa7firoZ +KkIZyiJQUE4FmQUZBHYtDk4iF+5l0ma0EsvxhP3y4H+lq/MlpU8ZLNJry898p9aB5rB2b0hYFr X+kNGKKtEls0AsZ4J5V4yPj6DE0PCtpyNejjhJm/50Ho0bqBpRW9fqhkibatUpjyiGn4iq6NpIa 6/CAZJOHisobPOdgcu7UgTlVg7GbZQ== X-Authority-Analysis: v=2.4 cv=dYGNHHXe c=1 sm=1 tr=0 ts=6931cb12 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=_esyMj-MSB3OpN4JKqEA:9 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 suspectscore=0 clxscore=1011 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" Based on steal metrics, find the ratio of current runtime to steal. This ratio would further be used to soft offline/online the core. Steal above a limit would indicate that there is more contention on cores and hence few cores would be soft-offlined. Steal below a limit would indicate that there are probably available cores and hence few cores would be soft-onlined. Currently only the first online CPU will calculate the steal and even this CPU will process steal metrics at a 1 second granularity. Also currently this steal processing is enabled on non-KVM shared logical partitions. Since the steal time would be portion of the processor's runtime, use a multiple to bump up the steal time so that its easier to compare with limits. Signed-off-by: Srikar Dronamraju --- arch/powerpc/platforms/pseries/lpar.c | 50 ++++++++++++++++++++++++ arch/powerpc/platforms/pseries/pseries.h | 4 ++ 2 files changed, 54 insertions(+) diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms= /pseries/lpar.c index dde12b27ba60..3431730a10ea 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -659,6 +659,53 @@ static int __init vcpudispatch_stats_procfs_init(void) machine_device_initcall(pseries, vcpudispatch_stats_procfs_init); =20 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING +#define STEAL_MULTIPLE (STEAL_RATIO * STEAL_RATIO) +#define PURR_UPDATE_TB tb_ticks_per_sec + +static void trigger_softoffline(unsigned long steal_ratio) +{ +} + +static bool should_cpu_process_steal(int cpu) +{ + if (cpu =3D=3D cpumask_first(cpu_online_mask)) + return true; + + return false; +} + +static void process_steal(int cpu) +{ + static unsigned long next_tb, prev_steal; + unsigned long steal_ratio, delta_tb; + unsigned long tb =3D mftb(); + unsigned long steal =3D 0; + unsigned int i; + + if (!should_cpu_process_steal(cpu)) + return; + + if (tb < next_tb) + return; + + for_each_online_cpu(i) { + struct lppaca *lppaca =3D &lppaca_of(i); + + steal +=3D be64_to_cpu(READ_ONCE(lppaca->ready_enqueue_tb)); + steal +=3D be64_to_cpu(READ_ONCE(lppaca->enqueue_dispatch_tb)); + } + + if (next_tb && prev_steal) { + delta_tb =3D max(tb - (next_tb - PURR_UPDATE_TB), 1); + steal_ratio =3D (steal - prev_steal) * STEAL_MULTIPLE; + steal_ratio /=3D (delta_tb * num_online_cpus()); + trigger_softoffline(steal_ratio); + } + + next_tb =3D tb + PURR_UPDATE_TB; + prev_steal =3D steal; +} + u64 pseries_paravirt_steal_clock(int cpu) { struct lppaca *lppaca =3D &lppaca_of(cpu); @@ -667,6 +714,9 @@ u64 pseries_paravirt_steal_clock(int cpu) steal =3D be64_to_cpu(READ_ONCE(lppaca->ready_enqueue_tb)); steal +=3D be64_to_cpu(READ_ONCE(lppaca->enqueue_dispatch_tb)); =20 + if (is_shared_processor() && !is_kvm_guest()) + process_steal(cpu); + /* * VPA steal time counters are reported at TB frequency. Hence do a * conversion to ns before using. diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platfo= rms/pseries/pseries.h index 3968a6970fa8..68cf25152870 100644 --- a/arch/powerpc/platforms/pseries/pseries.h +++ b/arch/powerpc/platforms/pseries/pseries.h @@ -26,6 +26,10 @@ void pSeries_machine_check_log_err(void); #ifdef CONFIG_SMP extern void smp_init_pseries(void); =20 +#ifdef CONFIG_PPC_SPLPAR +#define STEAL_RATIO 100 +#endif + /* Get state of physical CPU from query_cpu_stopped */ int smp_query_cpu_stopped(unsigned int pcpu); #define QCSS_STOPPED 0 --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 691E63559E8 for ; Thu, 4 Dec 2025 17:56:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870975; cv=none; b=F8QNgcKHqAAvPi1BwOUgbsLEQP6Xx0jin0o0HM+3BSs9PeZpEPRXvV+HNSiKudClwS0XoLdDFU35G0CN6Aqs3Lb0cL+G8vDHI7l87IFPNVXXB3Py4k+ON/Oy4x2rwNfkU99HlDxYQKDb9/FQCIT+b3g4/uqxu4GPcnfn0KHHxsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870975; c=relaxed/simple; bh=1b1aJGj/nmcXXvsdCm04uLzpI2p/2ikLE/n2dRlWVUs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MesCyAkfiq46Py552gYf8q8+CBo+6txDeWDc9x2TRAEhJE1CubTYLtDF6YonoURvXfjl1WE3XFABnKPe5lWkiHF+pfNYOHrcNHbY+STJfKu6Gm+RqyPXHxYUuas+jcbdlgCsgOpfQRaBOzWAxRooVhqKDVUgs5qhlXiDFjThyaE= 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=QqbbTS/s; arc=none smtp.client-ip=148.163.156.1 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="QqbbTS/s" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4CcGUQ001693; Thu, 4 Dec 2025 17:55:34 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=DEoPgJtZqvXLtS6bR UnlT+Janjhd3JxuIr6B9rUJSpc=; b=QqbbTS/sq1tv7wbvOASKZtnVgKiGeFwOx FjStQHT66SW21NztqXMnA4gJhiT6OydQCmapmkxzDWNg9N43kJv65rfLaQtU9xZT QWCv4RjCtvgsQa7zGe6sFyAZScktA1CFOwnmbYX0LuvPeaGCgCa+CcDaiFxUbWhL EcJIKrnT3jikaFbPO/Ucn3imAmyWoHHcrR/C9Hg9TpBo1I4TmIcb/hKruuIp6kUB cQdU6MhkzBT2WvjiZknMMGc/RqSgWd3zv7Ji3GqOVayhI+kHjUSru61iUv3/9Pmo oo8RT6xjhR6Ts0MdmiIP+aIs5m1tdaJ5uxTiLoJgAg3OVUocNjFWg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrh79vss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:34 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4HtXfI020542; Thu, 4 Dec 2025 17:55:33 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrh79vsp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:33 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4FtTO5003864; Thu, 4 Dec 2025 17:55:32 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardck0x44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:32 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HtSmE14745994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:28 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE99720040; Thu, 4 Dec 2025 17:55:28 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C7AA2004B; Thu, 4 Dec 2025 17:55:25 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:25 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 04/17] powerpc/smp: Add num_available_cores callback for smp_ops Date: Thu, 4 Dec 2025 23:23:52 +0530 Message-ID: <20251204175405.1511340-5-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Authority-Analysis: v=2.4 cv=dK+rWeZb c=1 sm=1 tr=0 ts=6931cb16 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=-j1-LL9dA9zlJV2-Wa4A:9 X-Proofpoint-GUID: ojgn4LuqSgngAxu1HZ_rKX3FqYYqQAJa X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfXyjv58sO0Jw50 Yylpj/9qAtsnNPtcwqBsw2Td29tY5hl5v+0P3+Qf3QFcx4OdeziVgrzv9zT4vSAXlpd/Via+gZX w6yWIl3x/D5lZcsEUSMnYZKq/HoXIFit2Ll7YUWp4k+yDmDCgdKxwdR8Obm8F8QKWlhdk4e2VYm aXsFvKJe/DtZJ+w6X8pmuLNj0vwygDwE7K2Z2tiI0An72i97K3DgiJFuTHM8wcJ40UYRqwcH7wU agI7t0UIZYkKkye13OtMKV/y5Q9bQH2+LU3XlX2MrC5iUqNATzpQRJmJXsC8aFqu1/+jV3jQL8w 77iZ2VEtT/BLqxWWywDHnbnZNrRYH1vur/4kD/KrsohtK45Mz/qa46vYoe08l73MSpWXHkuySVB krI4FCTcjF5rb3jgHzgJnDxpr8RJ1g== X-Proofpoint-ORIG-GUID: kOhr0FG4DjqBkKm6VAcAFCCm3cib37NT 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 clxscore=1011 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" num_available_cores callback will update the current number of available cores. If num_available_cores() callback is not defined, then assume all cores are available. Signed-off-by: Srikar Dronamraju --- arch/powerpc/include/asm/smp.h | 3 +++ arch/powerpc/kernel/smp.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index e41b9ea42122..fe6315057474 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h @@ -60,6 +60,9 @@ struct smp_ops_t { #ifdef CONFIG_HOTPLUG_CPU void (*cpu_offline_self)(void); #endif +#ifdef CONFIG_PPC_SPLPAR + unsigned int (*num_available_cores)(void); +#endif }; =20 extern struct task_struct *secondary_current; diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 68edb66c2964..c33e9928a2b0 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1732,6 +1732,11 @@ void __init smp_cpus_done(unsigned int max_cpus) =20 dump_numa_cpu_topology(); build_sched_topology(); + +#ifdef CONFIG_PPC_SPLPAR + if (smp_ops->num_available_cores) + smp_ops->num_available_cores(); +#endif } =20 /* --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 59A603559E6 for ; Thu, 4 Dec 2025 17:56:14 +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=1764870976; cv=none; b=JRJjOvFlscapv7m8jPh5jhYPHRnmFECFO4g0X9WNNtqsLrJjIDb2yxnTAHoPx2WTvaMiqyoXVGIQH2ZaJwa7jqJx3k4oOn6caaUFP+uMF2Pd9RarQbHCCFhFEl6gWksXVtEcjWzVJ/F4qbuiAHi5U0Vr7IfGM8ASyBPxbl07Hv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870976; c=relaxed/simple; bh=r18P9B3yns8TZHCStW0GmcxAi8OYfMWQUHjnYfxra9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g2WvWvkhUtB3o/6soDLQUqnXd6SuZc47nheHPerzf2KKCRVvGe9xsWMn67RoHFzT1ZAzN8Iq089N+s7nkzc6ekG2g78cx7QOpC54OBzRL+FX8/kwaEnuMhaAnYImUSQw2C0hvC17QFdiY1M97xPxu5N8/IYWY4rR+Lq5ZC9WzH8= 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=M71ttVib; 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="M71ttVib" 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 5B4A5oDf018043; Thu, 4 Dec 2025 17:55:38 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=ofdrv2HTyNhn9a94l vQbSf69S36F3l+q9KEMumrBl+U=; b=M71ttVibtm2D1LHW2cs88jdP6AJzzpsXr IT6cfto/fDmHDX4sW4jybmlbM7Ikf1nNbkugI3PaBtf77QDhOhJZnT10l7rc7YCo 9B9/ue6hAEaO62o5xA9ZcXymkb/lxqPpA032YK0uqOI46jq8Inuf450z49wFg6Hc h0a/7QEa4kMpohg8ER8gAlajJuI+b5gM2xCCtgs8vFkyoUj2a9OU7azM87iqz3PU C5MB5rn6baScSreWfdRZF/PoKZCXocP960QcDvv/6gjhgFMYhdBriaaZ12ps9MEF ePNR3RBzhBehmLbFWtUyp/tiAylZ2nujICb5WFrtaGzgaTEh4EzzQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrg5s6ct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:38 +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 5B4HqoSZ013939; Thu, 4 Dec 2025 17:55:37 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrg5s6cr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:37 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4GAjZ7029361; Thu, 4 Dec 2025 17:55:36 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardv1rva5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:36 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HtWHt32440644 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:32 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 826952004B; Thu, 4 Dec 2025 17:55:32 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00E7220040; Thu, 4 Dec 2025 17:55:29 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:28 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 05/17] pseries/smp: Query and set entitlements Date: Thu, 4 Dec 2025 23:23:53 +0530 Message-ID: <20251204175405.1511340-6-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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: 1Vrq_csNHCzp9xa2osFLtxs9Iw4Y1YK5 X-Authority-Analysis: v=2.4 cv=Ir0Tsb/g c=1 sm=1 tr=0 ts=6931cb1a cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=zmVj4zYWMFl_L39sl28A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX/rruhK4Cb7Ab VBYl60SFPuyS+jUyoUVb3pdstkli+caa3mouV9eVY+jsy39Yr5e7FzF0eBCnYHhwGalTHeuVlR8 ejOpvHWr7c7kOYGVaVgRbN2fGoUAYraO77TapdqJffWSj1oyD33N/Wr0aoBvcPgxjzx04d2Uyfe NSfrzXVmm8OY+3o402Ae3fswkJ8JoEPcInnAqbd5Pgm23KxNShgrscGHiEYhy1ZXP7A2Nj2BBl1 zgB/Kj4E7XDEcMb/yb2jC2KH39Rnb9AtgDceAlKcA+Sxd22V2h6rYRg62Qveb0lWIjHSUquf7MQ r8dTG0guRn7RfI0CfOKhfvRAluKt8KX9S0gUH56sLW26RPfW9LYuVReVIHZ+juxB14ixqBzHW0G hq/FelLaZTNeQnTR93got1ItaNs2eA== X-Proofpoint-GUID: JidS4L2skuTXWOaUvwLPfOO1ck_2dd-t 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" 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 --- 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 #include #include +#include =20 #include "pseries.h" =20 @@ -239,6 +240,40 @@ static __init void pSeries_smp_probe(void) smp_ops->cause_ipi =3D dbell_or_ic_cause_ipi; } =20 +#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 =3D 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 =3D=3D present_cores) + return available_cores; + + if (plpar_hcall9(H_GET_PPP, retbuf)) + return num_present_cpus() / threads_per_core; + + entitled_cores =3D retbuf[0] / 100; + max_virtual_cores =3D present_cores; + + if (!available_cores) + available_cores =3D max_virtual_cores; + else if (available_cores < entitled_cores) + available_cores =3D entitled_cores; + else if (available_cores > max_virtual_cores) + available_cores =3D max_virtual_cores; + + return available_cores; +} +#endif + static struct smp_ops_t pseries_smp_ops =3D { .message_pass =3D NULL, /* Use smp_muxed_ipi_message_pass */ .cause_ipi =3D NULL, /* Filled at runtime by pSeries_smp_probe() */ @@ -248,6 +283,9 @@ static struct smp_ops_t pseries_smp_ops =3D { .kick_cpu =3D smp_pSeries_kick_cpu, .setup_cpu =3D smp_setup_cpu, .cpu_bootable =3D smp_generic_cpu_bootable, +#ifdef CONFIG_PPC_SPLPAR + .num_available_cores =3D pseries_num_available_cores, +#endif }; =20 /* This is called very early */ --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 58EA535970A for ; Thu, 4 Dec 2025 17:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871005; cv=none; b=QsXfGAfhadng88aYlJqmR7/t99pHt5ARpFJq3LsU+cy/mL1owXSwa0gkAGrmLQNjq2hlEB0h+2O7vgCrjv02FZstAI+am+BGZ3h0leQW6v6xjU3BBr7WDAi0kuN8VxmJ0FX3UyUusCoHb6ZbuXbKQTr0Y2oFgMl7+uGgNQRPk7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871005; c=relaxed/simple; bh=fpQuz42FXLiLj3S24TdUu/Hzwn1N1etjqJjZZuplWRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JRXKp2Qq+Lee4VCETfLC++Uxe9eV6S7rYNE03JNEIqaDpxxX840OQXrDIBaQNLzG8mgNP5sxbQJLTwAP9ZE1MZvscVeX111DLYOEWAKuGkt6orvsNyEFWTmejaavFTsXNuyMcU+1+yXyXPWeoiDOgfZV42Bv6Qf2awgSOXwNkgg= 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=tJdEv8iK; arc=none smtp.client-ip=148.163.156.1 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="tJdEv8iK" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4E3eQ3022200; Thu, 4 Dec 2025 17:55:42 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=kMTJ/GDQee/iBpeJE RuosO4o6/1bcvJe+OVqpZx+BcE=; b=tJdEv8iKDMtHlahfsPwncQkbQyMQr1olp JdUikeCRF6LKXsnlOURYwnzaXFd1djG8o0xmQrgkIIHSQgYKVd2xo7COOJnL2hQz TTy/Jv6NRfrs5SBLt1ElJz82loAiqnlypnm9sbCCM4rzhZRYL7K5cYZ7uyU6wMno lZ8oJhmgBfBT/pkEkvcHpmy3b8hwZpdcq1OXW09v8INv8nwWc0Vc6oS/zFMF8mLq +wFDuL4/rcXjGQX15m7tr1pNgE6/nd6oG2ZBatjDFvXYQiGFndiVfpciT7RUuyiD SAKnDMW73yjUwHhWbA3HLmVvSwtCrYkFOPFmscXpYNgTi0cxbjahw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrbgj16v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:41 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4HrSU7020699; Thu, 4 Dec 2025 17:55:41 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrbgj16s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:41 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4FhhkX029343; Thu, 4 Dec 2025 17:55:40 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardv1rvad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:40 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4Htanf41812374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:36 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47D0820043; Thu, 4 Dec 2025 17:55:36 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8CB420040; Thu, 4 Dec 2025 17:55:32 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:32 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 06/17] powerpc/smp: Delay processing steal time at boot Date: Thu, 4 Dec 2025 23:23:54 +0530 Message-ID: <20251204175405.1511340-7-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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: MyEZB6I1h3psUYLHXo3Fj1mnYlU4LXID X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAxNiBTYWx0ZWRfX9mAN1DMg/KdM bjfa5FCzbcEXEJnh/L9rdqDmE5hN00qLm0grGS+L6/qxDG48sNRL9TElmkbyEV3hcvmF7TVWO1r rPPs2Ic/1K39u449+WtxUwH112eqs7aMDBoePynpyj55o8hJUcIgAWtfkpgekAO/lS9Cot+f2Qj wj+x1hgu+rj1HXigjFFMaikL/H30J/Bn1YumnB9QoekwrcTSPaqELjzUBRwdMIw8YL75UCZ4vr9 gsfNl+BL2OlVSHzMb6AKpe37yLUpVl1PsmU/e3kB4dan6/ZTXScMMzNTaGNk23nIocjMd+Lz7qU pPHZitg09Yr0Im+EOS5hDkbg06myvg/k9q9EVXHbWykI+QqAxslvpCF9bIotHyh9pI7POyh89F8 jwpNp8k1oeJ+X3tHV46DzX7vNF0HWw== X-Authority-Analysis: v=2.4 cv=UO7Q3Sfy c=1 sm=1 tr=0 ts=6931cb1d cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=1EFQ6eh71MqxaOUTsigA:9 X-Proofpoint-GUID: P-pgooUrMI7eb-N5SDgr-iSEfULqXNy9 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 spamscore=0 phishscore=0 clxscore=1015 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290016 Content-Type: text/plain; charset="utf-8" Before processing steal metrics, system also needs to know the number of entitled CPUs. Till that time, delay the steal processing till the time entitlement information is available. Signed-off-by: Srikar Dronamraju --- arch/powerpc/kernel/smp.c | 8 ++++++++ arch/powerpc/platforms/pseries/lpar.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index c33e9928a2b0..016dc7dc5bbc 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -82,6 +82,9 @@ bool has_big_cores __ro_after_init; bool coregroup_enabled __ro_after_init; bool thread_group_shares_l2 __ro_after_init; bool thread_group_shares_l3 __ro_after_init; +#ifdef CONFIG_PPC_SPLPAR +bool process_steal_enable __ro_after_init; +#endif =20 DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map); DEFINE_PER_CPU(cpumask_var_t, cpu_smallcore_map); @@ -1736,6 +1739,11 @@ void __init smp_cpus_done(unsigned int max_cpus) #ifdef CONFIG_PPC_SPLPAR if (smp_ops->num_available_cores) smp_ops->num_available_cores(); + + if (is_shared_processor() && !is_kvm_guest()) + process_steal_enable =3D true; + else + process_steal_enable =3D false; #endif } =20 diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms= /pseries/lpar.c index 3431730a10ea..f8e049ac9364 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -674,6 +674,7 @@ static bool should_cpu_process_steal(int cpu) return false; } =20 +extern bool process_steal_enable; static void process_steal(int cpu) { static unsigned long next_tb, prev_steal; @@ -682,6 +683,9 @@ static void process_steal(int cpu) unsigned long steal =3D 0; unsigned int i; =20 + if (!process_steal_enable) + return; + if (!should_cpu_process_steal(cpu)) return; =20 --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 20B3D3563DA for ; Thu, 4 Dec 2025 17:56:17 +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=1764870979; cv=none; b=lHSfbiIVoi+5XvaB+BUGoGk/2+DEpf5srHekV+BjTE+TeyNXPb7LP+fOjV3p03XQ1uHk3JCh0hJIl7jfi3sZO+cdS221DTN0w4CuiOFKCmoEdoqJF/74aNHLzQxGrQ0YSLJxgA+WLoU+Q8x68ANiHbHDoSd52IFLD8Fftqn27YU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870979; c=relaxed/simple; bh=oHO6PTcw3aXh685KOllB4RZtoSmWA3wpKHrLifYr+TE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DXNBA3o1n7Ps2ecmclctYYg9W/lELZctiC8vkW7ewJu3bSy1nbgOUfdxrnS18WLvUdi2z4ekvSPlSsjpo/Or4nOPk9HToLcKmZ4WjSNuiKHCgXUmue3BDaUJuVbUOz0K1EUJ98yl66pkK2eFykgDoVTgXAWbF3RDN4l0dyUOTEU= 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=k7Rup/Oc; 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="k7Rup/Oc" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4FbwZK018535; Thu, 4 Dec 2025 17:55:45 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=zfrg1rG5jDOEik4rU JgJKPizaKP9IuPevyT0ezbS4NA=; b=k7Rup/Oc37X8e4ZDBHMl3e6oAvsJDDPop C6Yl8IGPHsCaytOEEPvMpOw1OpgtWVeuGd/RuUNhaXT5H9LL3vqJlntlSVN4CwNs w+PAVotty/fa+wgBCc7TM4g022bbNsVk/UWAfaC7QdBLMRIxyNXJe6hdAIGNj1rk uiWkvF29y5CBip1nPAZevgd4Gno0yOerJxDY5BTrpbRR9ZLlE+0gs7Tv0uHCsWX7 y9HSlkg30kmmbDwAp5AeDHTwd0Qb/dBkgKPvKvH+Jzun4rQbQN74QfjWc0xxgOgq qLM8A4KGx/b3j7lDdmOb/i41rRJykOPIObhvyulqNVDDPqQXK5Vxw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e4k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:45 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4Hk24A031925; Thu, 4 Dec 2025 17:55:44 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:44 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4GDWRn003891; Thu, 4 Dec 2025 17:55:43 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardck0x4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:43 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4Htemk48890148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:40 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1068120043; Thu, 4 Dec 2025 17:55:40 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F80B20040; Thu, 4 Dec 2025 17:55:36 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:36 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 07/17] sched/core: Set balance_callback only if CPU is dying Date: Thu, 4 Dec 2025 23:23:55 +0530 Message-ID: <20251204175405.1511340-8-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfX7hJNWLOXP0fe fK/CL+ZvpnG8hHCZ5yh4SryhATLuFhfljDRhCO96hf7tJFtpoH7Xn070n/Hzi6aRMU5V4QJJFwr vuo86ULF+n4OOQXC1lqSr56/fIfrE24iAEbYTjpyd/Q1vRmgwRC3GniYXgkCyAq9nl+0Ozxg7il MJuZZI9KqeFXCLCenD/f7C+ryC0hbAgFX4+2lLBiiTKwOdY2ZSxVR32JrC1MpvsJ1AGJKx4UkEN q0zwIMtNsHGnR984jlLGPp8iTz7l13wxfalvKeEzAxwrOowsVuEnk24LK3uc08lOA9DMTxzU+jx T9hTgZmpZgicw1BYCTKycaoPGxirHPAlhvAYEceDpW2Sf7AoUcc/jVv2miv1iUcbh4dhz7ei0r/ ZzLdiELEhuJRR+lbYqmvnjLj0DLT3g== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=6931cb21 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=JESwPpsbOM5vm_rGWyIA:9 X-Proofpoint-ORIG-GUID: 8uU_t1RZRCpbzH0RSd3zI_3XEKNDkQ3R X-Proofpoint-GUID: g6N-ECgPD2VXnbLJPqWWFyz2k-qRoxJ7 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 Content-Type: text/plain; charset="utf-8" Scheduler is suppose to set balance_callback to push tasks out of a dying CPU. However the current code, unilaterally sets the balance_cpu and then checks if the CPU is indeed dying. Remove this anomaly by setting balance_callback only after checking if the CPU is about to die. Signed-off-by: Srikar Dronamraju --- kernel/sched/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index f754a60de848..89efff1e1ead 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8173,11 +8173,6 @@ static void balance_push(struct rq *rq) =20 lockdep_assert_rq_held(rq); =20 - /* - * Ensure the thing is persistent until balance_push_set(.on =3D false); - */ - rq->balance_callback =3D &balance_push_callback; - /* * Only active while going offline and when invoked on the outgoing * CPU. @@ -8185,6 +8180,11 @@ static void balance_push(struct rq *rq) if (!cpu_dying(rq->cpu) || rq !=3D this_rq()) return; =20 + /* + * Ensure the thing is persistent until balance_push_set(.on =3D false); + */ + rq->balance_callback =3D &balance_push_callback; + /* * Both the cpu-hotplug and stop task are in this case and are * required to complete the hotplug process. --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 314813570C1 for ; Thu, 4 Dec 2025 17:56:20 +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=1764870983; cv=none; b=dIgRNqByuPszCJy+FA3JA4IHszGvvwlp4uu9oXT/BQ3jiAS0z3vtVM+OPyCwmOxk1wfQrcWegO/5wnYn2OsGepV3iTrVM6L80uXq0XUMg3Q4ts1xMi6un6dX0FyoWH4NZyx5InOeHKlg9YYuXm/LX1WhoUcEy4Uh7gAy61M5RQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870983; c=relaxed/simple; bh=y3FT/d3WA8RmCbfMbBFFEtokW7xuWWjNVRwkxIK8Vso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uUmZ+MtGES/InpOirp62OcjJYdAZ0McWLRkKYortTcobwoEjqBsKNEzDB9kzBpw05FNWaX9mnBHonHvkHDadHdQqd+i+UdzjpPC3V06JSInx1DRczmIwhaiuaa3pW5/5Cviqt/qC9kPtNrl/XgM/nI3kufrs8f2xIaHuiDoVdQc= 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=MUYguFmw; 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="MUYguFmw" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4C4AIE010288; Thu, 4 Dec 2025 17:55:49 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=L9hSPWn9kNfDvGkjw Y79YeQX2N4JGRCB25PXRwW7tQE=; b=MUYguFmwmRRd0JpBg6o4vfBbPgvIhnhSk fJesW8OIF8UL+CnNkmBRpQK6SpIH8vD8oh/tphx5y3BrUroRE1PSKHkVRoIG6sV6 lfLEYeOKC7h+CMzYpAv70hlPM9PExxq01YhpC/QxEDAb2mhaV22+O7/Cbi15jrcW 8R55uvyl5T5cdKR1bqO2tiPaIXUL8Udapu35/gp5PgU0tbl8dXpu0QJvipQwr14z jTIZkTNP2hUO/frjgQPTb4fbu4wtWHJjscPylR1sIe/Igb7iMEHZNHo4B1xbtd+P EtotSPGzf/lbTTddAy+0zP/25Xbbadn5qw3MHDVY1SFxDy1j/BnZQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:49 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4Hhwq7026247; Thu, 4 Dec 2025 17:55:48 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 4aqp8q9e4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:48 +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 5B4GQpKe021503; Thu, 4 Dec 2025 17:55:48 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4at8c6jba4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:47 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4Htikb26214774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:44 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E3A020043; Thu, 4 Dec 2025 17:55:44 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 568DF20040; Thu, 4 Dec 2025 17:55:40 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:40 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 08/17] sched/core: Implement CPU soft offline/online Date: Thu, 4 Dec 2025 23:23:56 +0530 Message-ID: <20251204175405.1511340-9-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfXzEO9T9nxp8Sm k/a/qBoKLFIRlREgWn3Ttw6DInezbD4ymrRG6P1TxKRicoKjQf6teeGY+n6vgyfyv+QXOGhxRe0 7cZpnA/6dxZFqQaFal/OA4d80Pgm7icfrS4nHgBj0WhyrDFfXJ8aZ4n2h0wRQBgIMkG8qUDa2SN m+YqRN/bEVLrNESPVq124BymBZyL2AvXtt1YzJ88DjmD1fv/gtK5Wck4lO+IZ4XYDZr4K0jDBpz 20OeqXIjB+DlB8Y0w5anIpgb/ucaKE1jHGNJIomctJlvX+1OB06gCUQHV/dbsyuKj8ZHEFA2lW+ SK3/36spsFdAk7M/143EUK+A00AMNRd06iG1mPwpOLAZxCl2i9Ya+QYPm02ayoo5epXcbejRST2 X4EyANVvcdiMWWisr0AO2Ia2J+HqzQ== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=6931cb25 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=i_Grb7urhSapXPVAAnwA:9 X-Proofpoint-ORIG-GUID: 1NSFEosnOBjow0v-3ZV3xWGqlnZTAi9f X-Proofpoint-GUID: jucU3bnD4SrqdJkLcS8AlEYyBox03jwf 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1011 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 Content-Type: text/plain; charset="utf-8" Scheduler already supports CPU online/offline. However for cases where scheduler has to offline a CPU temporarily, the online/offline cost is too high. Hence here is an attempt to come-up with soft-offline that almost looks similar to offline without actually having to do the full-offline. Since CPUs are not to be used temporarily for a short duration, they will continue to be part of the CPU topology. In the soft-offline, CPU will be marked as inactive, i.e removed from the cpu_active_mask, CPUs capacity would be reduced and non-pinned tasks would be migrated out of the CPU's runqueue. Similarly when onlined, CPU will be remarked as active, i.e. added to cpu_active_mask, CPUs capacity would be restored. Soft-offline is almost similar as 1st step of offline except rebuilding the sched-domains. Since the other steps are not done including rebuilding the sched-domain, the overhead of soft-offline would be less compared to regular offline. A new cpumask is used to indicate soft-offline is in progress and hence skips rebuilding the sched-domains. To push tasks out of the CPU, balance_push is modified to push tasks out till there are runnable tasks on the runqueue or till the CPU is in dying state. Signed-off-by: Srikar Dronamraju --- include/linux/sched/topology.h | 1 + kernel/sched/core.c | 44 ++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index bbcfdf12aa6e..ed45d7db3e76 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -241,4 +241,5 @@ static inline int task_node(const struct task_struct *p) return cpu_to_node(task_cpu(p)); } =20 +extern void set_cpu_softoffline(int cpu, bool soft_offline); #endif /* _LINUX_SCHED_TOPOLOGY_H */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 89efff1e1ead..f66fd1e925b0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8177,13 +8177,16 @@ static void balance_push(struct rq *rq) * Only active while going offline and when invoked on the outgoing * CPU. */ - if (!cpu_dying(rq->cpu) || rq !=3D this_rq()) + if (cpu_active(rq->cpu) || rq !=3D this_rq()) return; =20 /* - * Ensure the thing is persistent until balance_push_set(.on =3D false); + * Unless soft-offline, Ensure the thing is persistent until + * balance_push_set(.on =3D false); In case of soft-offline, just + * enough to push current non-pinned tasks out. */ - rq->balance_callback =3D &balance_push_callback; + if (cpu_dying(rq->cpu) || rq->nr_running) + rq->balance_callback =3D &balance_push_callback; =20 /* * Both the cpu-hotplug and stop task are in this case and are @@ -8392,6 +8395,8 @@ static inline void sched_smt_present_dec(int cpu) #endif } =20 +static struct cpumask cpu_softoffline_mask; + int sched_cpu_activate(unsigned int cpu) { struct rq *rq =3D cpu_rq(cpu); @@ -8411,7 +8416,10 @@ int sched_cpu_activate(unsigned int cpu) if (sched_smp_initialized) { sched_update_numa(cpu, true); sched_domains_numa_masks_set(cpu); - cpuset_cpu_active(); + + /* For CPU soft-offline, dont need to rebuild sched-domains */ + if (!cpumask_test_cpu(cpu, &cpu_softoffline_mask)) + cpuset_cpu_active(); } =20 scx_rq_activate(rq); @@ -8485,7 +8493,11 @@ int sched_cpu_deactivate(unsigned int cpu) return 0; =20 sched_update_numa(cpu, false); - cpuset_cpu_inactive(cpu); + + /* For CPU soft-offline, dont need to rebuild sched-domains */ + if (!cpumask_test_cpu(cpu, &cpu_softoffline_mask)) + cpuset_cpu_inactive(cpu); + sched_domains_numa_masks_clear(cpu); return 0; } @@ -10928,3 +10940,25 @@ void sched_enq_and_set_task(struct sched_enq_and_s= et_ctx *ctx) set_next_task(rq, ctx->p); } #endif /* CONFIG_SCHED_CLASS_EXT */ + +void set_cpu_softoffline(int cpu, bool soft_offline) +{ + struct sched_domain *sd; + + if (!cpu_online(cpu)) + return; + + cpumask_set_cpu(cpu, &cpu_softoffline_mask); + + rcu_read_lock(); + for_each_domain(cpu, sd) + update_group_capacity(sd, cpu); + rcu_read_unlock(); + + if (soft_offline) + sched_cpu_deactivate(cpu); + else + sched_cpu_activate(cpu); + + cpumask_clear_cpu(cpu, &cpu_softoffline_mask); +} --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 A8D7F3587A5 for ; Thu, 4 Dec 2025 17:56:27 +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=1764870989; cv=none; b=ogbBIB14JdlvNl6Gr1d0f6dK+LOsp7wMuaN3MGcvCVwIF7sV1T59HNs6Ypc4uZkdaZVgJj005gg9tL8RyZLlV4VD45Epk2frFGdwnvhsKQpCNPzUa8e8K4U1NjVzKfHEImzSTIwyF9V4b72lWoQzdMSy8nroBcF1fX8Pn/p8YGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870989; c=relaxed/simple; bh=rOZ2XXk4H9j+a/PIjktgSIfaBU5mJTcLlxFtjta6D0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WYJVNWLd5DBCK9jtjbUxpdZCK6kEQqV8Nx8AauzUj7v6xgZOgiCXAxz509oosdGsPQalVS4zdl7/64MqzXfLNipl96x2Vt7JUIdT0APxIXsZGsW1En0Jwpony17M8+qo/HUfWohky/QBw0txYqTN+IiDE+U4XsT/Glm7qI44e5k= 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=AGrqVwjg; 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="AGrqVwjg" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4DbUPJ027754; Thu, 4 Dec 2025 17:55:53 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=Ndrrcx1O9Y/Vz03Da IShxn4p1fkYnsBk7V1KxQMIrAI=; b=AGrqVwjg2dzbunMJYse9z2Q4yVYiTYDJP vw3I1i++cHePBfG0VvCjqFSmwJp5mQ4aPNUDJlS5XM+bqx+kTJ0ausRGaJ6dATWO PATRN/4nMFsZuKdpaOiqwcF39Py1QCop5DGsKySswkJzx8k671qCTHNbsYhOa0u2 /fqMMyKZ8NNUsHTVrUX2sADSUymqGmM/ooOEm2QZTfmvhG2pg9QlxY/i/+R8J8X2 anFDj4aoJzldJFv4WuQjDAwg+zclbcO+S6JsRb4QLtrEaqDgXrrhg7FDAPhBrz2J 5AqPk63tTVHd0GEC1CfaxBzFkOy3GNBEdVdLtbWbHmCswOecBBRFg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e58-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:53 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4Hk24C031925; Thu, 4 Dec 2025 17:55:53 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:52 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4FiU9t010227; Thu, 4 Dec 2025 17:55:52 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arcnkh2t1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:51 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4Htl9H60293626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:48 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C780320043; Thu, 4 Dec 2025 17:55:47 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54A2720040; Thu, 4 Dec 2025 17:55:44 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:44 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 09/17] powerpc/smp: Implement arch_scale_cpu_capacity for shared LPARs Date: Thu, 4 Dec 2025 23:23:57 +0530 Message-ID: <20251204175405.1511340-10-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfX2cPI5z1HXWzy qV5ExdlzYTaDfqFxWJdGjU4UfSQ75FBUqL7CiqEymyTjVn8NerSpT5BIfExtKb2q1uubx1Nf/6b 7A06Q7wJmhlGTyu3pmSofSvqwxwB77nT4sse81NbP5LJ7CNZHxlxGNDsLuDyOMFf2LnPAigDXNn vkAZbFbZnVFXP5wGCkn89eb6dMYvwXVlj07PO20nHI+MYeiaWeKVLTgHlPnCGwcb83D3SGxTad9 2yqcnT/r7kXbcX6j+RlhZCD8xCLRezm/9OliY7PKzos5xB3jh++gC0g5tRQYsl6NUepp+ZvktxJ KbflRX2D9XIZK7ScFHEUdjFOVfB5WixAd2g401U21CJpgGpd4V5v7YXCBCcMTYq6nQ1T3qkdhYT WMpSCwp7bOyedFRZ6Paoza1WOk5yiw== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=6931cb29 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=oq048o8STzGrlCM9ncQA:9 X-Proofpoint-ORIG-GUID: 23B6ub71QgzygcDZbRocq0TUB4x15cgd X-Proofpoint-GUID: DG6BoV-zGkVac9lbvnZkjTSBW46qxC_l 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 Content-Type: text/plain; charset="utf-8" If a CPU is soft-offlined, then its marked as in-active CPU. On a shared LPAR, reduce that CPU's capacity. This will force the Linux kernel scheduler's load balancer to prefer CPUs with higher capacity. Setting the capacity to be low also helps the scheduler in load balancing. If there are 2 equal groups of CPUS but if one group has more inactive CPUs compared to the other, then setting to low capacity will make the scheduler schedule more tasks on the group with more active CPUs. However tasks pinned on that particular CPU (or set of CPUs that are all marked as inactive) will continue to run on the same CPU. Signed-off-by: Srikar Dronamraju --- arch/powerpc/include/asm/topology.h | 5 +++++ arch/powerpc/kernel/smp.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm= /topology.h index f19ca44512d1..031c067fc820 100644 --- a/arch/powerpc/include/asm/topology.h +++ b/arch/powerpc/include/asm/topology.h @@ -174,5 +174,10 @@ static inline bool topology_is_core_online(unsigned in= t cpu) } #endif =20 +#ifdef CONFIG_PPC_SPLPAR +#define arch_scale_cpu_capacity arch_scale_cpu_capacity +unsigned long arch_scale_cpu_capacity(int cpu); +#endif + #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_TOPOLOGY_H */ diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 016dc7dc5bbc..c269b38dcba5 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1811,3 +1811,20 @@ void __noreturn arch_cpu_idle_dead(void) } =20 #endif + +#ifdef CONFIG_PPC_SPLPAR +#define MIN_CAPACITY 1 + +/* + * Assume CPU capacity to be low if CPU number happens be above soft + * available limit. This forces load balancer to prefer higher capacity CP= Us + */ +unsigned long arch_scale_cpu_capacity(int cpu) +{ + if (is_shared_processor() && !is_kvm_guest()) { + if (!cpu_active(cpu)) + return MIN_CAPACITY; + } + return SCHED_CAPACITY_SCALE; +} +#endif /* CONFIG_PPC_SPLPAR */ --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 DFCA1357A4B for ; Thu, 4 Dec 2025 17:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870988; cv=none; b=kZt//Yl+JQuzA+QOK8Uv6N7g/zLttZ6oQe3MCHIDIz04DsYpEDXLEhnp5HA81UrYQgfk/XtBYQAW9hoY4m19iyMeDHbF4BEdh1ZL+Bwki4jQkfv7RUT7X2ngNbJJVO0xXCD+ijJgtB9nQ5lzrrZTnHE+mzaf0+8jPO1wFdrPotM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870988; c=relaxed/simple; bh=eBgm4wu3cZFTfRCFezSLavfMK4CRo3hz2u22MQVZiek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OlFTCU59wa1/qCshPWN2Xd2Y+/uGgAGWcgui8R5mV+hbMXT9WJTFvJR7cwM+xOe8Bd2siz+jP6QeEcYUNAHYnnA4efGQjsf0nWYijZjGhBzFB//wlqnTZWgNgSCxAwmuk+G0qBVqSkPJ0yAQTB/7Vx/ZGldbImZwOP4IIU6WExA= 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=ri4SSvC7; arc=none smtp.client-ip=148.163.156.1 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="ri4SSvC7" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4BFo4q008018; Thu, 4 Dec 2025 17:55:57 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=h9HJXLAxAr/bNBAaj 1O+oB5I9KnYyrsRbt+7/zL5d4U=; b=ri4SSvC7QthVZQf5pwdQnzBEU+V41P/rs VYaqKfd8Dokr57buu8lTff185Fqu7e7Ho+PLniNM2SJORQZwMIM+ZjXvCf9l5svh 3Dn2Nwr6iAC4QvZw/VTA7UuY0OxjMf0iUb80O5mkjYU74dVwsMSuezZ5aOzk3SXV 2+D+SExhAAW3nO9DzQ24hnMSobgiKYALdWjskCkIhrUlEAwVqQmzIN/icuTgFaXg jLhBABRj/2frCkF15M8En9d2mO+50iIef7uaS4j6C70GCdb7gZMBn2oTd2qeSEFf WOQ0iQfjzFG8XWpecLCb3XCyzUf4U2YFA4QDXkaBhAyUxbXJLHGtQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja1tae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:57 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4HtR2T009837; Thu, 4 Dec 2025 17:55:56 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja1ta9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:56 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4Hik3w024102; Thu, 4 Dec 2025 17:55:55 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4arb5ss9uw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:55 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HtpmI22544774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:51 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9291D20043; Thu, 4 Dec 2025 17:55:51 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1CB1620040; Thu, 4 Dec 2025 17:55:48 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:47 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 10/17] powerpc/smp: Define arch_update_cpu_topology for shared LPARs Date: Thu, 4 Dec 2025 23:23:58 +0530 Message-ID: <20251204175405.1511340-11-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-GUID: l4JR9jDM1pD_VA4oSlDEXPnrt15NScFv X-Proofpoint-ORIG-GUID: DCiUbeQ79lvHy67x1YWZza-xc7CBBPuL X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX8SYKDMWgd3GQ oN4rZspFHqoQgfoySF1m2+eIdRy1frSAqnrblMPIf+Yjbl/hh6LF0hBjL05szRY1paKR+Rvr353 vmxCneLf5Wa8qf9QrcotBXGdRc0rspvfuLgIf/VSW0cj+m6qseYjy1Gn08ZrfU5rbb+q6Vtueqr Ql+fUbHhWrrzAiv2b2R7gCPOkEylRyKgpmMscqo6pIvkc0YCwhgpTI3Ok3eMBLTDgguFo+0LvF/ BcjzWCsZue7VbZM9XjjTRFWEZbaWzjh7iEyP6b6iunNI4aqP29XNe0EZ8DbSHYcE8+a87k2DOiO 4v68nobU8HnA/sp8B+zx3p5U/N7Bu1JW2SXkK3/xNS11BIwF/zBIS+0LnauBnfgRQKlevt6xGYs tNhT7W35ygM/QstneYLzfg+ujDwPIw== X-Authority-Analysis: v=2.4 cv=dYGNHHXe c=1 sm=1 tr=0 ts=6931cb2d cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=1omYuK1FgZOeepGw4pQA:9 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" While rebuilding a sched-domain, arch_update_cpu_topology() is a way for the architecture to tell the scheduler that there are asymmetric CPU capacities that need to be taken care. If arch_update_cpu_topology() returns non-zero, then scheduler shall rebuild the topology post scanning the CPU capacities. On Powerpc, If there are soft-offlined CPUs, then inform the scheduler to scan for possible asymmetric CPU capacities. Signed-off-by: Srikar Dronamraju --- arch/powerpc/include/asm/smp.h | 3 +++ arch/powerpc/kernel/smp.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index fe6315057474..92842eda1a03 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h @@ -269,6 +269,9 @@ extern char __secondary_hold; extern unsigned int booting_thread_hwid; =20 extern void __early_start(void); +#ifdef CONFIG_PPC_SPLPAR +int arch_update_cpu_topology(void); +#endif /* CONFIG_PPC_SPLPAR */ #endif /* __ASSEMBLER__ */ =20 #endif /* __KERNEL__ */ diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index c269b38dcba5..478847d6ab7c 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1827,4 +1827,12 @@ unsigned long arch_scale_cpu_capacity(int cpu) } return SCHED_CAPACITY_SCALE; } + +int arch_update_cpu_topology(void) +{ + if (is_shared_processor() && !is_kvm_guest()) + return (num_online_cpus() !=3D cpumask_weight(cpu_active_mask)); + + return 0; +} #endif /* CONFIG_PPC_SPLPAR */ --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 73D54358D04 for ; Thu, 4 Dec 2025 17:56:31 +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=1764870993; cv=none; b=LsXd9QDXDIG3uhdNpRJxG9Uokx/z/fSHmyv4IFgYYyZIX1tUgSvLC6aJ4G+hwoQlbB1USiRJ1tihrnT3GdLdJFEs1HEUwixvm+eNga2cCWpHFKfeJndkG395OwlVlW/XfZZT5kB2MFPo95HNCWDFd5/uqJR/MZFcuU9BC+otSmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870993; c=relaxed/simple; bh=mhgfA0712tWFSa7xNTFSqOSWUsVbwxgnDwh9oOXiaKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GjcCjddGTi3sYzXFZ9Xc/+E4+heS5Gbdoq/MLXTBKOyisj3o3I9JP/W6kcEfhWoMf7AZCU42S5N/+WEBf+99CudjXD9/qEvj/fGIFkpD4GY3bMU35U8IXRpJgm6Kej259TRYZIatOI+CPIAelDgLWxH4kXSRxb1/16CX1/iN2Jk= 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=RftKjCJL; 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="RftKjCJL" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4AZqtS007787; Thu, 4 Dec 2025 17:56:00 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=ysKpJ6qK+0o6f5e9z aWSj7+gvfbnph9GLv07UXGGudU=; b=RftKjCJLWuvbPaE36VbCIoLVUgqSjREft 7GPPn6ZMTyyCM+lKgHvTFHss2QVwU0OeTkNUOMDkIitaFfQUqJWZOyYsUJNY2mU1 Fj+KFpg9Bq206SgDe6RvfcR7UkosCgKhl40W/TnOJ+4vS7EVpwTQVkArkKMTxwvs gFdB8AcMpWPXa9LhCaCGuAHmBTU18j8nXvPhwJ8T3VoG6ST0WaCvTZamZoWRQwp8 cX1/AQRLACnQhjwB7HqyvdKnt/+LN+aG2AFXqOT3w6vE2hUjTinPkIkrXi6nvHag 50mk6nz1M//XdLi5yuNr8nuSF2wOvi8prN6LCeguWCTXKKTFlAOCA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:00 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4Hl97R001863; Thu, 4 Dec 2025 17:56:00 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:59 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4F08Y4024080; Thu, 4 Dec 2025 17:55:59 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4arb5ss9v5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:55:58 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HttdL52625664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:55 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 661BB20043; Thu, 4 Dec 2025 17:55:55 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D908E20040; Thu, 4 Dec 2025 17:55:51 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:51 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 11/17] pseries/smp: Create soft offline infrastructure for Powerpc shared LPARs. Date: Thu, 4 Dec 2025 23:23:59 +0530 Message-ID: <20251204175405.1511340-12-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfX35luS4bBhR1r QmlIM/dV30GhP6qHbKEP8ECfAUoyjboLKj+LH3EWKw0CPxYH3HZ1eUWrM6WsSl3MKczLSHePcUr vzGVcqaokapzt3nOGmL0Ms1CV0qP4Jm+ZBfMBCJqj7FXItUqqRQASWCxaHMc6x6d/xbojHXvNgd gbHQXsdYx4wFIaVu5qhOAkDJW8GYsg2+6v66hpMRcWmKQNLsVLmWV6CVihG04u9ySrdesGmJxYi BbK/laXMgWFit9PwaCPisJpdSoHV77sHNOqlDiqved7HDXp4cEh/NPDOPE31shz9lnEUReNniaq BFOn1GFQW3ALhQdV/4fZaFR0OPU7kLhtCNu3UG+h1QcNWckgxLpVs3Bxkyh7wVzLRC7OpJjHMbj +12Ni3ofKdtEKYxDFAMxpEefJKnDvQ== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=6931cb30 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=3qOYXtFuKzhovN1QMkgA:9 X-Proofpoint-ORIG-GUID: dHHVYs7YbjW6iW96gITP0-qTI929wgAc X-Proofpoint-GUID: zTTYAFQMt9ec2zkkq3HPKXSJaEn3Q6RZ 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 Content-Type: text/plain; charset="utf-8" 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 --- 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; } =20 +#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 =3D 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 =3D &per_cpu(offline_workers, cpu); + + INIT_WORK(&worker->work, softoffline_work_fn); + worker->cpu =3D 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; =20 + if (!entitled_cores) + softoffline_work_init(); + entitled_cores =3D retbuf[0] / 100; max_virtual_cores =3D present_cores; =20 --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 6EF453587A5 for ; Thu, 4 Dec 2025 17:56:36 +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=1764870998; cv=none; b=GgTQ0RwCFHcSJYG8h5NboqkueT24BTgejHg5/oDI37Vr56yA31MgweXJEu4eh6NoM4UYL/CwxIOXU1vb40LceTYaSt7iLGOyD0ReAAH3/AHeidYaLxe+IKXq3n6y0JgGw1mP9bvSRX13ySWMyWclgSEoxbUpfxmmm9QJsC8umRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764870998; c=relaxed/simple; bh=YCCb/7EaIQcNXdAqnwws8/QAxOPzLfxuw7wg0TKCfpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nj/9Is9DwZ9U8OCV8wOG0jRkyefk+px3SNB+8H5hCWkrO/XbFgXUg3JlWhcTsORAtRoSqWZ/f6kIIa71oeQgzylTXS9oZLTWU6V7V2oEezKjaDRB4kSCdktfg7uuvzGCt5aEB1JLNJPZFLuGtu1VlL6F2a3Ss4rllTNVLt9KRj8= 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=XSQ+SfwL; 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="XSQ+SfwL" 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 5B4B7HVR014086; Thu, 4 Dec 2025 17:56:04 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=kkg9Mm171EveHML6p pZAmLKP+NVKMK5te30viw6KABs=; b=XSQ+SfwL6z47CoKBBmz3Q9telL8/hbtRI 5sdYycFJjuS7kp0bP/N3/CBif4092s9DjX9te2V7QTTYGZuXbzNd5FN65tBc8h6I ZqyPJdXb6mCsLvcjaevXOJ/HQXFuLvb8Jb9W7mQzLlGHWpsWwfLSnFFa3CphkT4q lpdCbS+ERxpeuiHtl7pZYQ8gS3awsqanO1n/e8n9QgoSrw0B0kiFjO2YXuqq92x8 WLiAfnfg4KFOMId/3m8of53BIR/fMQpVhKf4TYYdQ8Mz8TwWcBJB/K/mmlk7Z9ly 52PvN3LgjIhUDwiT5Hx7i9bDW/SPKekWyUpXF6GHSc1pGQfsP8tgQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrg5s6eg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:04 +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 5B4HtbE6019080; Thu, 4 Dec 2025 17:56:04 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 4aqrg5s6eb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:03 +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 5B4G44Fo021859; Thu, 4 Dec 2025 17:56:03 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4at8c6jbbd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:03 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4Htxnc43123066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:55:59 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A89720043; Thu, 4 Dec 2025 17:55:59 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB86B20040; Thu, 4 Dec 2025 17:55:55 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:55 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 12/17] pseries/smp: Trigger softoffline based on steal metrics Date: Thu, 4 Dec 2025 23:24:00 +0530 Message-ID: <20251204175405.1511340-13-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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: Fm2fUOblfS-MMrubUr6aOuAovAIP_ibQ X-Authority-Analysis: v=2.4 cv=Ir0Tsb/g c=1 sm=1 tr=0 ts=6931cb34 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=FOpSX02iUUlzJe458GUA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfXzH5h37RCypag CCwblen8QWnLe+fJsBdDHQmMtzkqPHZyQRpErufS0TjeQoNj8c3hcWF3/e0yJFSONnll0h44xut 0NsHUMjoP+83VDDvVWpk/SAzr3PYwUI+ltRxjx75+riyLC14MrbLGTs7QYkaHYeNqFwtc1dpL3C GScLGWxf/oocOLQNYEdJc9ywkMYN64zxK+k3UwHNTdaJF2IeWn60SOkojs44g19vJeeUWgooAW0 plIcSA1/fHFF5PKuTYIu36eEEbDn1eTcEVKKeSPThx6cWKtM5QqwTeWjRb6ZQ/4N5xUzJ3UHL9d 4etSHgiSKVA5uMEm58kZKVvYctnKMn+WhLQgjxEJhHow9QoXXHMUfudaNtOcLdrpi7ib7FyCrsu v3ALub4VJxULOJjMiFoDzS7AUmxogA== X-Proofpoint-GUID: Ljq-AuS19zSba1sj3Hwb21dCzsrOzBLx 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" Based on the steal metrics, update the number of CPUs that need to soft onlined/offlined. If LPAR continues to see steal above the given higher threshold, then continue to offline more CPUs. This will result in more CPUs of the active cores being used and LPAR should see lesser vCPU preemption. In the next interval, the steal metrics would also continue to drop. If LPAR continues to see steal below the lower threshold, then continue to online more cores. To avoid ping-pong behaviour, online/offline a core only if steal metrics trend is seen for at least 2 intervals. In a PowerVM environment schedules at a core granularity. Hence its preferable to soft online/offline an entire core. Online / Offline of only few CPUs from a core is neither going to reduce steal nor would the resources being used efficiently/effectively. A Shared LPAR on a PowerVM environment will have cores interleaved across multiple NUMA nodes. Hence choosing the last active core to offline and the first inactive core to online will most likely be able to balance NUMA. A more intelligent approach to select cores to online /offline may be needed in the future. Signed-off-by: Srikar Dronamraju --- arch/powerpc/platforms/pseries/lpar.c | 3 -- arch/powerpc/platforms/pseries/pseries.h | 3 ++ arch/powerpc/platforms/pseries/smp.c | 57 ++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms= /pseries/lpar.c index f8e049ac9364..f5caf1137707 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -662,9 +662,6 @@ machine_device_initcall(pseries, vcpudispatch_stats_pro= cfs_init); #define STEAL_MULTIPLE (STEAL_RATIO * STEAL_RATIO) #define PURR_UPDATE_TB tb_ticks_per_sec =20 -static void trigger_softoffline(unsigned long steal_ratio) -{ -} =20 static bool should_cpu_process_steal(int cpu) { diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platfo= rms/pseries/pseries.h index 68cf25152870..2527c2049e74 100644 --- a/arch/powerpc/platforms/pseries/pseries.h +++ b/arch/powerpc/platforms/pseries/pseries.h @@ -119,6 +119,9 @@ int dlpar_workqueue_init(void); =20 extern u32 pseries_security_flavor; void pseries_setup_security_mitigations(void); +#ifdef CONFIG_PPC_SPLPAR +void trigger_softoffline(unsigned long steal_ratio); +#endif =20 #ifdef CONFIG_PPC_64S_HASH_MMU void pseries_lpar_read_hblkrm_characteristics(void); diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/= pseries/smp.c index ec1af13670f2..4c83749018d0 100644 --- a/arch/powerpc/platforms/pseries/smp.c +++ b/arch/powerpc/platforms/pseries/smp.c @@ -51,6 +51,9 @@ * interface by prom_hold_cpus and is spinning on secondary_hold_spinloop. */ static cpumask_var_t of_spin_mask; +#ifdef CONFIG_PPC_SPLPAR +static cpumask_var_t cpus; +#endif =20 /* Query where a cpu is now. Return codes #defined in plpar_wrappers.h */ int smp_query_cpu_stopped(unsigned int pcpu) @@ -277,6 +280,14 @@ static __init void pSeries_smp_probe(void) } =20 #ifdef CONFIG_PPC_SPLPAR +/* + * Set higher threshold values to which steal has to be limited. Also set + * lower threshold values below which allow work to spread out to more + * cores. + */ +#define STEAL_RATIO_HIGH (10 * STEAL_RATIO) +#define STEAL_RATIO_LOW (5 * STEAL_RATIO) + static unsigned int max_virtual_cores __read_mostly; static unsigned int entitled_cores __read_mostly; static unsigned int available_cores; @@ -311,6 +322,49 @@ static unsigned int pseries_num_available_cores(void) =20 return available_cores; } + +void trigger_softoffline(unsigned long steal_ratio) +{ + int currcpu =3D smp_processor_id(); + static int prev_direction; + int cpu, i; + + if (steal_ratio >=3D STEAL_RATIO_HIGH && prev_direction > 0) { + /* + * System entitlement was reduced earlier but we continue to + * see steal time. Reduce entitlement further. + */ + cpu =3D cpumask_last(cpu_active_mask); + for_each_cpu_andnot(i, cpu_sibling_mask(cpu), cpu_sibling_mask(currcpu))= { + struct offline_worker *worker =3D &per_cpu(offline_workers, i); + + worker->offline =3D 1; + schedule_work_on(i, &worker->work); + } + } else if (steal_ratio <=3D STEAL_RATIO_LOW && prev_direction < 0) { + /* + * System entitlement was increased but we continue to see + * less steal time. Increase entitlement further. + */ + cpumask_andnot(cpus, cpu_online_mask, cpu_active_mask); + if (cpumask_empty(cpus)) + return; + + cpu =3D cpumask_first(cpus); + for_each_cpu_andnot(i, cpu_sibling_mask(cpu), cpu_sibling_mask(currcpu))= { + struct offline_worker *worker =3D &per_cpu(offline_workers, i); + + worker->offline =3D 0; + schedule_work_on(i, &worker->work); + } + } + if (steal_ratio >=3D STEAL_RATIO_HIGH) + prev_direction =3D 1; + else if (steal_ratio <=3D STEAL_RATIO_LOW) + prev_direction =3D -1; + else + prev_direction =3D 0; +} #endif =20 static struct smp_ops_t pseries_smp_ops =3D { @@ -336,6 +390,9 @@ void __init smp_init_pseries(void) smp_ops =3D &pseries_smp_ops; =20 alloc_bootmem_cpumask_var(&of_spin_mask); +#ifdef CONFIG_PPC_SPLPAR + alloc_bootmem_cpumask_var(&cpus); +#endif =20 /* * Mark threads which are still spinning in hold loops --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 93821359F99 for ; Thu, 4 Dec 2025 17:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871005; cv=none; b=orHFG5ajPYqfFkcAatjD6cVdH+0ZqG88cWVmhwOvFO2HW325C0wm4GH9JZ03OCuzJsIKwVDqoI9v3c3qVzAX5/Q0UUYQTZlRqnti3iA9FvRhOIAi8JOXFFe5yoC+ApBUGrzg28Sz90Ja/7dGDoc9e8QT2SU+Do4Kd3St1lhh4BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871005; c=relaxed/simple; bh=q2wrhQDryLhTPp3tA1K5yKEZWBrnRiOW5IKkmCmlt3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uSo6Bx3BFjNLvqggl/CX40SNjweWlLupD+WI1/f9SM7dT5vLMwVjHtd/Ovd7ANNWzeSdIthCcUjs0h3XGvqDFGcMFB+F21Q+YvPEJxuFc6DfWne+NIMNOmLbSnIBGpRH0lSbTyVbW1HeHElVo7X5Uj5HfmC5BGo/+JyPrx1R3sY= 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=eRg9eVDa; arc=none smtp.client-ip=148.163.156.1 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="eRg9eVDa" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4CVwkE013518; Thu, 4 Dec 2025 17:56:10 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=COHvKYjgKzz9JnJqB R21qXREb5HwbfkQOktMhWdqSPg=; b=eRg9eVDan64NzQCgvAJQD28SRJsfbWhFL RKVlLM81qofcj9iQBMfadDhwCTHfDPWcV87c1IMgV5ZWzrheA57/NqSxlVNFzcvT ZfE/RxF/2pe6S/ZKEZBxT3Mn4EnuW6t3sspqE5yHZYViV7dhlOhSy31cs3Pc8RLc uKJEgeT7rz3mv/b2Z6I8TvJiUfJhkKmuzInUw/FmuVimKqrRb0G/Y1T6IGXIDFSS weBWApxaScBHHxEZ8ZaQmMql1VY1CybOkleI/MHNBfzeTCObka7H7y3LHdJpYsMB L+LlrwfamzWwmw1DnB1iTThkTsYMKOiUgpkwXnr0NQ65tmpNKXiOA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrh79vv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:09 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4Hg50q026211; Thu, 4 Dec 2025 17:56:08 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 4aqrh79vv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:08 +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 5B4G8xq8021690; Thu, 4 Dec 2025 17:56:07 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4at8c6jbbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:07 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4Hu3Cd16318956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:56:03 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E77B520043; Thu, 4 Dec 2025 17:56:02 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FB0820040; Thu, 4 Dec 2025 17:55:59 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:55:59 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 13/17] pseries/smp: Account cores when triggering softoffline Date: Thu, 4 Dec 2025 23:24:01 +0530 Message-ID: <20251204175405.1511340-14-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Authority-Analysis: v=2.4 cv=dK+rWeZb c=1 sm=1 tr=0 ts=6931cb39 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=hMrejquCwrOoUXIZ0_UA:9 X-Proofpoint-GUID: _vx2ZrcX-PNX-n7NeBZdzw1v8eHZdwRE X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfXz1o2mbP6IcH1 OmMQ0MzVFzMZbjMEoDw3dXCwAhhF71D93YxPTBXSEOdtzs+smnbCvCM3LM2SHCaKDHXouLZZEBw hfxsigcRyxYK8u0dn2f0UYTI8lqS5oQ+8SnrVHfLNrCBF8mvRNq7oyE1k8lZnaHjpcoz4jbGbsR evuuEppTlo5nZqh/qQYkW4dYrBL4vLzgfPofmGcYxtnYwK011ETidVWxfaHVJtZT0B65WG6z7im RGg5YCa4GWPQZ1V4r1s5iZwP2V4K4JlTpqLhjEH4M8nByIiA9PSoeoyAn3MFmAZed8UTt/koxJd /L0hwxrp1pvPbOGqlyFUDmLGTf6xKJ2OED16UdrOEtOKc0bw7avlV3+TaKAymFQpoPIyJDbZTKv Kr7LNVbUdsQjzcWjat/KDP6cErtzvQ== X-Proofpoint-ORIG-GUID: Y6oyYVlwPGDCHU8eIffBBUvXwfclhGHw 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" On a shared LPAR is entitled to certain number of cores, i.e the number of cores that PowerVM hypervisor is committed to provide at any point of time. Hence based on steal metrics, soft offline such that at least soft-offline cores are available. Also when soft-onlining cores, unless DLPAR, ensure system can only online up to max virtual cores. Signed-off-by: Srikar Dronamraju --- arch/powerpc/platforms/pseries/smp.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/= pseries/smp.c index 4c83749018d0..69e209880b6f 100644 --- a/arch/powerpc/platforms/pseries/smp.c +++ b/arch/powerpc/platforms/pseries/smp.c @@ -327,25 +327,45 @@ void trigger_softoffline(unsigned long steal_ratio) { int currcpu =3D smp_processor_id(); static int prev_direction; + int success =3D 0; int cpu, i; =20 + /* + * Compare delta runtime versus delta steal time. + * [0]<----------->[EC]--------->[VP] + * [0]<------------------>{AC}-->[VP] + * EC =3D=3D Entitled Cores + * VP =3D=3D Virtual Processors + * AC =3D=3D Available Cores Varies between 0 to EC/VP. + * If Steal time is high, then reduce Available Cores. + * If steal time is low, increase Available Cores + */ if (steal_ratio >=3D STEAL_RATIO_HIGH && prev_direction > 0) { /* * System entitlement was reduced earlier but we continue to - * see steal time. Reduce entitlement further. + * see steal time. Reduce entitlement further if possible. */ + if (available_cores <=3D entitled_cores) + return; + cpu =3D cpumask_last(cpu_active_mask); for_each_cpu_andnot(i, cpu_sibling_mask(cpu), cpu_sibling_mask(currcpu))= { struct offline_worker *worker =3D &per_cpu(offline_workers, i); =20 worker->offline =3D 1; schedule_work_on(i, &worker->work); + success =3D 1; } + if (success) + available_cores--; } else if (steal_ratio <=3D STEAL_RATIO_LOW && prev_direction < 0) { /* * System entitlement was increased but we continue to see - * less steal time. Increase entitlement further. + * less steal time. Increase entitlement further if possible. */ + if (available_cores >=3D max_virtual_cores) + return; + cpumask_andnot(cpus, cpu_online_mask, cpu_active_mask); if (cpumask_empty(cpus)) return; @@ -356,7 +376,10 @@ void trigger_softoffline(unsigned long steal_ratio) =20 worker->offline =3D 0; schedule_work_on(i, &worker->work); + success =3D 1; } + if (success) + available_cores++; } if (steal_ratio >=3D STEAL_RATIO_HIGH) prev_direction =3D 1; --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 983F13590DB for ; Thu, 4 Dec 2025 17:56:41 +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=1764871003; cv=none; b=PdulwGMOrKq3PsAO+pwv3ZMo6PMi0cSuJ+biXT3obCHVdj3dHm76Mr2uIW9rrjKhnUwEJy5I6q5EuPlncmEVBePaPuyAilhq9mOF/SCIv52lQl/ocb2sS1xdzaaOdXxt67T1ZY5agx7FCktCFRk1zMd4PYnVSr2x7ByeqYHYtqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871003; c=relaxed/simple; bh=Bnt8mVnLHAEeju2KkXPSqmZi6tGivH3lNJbtOQZYkfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rRXYp5dnz6zaB89ypVr7S0N4j7/U7/zCMw44rP8kAGeoqvSPS5XQLfPtkDU9+pBCJWGnmdkmQ2xFvivj9DEpyXamkUmzKGj3PdIAwmyPasZdEIlLaVvFHz1bUvFD70h22q96zzsaQxenj4mV3bCKC/H8p5EHaV7kDS24lmohzv4= 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=npNBkVM1; 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="npNBkVM1" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4CIoHr010190; Thu, 4 Dec 2025 17:56:12 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=gBvk4eMk6v6ZAOxTB Gwue2xrVUEEoxsJgnPd2ac/fyw=; b=npNBkVM1tbJ3JUr5HJrj6rtcZD3Ab+qOM 9uXk/lGJ/Rh708lBvFROVXK2LJ6tz7dmbLOPjsoUeMgg9t96lXztNlpxpMCuVzSC DrbJl1yE08ZlB6hFzRpY82Bw5RcAxhuJ59Aebtg/2yRLo0Q+8jIYCEXr497Ou6hU W+StBDZ9cd3BfGiDkWEDwFrVklGV2J65uzMkf8p6VR5brdh2Y1cjRZJLF8oOFniw IK+P0TuNPxlK1OpWYvpX5s+G/4dURlQrbB2pq+LguRLDOGUuBRxUcTQrugNbYPvk 24qDCvbSM2A+G8qsvP5SBwKV0foQ4Juf3LoAIdMmWZ37Xg2Z5S8iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:12 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4HuBdw018464; Thu, 4 Dec 2025 17:56:11 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqp8q9e6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:11 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4G1MLm029338; Thu, 4 Dec 2025 17:56:10 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ardv1rvcu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:10 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4Hu6FR46203282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:56:06 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B3F6320043; Thu, 4 Dec 2025 17:56:06 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C6B920040; Thu, 4 Dec 2025 17:56:03 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:56:03 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 14/17] powerpc/smp: Assume preempt if CPU is inactive. Date: Thu, 4 Dec 2025 23:24:02 +0530 Message-ID: <20251204175405.1511340-15-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAwMCBTYWx0ZWRfX3yL8M1FQVfis im8nnAvYJT/jR7qKWigQ4v15uxYEjhX7o1H6AaQJVmaTX6M3tKWqJRJn4IenYRfAw2QFUc0B+G6 Qyg1cGu/5jChU1xSMkQuJdXg4z+dZD3ApBi9+uzDDbDN8D1w9IGm/qAusaaHvc/elrZHheGHPeQ kUYwvvp3y7B7BwWVgB3o3JlqH3d95zwN63IRRm14xX6Y0z79NWW7WtcE1QplMtgHs0Zuul0y36i ua2GbxKLer7R1I+aU2Jj9pBP7J3Ydk7POaVsXVAuD4kaatkb3HgwKNZWbbRzy7T2P+w4rXI4qI8 U/U43IoAbX3xu1sUjkH+sLrmoKLf2HKmbm/0s1dc4DXrvUCtZIeSAN716rPc6KnCxtgnskCHVe6 cZGv6i/w2CoKx0B6kMYIp81BWkrc+A== X-Authority-Analysis: v=2.4 cv=dIerWeZb c=1 sm=1 tr=0 ts=6931cb3c cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=R1vJ1bMZ7EzTfBZCLQ4A:9 X-Proofpoint-ORIG-GUID: sZ-3IVy9C2T-DcjEVeXc27zHs0lFgv6u X-Proofpoint-GUID: I5KCaBuqR44QxaNU3pBk_7-8f26bzBvN 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290000 Content-Type: text/plain; charset="utf-8" When a vCPU is marked inactive, it qualifies as preempted vCPU. And when a vCPU is marked active, we should hope that its not going to be preempted. Also with lower steal times, the chances of active vCPU being preempted reduces too. Signed-off-by: Srikar Dronamraju --- arch/powerpc/include/asm/paravirt.h | 62 +++++------------------------ 1 file changed, 9 insertions(+), 53 deletions(-) diff --git a/arch/powerpc/include/asm/paravirt.h b/arch/powerpc/include/asm= /paravirt.h index b78b82d66057..93c4e4f57cb3 100644 --- a/arch/powerpc/include/asm/paravirt.h +++ b/arch/powerpc/include/asm/paravirt.h @@ -145,6 +145,15 @@ static inline bool vcpu_is_preempted(int cpu) if (!is_shared_processor()) return false; =20 +#ifdef CONFIG_PPC_SPLPAR + /* + * Assume the target CPU to be preempted if it is above soft + * entitlement limit + */ + if (!is_kvm_guest()) + return !cpu_active(cpu); +#endif + /* * If the hypervisor has dispatched the target CPU on a physical * processor, then the target CPU is definitely not preempted. @@ -159,59 +168,6 @@ static inline bool vcpu_is_preempted(int cpu) if (!is_vcpu_idle(cpu)) return true; =20 -#ifdef CONFIG_PPC_SPLPAR - if (!is_kvm_guest()) { - int first_cpu, i; - - /* - * The result of vcpu_is_preempted() is used in a - * speculative way, and is always subject to invalidation - * by events internal and external to Linux. While we can - * be called in preemptable context (in the Linux sense), - * we're not accessing per-cpu resources in a way that can - * race destructively with Linux scheduler preemption and - * migration, and callers can tolerate the potential for - * error introduced by sampling the CPU index without - * pinning the task to it. So it is permissible to use - * raw_smp_processor_id() here to defeat the preempt debug - * warnings that can arise from using smp_processor_id() - * in arbitrary contexts. - */ - first_cpu =3D cpu_first_thread_sibling(raw_smp_processor_id()); - - /* - * The PowerVM hypervisor dispatches VMs on a whole core - * basis. So we know that a thread sibling of the executing CPU - * cannot have been preempted by the hypervisor, even if it - * has called H_CONFER, which will set the yield bit. - */ - if (cpu_first_thread_sibling(cpu) =3D=3D first_cpu) - return false; - - /* - * The specific target CPU was marked by guest OS as idle, but - * then also check all other cpus in the core for PowerVM - * because it does core scheduling and one of the vcpu - * of the core getting preempted by hypervisor implies - * other vcpus can also be considered preempted. - */ - first_cpu =3D cpu_first_thread_sibling(cpu); - for (i =3D first_cpu; i < first_cpu + threads_per_core; i++) { - if (i =3D=3D cpu) - continue; - if (vcpu_is_dispatched(i)) - return false; - if (!is_vcpu_idle(i)) - return true; - } - } -#endif - - /* - * None of the threads in target CPU's core are running but none of - * them were preempted too. Hence assume the target CPU to be - * non-preempted. - */ return false; } =20 --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 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 180AC359F92 for ; Thu, 4 Dec 2025 17:56:46 +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=1764871007; cv=none; b=POfsqN7UYuzqGlxKImEFYUM6k9ly4LsO3nm9pfdF/zAnOFNxuxm1sldmxs1XhDdxjPpytZtwFRMySwUXgTiE/xT5yPi7FHKK3FDnIMyBN+CSb0zhWHtMQnipFfD9cwBf3zQ9J9aGEP73yjKGc+WPzzEfT4lvqj+P4mi0HlY2P2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871007; c=relaxed/simple; bh=3xDEU7a+dcpyT6p4unhp6zUGCQzFd3HMR7zWIje2I00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ts7xkDzvQeOCrww2zy7uNHnnS0L+FdAkViWeLkTB/IKyXHUt8UEoj78fo2uamoKJ+7fpOLhXg1HRyKUwkg/jwa9MbdSSSyp5zaPmjSHM6izM0Jo2KlXe127icyThOOzTeRBegNSugAr+/d+5r5w+pFoyp6GW5+RRyV4Uvm59yhw= 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=bZOOj5+3; 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="bZOOj5+3" 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 5B4ARExC025115; Thu, 4 Dec 2025 17:56:16 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=ux0EhBWJUf5wZJAGz UVeEs+JHElwVRFtaD5oNwlf0HM=; b=bZOOj5+3RxGyH+FGQ4N1WrNWrKk3kX8fS T3TPCtRTErvoKxbodAEn9RhzwCAc79cGfloAou4BBXZCPvlE4chzLasYEOFd0s4M M3s5o4VJwBJrhrK/Mj8kA+Sljnz/GAtIkr2ICrVeOb+3ireC8TvtrEc91sMysmFv ymuKQ9hQ8Ttw4RrQ1X/Yp7QMDelu05iKJJeeR+HUV3oGKeOmsXEhYlaFBv/jquK1 NbHFTSp7uzFvGGNOFnHfyALqMuVjnM10BYOh5Havs4e01qpTjLlGQkhMELYeres6 I17zzbiZXRsILW2y9Sg8NX25QJ4SIqHNc+ldoK+G18Klcl/qWKg5A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrg5s6f1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:15 +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 5B4HgGoB024742; Thu, 4 Dec 2025 17:56:15 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrg5s6ew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:15 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4FAKAP019051; Thu, 4 Dec 2025 17:56:14 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arbhy96v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:14 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HuAMA27853372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:56:10 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A9A120043; Thu, 4 Dec 2025 17:56:10 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04C7B20040; Thu, 4 Dec 2025 17:56:07 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:56:06 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 15/17] pseries/hotplug: Update available_cores on a dlpar event Date: Thu, 4 Dec 2025 23:24:03 +0530 Message-ID: <20251204175405.1511340-16-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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: wOfvkC0uOapX7Jh4z6xnd_FzMcZQjtFY X-Authority-Analysis: v=2.4 cv=Ir0Tsb/g c=1 sm=1 tr=0 ts=6931cb40 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=WWXCdL_Rce5lBg350DQA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfXyDHhUZlL/rbr muAdVF4jCCrEnyxd0+8tqrFy8tA5zov3Ron2eG7LTLJTot7YzcYv2Wu1uxyE6Nd6N1Ye60mKfH2 8EU7466aialjO8EsG/boJ9RTRFri6yUQG/nVDx27MBmp25FD+N4zHuk/d+wMT0GKGv5qU5cXGSe XiMgwvsb/THc1LP4yPkRUhDxukBbvCtYkU4xa9ICuTBfXZYdaZxx8SvmJgTqIZnwWoXILsbiUri vdgaXSEhG4f4lJaw5xTOLoxFMRzzTlS3ThFnjWfShV00ItGPacua0x/POdnl/gHkOZRYo4VTeXd fKlQZA4O3ymSgtJfem5oEl4ASJnWJ3yGbBY3A7JbkyF1xMJls4jc8xxbJBm8JeWAwwVr8JiHbPj xneJR98hvjWaHsuGk9yFcpU4W4dXGA== X-Proofpoint-GUID: rS9Up9g0pBVUYbf6f-AaloNfu_F1ttWL 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" Everytime, a DLPAR CPU event happens on a shared LPAR, the number of entitled_cores, and virtual processors allotted to the LPAR can change. Hence available_cores has to be updated to be in sync. Signed-off-by: Srikar Dronamraju --- arch/powerpc/platforms/pseries/hotplug-cpu.c | 6 ++++++ arch/powerpc/platforms/pseries/pseries.h | 1 + arch/powerpc/platforms/pseries/smp.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/pl= atforms/pseries/hotplug-cpu.c index bc6926dbf148..4ba8cc049b5b 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -284,6 +284,9 @@ static int pseries_add_processor(struct device_node *np) =20 out: cpu_maps_update_done(); +#ifdef CONFIG_PPC_SPLPAR + pseries_num_available_cores(); +#endif free_cpumask_var(cpu_mask); return rc; } @@ -323,6 +326,9 @@ static void pseries_remove_processor(struct device_node= *np) "with physical id 0x%x\n", thread); } cpu_maps_update_done(); +#ifdef CONFIG_PPC_SPLPAR + pseries_num_available_cores(); +#endif } =20 static int dlpar_offline_cpu(struct device_node *dn) diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platfo= rms/pseries/pseries.h index 2527c2049e74..1eed08752a03 100644 --- a/arch/powerpc/platforms/pseries/pseries.h +++ b/arch/powerpc/platforms/pseries/pseries.h @@ -121,6 +121,7 @@ extern u32 pseries_security_flavor; void pseries_setup_security_mitigations(void); #ifdef CONFIG_PPC_SPLPAR void trigger_softoffline(unsigned long steal_ratio); +unsigned int pseries_num_available_cores(void); #endif =20 #ifdef CONFIG_PPC_64S_HASH_MMU diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/= pseries/smp.c index 69e209880b6f..a3daac4c3e1e 100644 --- a/arch/powerpc/platforms/pseries/smp.c +++ b/arch/powerpc/platforms/pseries/smp.c @@ -293,7 +293,7 @@ static unsigned int entitled_cores __read_mostly; static unsigned int available_cores; =20 /* Get pseries soft entitlement limit */ -static unsigned int pseries_num_available_cores(void) +unsigned int pseries_num_available_cores(void) { unsigned int present_cores =3D num_present_cpus() / threads_per_core; unsigned long retbuf[PLPAR_HCALL9_BUFSIZE]; --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 36D3A350A3E for ; Thu, 4 Dec 2025 17:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871021; cv=none; b=uaICSjp5PFqCRsnD4fUDpgG+g4tJtrGiPdnbXSslDwZinoed95y+230VI9HIukpIDIhzjerGHHnQa7KzSClqIeN+wFywP1eOFHD0ru/3CrCPnmj4uxpyFrwD/VGnjrAMEXrdAmTo6Rkf6y15pZLt5mo9Eu2hxjsokU5zaM26c9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871021; c=relaxed/simple; bh=xW7vrIolOiTgfh5naSngmIAre+JZIa6csPbN+wjdI0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ekbc4HgZ35Vxe6cIU7WPLAnjweVoIomJhqDD331mvDlRfUErQYaEHaDEtQDI1W2mUVcJazg/UMpMziIkMemzVsF8kMTbvnJs9F8aDtY0eDVPpBLT68R7JBrjB6thBeakWoucr3XfVVHWeO6ITTLdUOTtdjwEQF2N/dIQrj1tBW0= 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=Ad0TnzAn; arc=none smtp.client-ip=148.163.156.1 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="Ad0TnzAn" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4D0P6o007009; Thu, 4 Dec 2025 17:56:20 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=mlpFgm7ForCx1wVbr ClPH+oaDY6Ooxw2Cvy2EE53C0k=; b=Ad0TnzAn4WMhluNwES1hPnnE4b+7HPKyP vr+lKHZEFntXLeJiU8kMX7ObNTESAEjHgtZyWsWSvbXz/x2ajHNezeuN/URrxCqY T137OmZVyBkpLB5unBkp/0r0D4JsyxfPG5dp2efZ6dgzYDtHCyydxIreSl+pm5vj 8YnYVQ7Rb4e7sB5lcaZjFb+hJA2vmNUTG4TVmyG2EH/guq0eozmCcoay5Anny1qA xpW4QAhxoYZXs8zqRktVL3OErZRpU0+Nmx7T4NNX1hEiOYdF9Cgt94Rg5W20SlF4 0Q7pBdKWbe2mEfE1LXnL9yUOeiDJJJiDDkLPXfmhORya3cLJHN09g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja1tbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:20 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4HuJSJ010965; Thu, 4 Dec 2025 17:56:19 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 4aqrja1tbm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:19 +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 5B4GHegV021731; Thu, 4 Dec 2025 17:56:18 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4at8c6jbcg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:18 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HuE1K47579394 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:56:14 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41F5920043; Thu, 4 Dec 2025 17:56:14 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C008320040; Thu, 4 Dec 2025 17:56:10 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:56:10 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 16/17] pseries/smp: Allow users to override steal thresholds Date: Thu, 4 Dec 2025 23:24:04 +0530 Message-ID: <20251204175405.1511340-17-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-GUID: grM7ksqg05fc0zyk6Jf5luq4L1sLl7QD X-Proofpoint-ORIG-GUID: lIT3fTsKSgeSOSZOVu_7aTC0h3wmOs2R X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfXx2Wd0mAODIb1 2SIn1PAlKT/M3dItrJU/K7MSZGxABGvpR+OJg+vop7J8b1zWuXXEP1nVfXGMc8pKVZcnDzr6jkr hZorn7QH8NsvxK71BHfEy2Ps3zf95xJjrdjsVKHIAUz7US1xWhroVURiB/ymHLpvvY0/RWdMKpr v/EF/19jBY74yFZ5c2W555nyN3HBzQM0uimZPDnSDb+x4QUJl62nONfzOIEOloH1AL0ozME7G28 JAinplCabXKbxJ/VoCUeYr782H9GPQ/tNy3SxQOrGbdDBxAjA51LXpMItbih7XG4cz6wwaDWJFG EO0gvLe/yemllrNV5D+uUoWSCgyJhidUyTGqdu46i9DkZtmS1U6EUi9AgEZkHfZyysW5V6qLXXC 0dfBEMoWBWOhTwaA4DROIJVu7fzXmg== X-Authority-Analysis: v=2.4 cv=dYGNHHXe c=1 sm=1 tr=0 ts=6931cb44 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=D5CivmakTvuzdLjxN4gA:9 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" Different shared LPARs will have different entitled cores, different number of cores in shared pools and different virtual processors. Also the number and configuration of other shared LPARs sharing the same pool will differ in each case. Hence a single set of threshold values may not work. Hence provide a debugfs interface by which a privileged user can set the high and low threshold values. Signed-off-by: Srikar Dronamraju --- arch/powerpc/platforms/pseries/smp.c | 30 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/= pseries/smp.c index a3daac4c3e1e..909f2d58384a 100644 --- a/arch/powerpc/platforms/pseries/smp.c +++ b/arch/powerpc/platforms/pseries/smp.c @@ -21,6 +21,9 @@ #include #include #include +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_PPC_SPLPAR) +#include +#endif =20 #include #include @@ -285,9 +288,6 @@ static __init void pSeries_smp_probe(void) * lower threshold values below which allow work to spread out to more * cores. */ -#define STEAL_RATIO_HIGH (10 * STEAL_RATIO) -#define STEAL_RATIO_LOW (5 * STEAL_RATIO) - static unsigned int max_virtual_cores __read_mostly; static unsigned int entitled_cores __read_mostly; static unsigned int available_cores; @@ -323,6 +323,9 @@ unsigned int pseries_num_available_cores(void) return available_cores; } =20 +static u8 steal_ratio_high =3D 10; +static u8 steal_ratio_low =3D 5; + void trigger_softoffline(unsigned long steal_ratio) { int currcpu =3D smp_processor_id(); @@ -340,7 +343,7 @@ void trigger_softoffline(unsigned long steal_ratio) * If Steal time is high, then reduce Available Cores. * If steal time is low, increase Available Cores */ - if (steal_ratio >=3D STEAL_RATIO_HIGH && prev_direction > 0) { + if (steal_ratio >=3D STEAL_RATIO * steal_ratio_high && prev_direction > 0= ) { /* * System entitlement was reduced earlier but we continue to * see steal time. Reduce entitlement further if possible. @@ -358,7 +361,7 @@ void trigger_softoffline(unsigned long steal_ratio) } if (success) available_cores--; - } else if (steal_ratio <=3D STEAL_RATIO_LOW && prev_direction < 0) { + } else if (steal_ratio <=3D STEAL_RATIO * steal_ratio_low && prev_directi= on < 0) { /* * System entitlement was increased but we continue to see * less steal time. Increase entitlement further if possible. @@ -381,9 +384,9 @@ void trigger_softoffline(unsigned long steal_ratio) if (success) available_cores++; } - if (steal_ratio >=3D STEAL_RATIO_HIGH) + if (steal_ratio >=3D STEAL_RATIO * steal_ratio_high) prev_direction =3D 1; - else if (steal_ratio <=3D STEAL_RATIO_LOW) + else if (steal_ratio <=3D STEAL_RATIO * steal_ratio_low) prev_direction =3D -1; else prev_direction =3D 0; @@ -437,3 +440,16 @@ void __init smp_init_pseries(void) =20 pr_debug(" <- smp_init_pSeries()\n"); } + +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_PPC_SPLPAR) +static int __init steal_ratio_debugfs_init(void) +{ + if (!firmware_has_feature(FW_FEATURE_SPLPAR)) + return 0; + + debugfs_create_u8("steal_high", 0600, arch_debugfs_dir, &steal_ratio_high= ); + debugfs_create_u8("steal_low", 0600, arch_debugfs_dir, &steal_ratio_low); + return 0; +} +machine_arch_initcall(pseries, steal_ratio_debugfs_init); +#endif /* CONFIG_DEBUG_FS && CONFIG_PPC_SPLPAR*/ --=20 2.43.7 From nobody Sun Feb 8 01:31:26 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 C175E34FF79 for ; Thu, 4 Dec 2025 17:56:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871019; cv=none; b=bdX1l1gWJJE6/FK+dfSpalvMeabwsZpo2J7OMb07NdaSYd+WZ4bcvJq58HZanb3MZhvwi8OU8Lmg4/JJkddTkdy5mDjFctrEjAGr4kUz5gFUSbgSKU8oaU3jT5uRr6sB5xHiIqoD6nOspRYvw4v7cWC1VVJDhydoFmHZ/B10DBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764871019; c=relaxed/simple; bh=n0FnMbPU6Awhr5dco7+1fEZQHcMmZvvfEWLy33vxCcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CZIvdGTMXS/M1C/8iczDyhR37cm9IfJaIyuhoUEjccHskE3w6wLQP0R1ErjhW4/7AeFeyc3V30WRwwU4sqqgeNNNptEqc8pKGG/ljAKhH7a7+ZyfovuLkvcSYoEOSIxfbeZOiuX72XAlbYpws+5rEYpzGBUgbZsHODfJmCPZdTs= 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=j5S4S+1V; arc=none smtp.client-ip=148.163.156.1 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="j5S4S+1V" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4B2KH1014613; Thu, 4 Dec 2025 17:56:24 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=UikS5TkXcNc8h8b6t Ypk0p5GLnY/uUu63XCX0ekANJg=; b=j5S4S+1Vesxx/U6OLSeAMzAqXhWOOKxyc Q6J53knusEKWbJ4dfjj847npJHkLSoMT9x0qxDSt10uZD+yMvFakcH8KwkFCBFSa 3uP6cKzhsuKtNTthexJWlNX+y0iziW8++2ybKQtW2I91gZAigvDGjvo77yzn4eXO 3kZKZAgOEK/5chR+Ncg+NLrdF0Axki4sdW2tnQWHgnTujooeBUYlhnmv9VvUukDv rgQzO/3uWb4MQHWG8YXxhB/grkEQc9IKMkj7MsQu/QRHFXP8GaX2v3FrI6cTq/G8 CGyL0EiIlK5yXQ8PpqsKSvW9wO5wQSERzl7Q61MnjMnUnLCYe5gvA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja1tc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:24 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5B4HuNYp011085; Thu, 4 Dec 2025 17:56:23 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrja1tbu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:23 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B4FXrQs010240; Thu, 4 Dec 2025 17:56:22 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arcnkh2v3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Dec 2025 17:56:21 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B4HuI8u45744424 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Dec 2025 17:56:18 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0822E2004B; Thu, 4 Dec 2025 17:56:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87CC220040; Thu, 4 Dec 2025 17:56:14 +0000 (GMT) Received: from sapthagiri.in.ibm.com (unknown [9.39.29.188]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 4 Dec 2025 17:56:14 +0000 (GMT) From: Srikar Dronamraju To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Peter Zijlstra Cc: Ben Segall , Christophe Leroy , Dietmar Eggemann , Ingo Molnar , Juri Lelli , K Prateek Nayak , Madhavan Srinivasan , Mel Gorman , Michael Ellerman , Nicholas Piggin , Shrikanth Hegde , Srikar Dronamraju , Steven Rostedt , Swapnil Sapkal , Thomas Huth , Valentin Schneider , Vincent Guittot , virtualization@lists.linux.dev, Yicong Yang , Ilya Leoshkevich Subject: [PATCH 17/17] pseries/lpar: Add debug interface to set steal interval Date: Thu, 4 Dec 2025 23:24:05 +0530 Message-ID: <20251204175405.1511340-18-srikar@linux.ibm.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251204175405.1511340-1-srikar@linux.ibm.com> References: <20251204175405.1511340-1-srikar@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-GUID: ni3vhbmp42pzMrrHuc6bnF_Kzql4ImFA X-Proofpoint-ORIG-GUID: DAgezDF_G1mL2zRPjpvzMWkMiCPNhsPZ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAyMCBTYWx0ZWRfX2HJrKpeW8ZP3 S8JNVf73b2KIBPAzcIfTRQ7qp4G/iE/NRxRbPMSG2YsgmfNB+jOt4JIto+3k1M2wDJhyWqQQdN0 uGSW2ZGq8Glj3wRmBTiIbXFDbDK9OtA0B7E1iTEED4HWXsXr8xL0a4h75Cjp+rxn+C8GoWLNQY/ aq417TvC/ewmG6jNeYZoxT0/MyrFFDNiezE114VFNKRABSVvsWaeLhuSYHQmsoipOVpwSTVdIwr TXOqkjnrFlzz0mk6xtH9LcgyevRUfI+WHt8CYSMLBFxzXdyiJe+lIUtniFVd5eQocIIK/3rQ2j+ Hg8BYcTrxFE4H6pLE58lrIkg5LZpWA6R6IG84e40Z+DTiB3wz8wZPNyL/MF7dS+itIUmjctCPfd Z3HEccxcu089gz02Ao4YIYbV4uM7tw== X-Authority-Analysis: v=2.4 cv=dYGNHHXe c=1 sm=1 tr=0 ts=6931cb48 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=WutiPhbOZldT-Hsz3twA:9 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-12-04_04,2025-12-04_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290020 Content-Type: text/plain; charset="utf-8" Currently steal metrics are processed on CPU 0 at a 2 second interval. However the right value for processing the steal interval has yet to be discovered. If a too small value is provided, LPAR may end up adjusting too frequently and also the steal metrics may also be unreliable. If too large value is provided, LPAR may lose the opportunity for soft online and offline. Hence enable a debug interface for privileged users to specify steal interval. Signed-off-by: Srikar Dronamraju --- arch/powerpc/platforms/pseries/lpar.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms= /pseries/lpar.c index f5caf1137707..4f7b217a4eb3 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -660,8 +660,8 @@ machine_device_initcall(pseries, vcpudispatch_stats_pro= cfs_init); =20 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING #define STEAL_MULTIPLE (STEAL_RATIO * STEAL_RATIO) -#define PURR_UPDATE_TB tb_ticks_per_sec =20 +static u8 steal_interval =3D 1; =20 static bool should_cpu_process_steal(int cpu) { @@ -674,8 +674,8 @@ static bool should_cpu_process_steal(int cpu) extern bool process_steal_enable; static void process_steal(int cpu) { + unsigned long steal_ratio, delta_tb, interval_tb; static unsigned long next_tb, prev_steal; - unsigned long steal_ratio, delta_tb; unsigned long tb =3D mftb(); unsigned long steal =3D 0; unsigned int i; @@ -696,14 +696,18 @@ static void process_steal(int cpu) steal +=3D be64_to_cpu(READ_ONCE(lppaca->enqueue_dispatch_tb)); } =20 + if (!steal_interval) + steal_interval =3D 1; + + interval_tb =3D steal_interval * tb_ticks_per_sec; if (next_tb && prev_steal) { - delta_tb =3D max(tb - (next_tb - PURR_UPDATE_TB), 1); + delta_tb =3D max(tb - (next_tb - interval_tb), 1); steal_ratio =3D (steal - prev_steal) * STEAL_MULTIPLE; steal_ratio /=3D (delta_tb * num_online_cpus()); trigger_softoffline(steal_ratio); } =20 - next_tb =3D tb + PURR_UPDATE_TB; + next_tb =3D tb + interval_tb; prev_steal =3D steal; } =20 @@ -2081,6 +2085,9 @@ static int __init vpa_debugfs_init(void) debugfs_create_file(name, 0400, vpa_dir, (void *)i, &vpa_fops); } =20 +#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING + debugfs_create_u8("steal_interval_secs", 0600, arch_debugfs_dir, &steal_i= nterval); +#endif return 0; } machine_arch_initcall(pseries, vpa_debugfs_init); --=20 2.43.7