From nobody Tue Dec 2 02:29:40 2025 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2D8E364038 for ; Wed, 19 Nov 2025 12:46:28 +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=1763556390; cv=none; b=THBi1uMEG9NB3yHY/UVXs+p/tXmB7WmX8EAfeNmkpTArdOHfMLlsTyOz/GetsQJsW/ex72WDvyu7zefadWjYigheJm6kNNmzaS3zutMxqdfpUJaqXxl65z6XwNj9s4qWXzbPYZt9mE46ja/32/1at4BbmgjESwbv0Au1cXmzipg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763556390; c=relaxed/simple; bh=MqiQpjnN49QjL54CkTYwS3pompwMAxCIRnOx7B59kjc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aYFAPBE0clAOXfP8yYLbNjAgzklAweK0GnV69o/zhm9j05Tw9HC/vQFuKENvG+Nho2zFf4DMCDwFKMmaRVxC5fIgEgRFVfq6aSvKlB5ViB1mgVIEYXUuALHwkLruAr5SAgMamb5OY0bUT0sCBMXC6Jwt9NxXIHxvYgaGqxaT7A0= 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=gmHjMfuM; 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="gmHjMfuM" 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 5AJ7viZV019885; Wed, 19 Nov 2025 12:46: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=AmpKMuL3w7icau4MK INf+cSEFiv6NLC2GZgmKjHG7h8=; b=gmHjMfuMr0sxe3YNw0G3cZim2kl8V4D5y wfTi4Yli/VGu7EbFxdvOMFp5KqnmUnvVzFO3f3GSh96b9yoHh0qRo2v2hEhTWHTd 8YjSNGVJU5kFsKWTFot7pRU8k9nVZG6t1sKMhwq4bW6WiYFjPXngFlfLVTyrRR0m CDJZZEB/yBD2X8X+swFsIBQ7LR5bxTo5M5PNrFX0P1XRFcKUNLQELl9qBWL65B7a sRm+BLNC6pwyGnALXerXoBPBJAFwg9rMRnDObcoELdn9dpJ4q8ryBl1aRaPC2XiO kyaHKL+KscOdM+BWpzO6jko4kdJJfxzI+sloxLCExvjvnIVlRKYsw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aejgwymdb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 12:46:10 +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 5AJCilSK029186; Wed, 19 Nov 2025 12:46:10 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 4aejgwymd9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 12:46:09 +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 5AJCeBYs017318; Wed, 19 Nov 2025 12:46:09 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4af6j1rcfc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 12:46:08 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5AJCk5Yk38535656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 12:46:05 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5082A20043; Wed, 19 Nov 2025 12:46:05 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18ACA20040; Wed, 19 Nov 2025 12:46:01 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.25.220]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 19 Nov 2025 12:46:00 +0000 (GMT) From: Shrikanth Hegde To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: sshegde@linux.ibm.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, tglx@linutronix.de, yury.norov@gmail.com, maddy@linux.ibm.com, srikar@linux.ibm.com, gregkh@linuxfoundation.org, pbonzini@redhat.com, seanjc@google.com, kprateek.nayak@amd.com, vschneid@redhat.com, iii@linux.ibm.com, huschle@linux.ibm.com, rostedt@goodmis.org, dietmar.eggemann@arm.com, christophe.leroy@csgroup.eu Subject: [PATCH 15/17] powerpc: add debugfs file for controlling handling on steal values Date: Wed, 19 Nov 2025 18:14:47 +0530 Message-ID: <20251119124449.1149616-16-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251119124449.1149616-1-sshegde@linux.ibm.com> References: <20251119124449.1149616-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: GumJZcUnzEqyEvdLHeKkHzJYT6jSGsLt X-Authority-Analysis: v=2.4 cv=YqwChoYX c=1 sm=1 tr=0 ts=691dbc12 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=KSc5eBifJ7cFlDAX9ZYA:9 X-Proofpoint-ORIG-GUID: -0_-Hn2JQa6yuz485H47m9tjBaEzsdtX X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMiBTYWx0ZWRfX8J+nl7YhfEJe DAJD4NyHFryy8UV1JOclKyHxlW+HRspA1uXWPqfJ2BTylZZXyquxNzEgi9eXBTw0by78quT8h/n KD+/hVOOwLzW4WTRbPb8XIGx3zmB13V5CdUoL+C35+xzq9p0jjEiKW8pA/XMAdbrejduAjM9qOe msOpdVlk0kT630Rqddd8xZe75GXIaDEWzePqn/6eO/HEq5fZNX8zD2WadrCtw7uQBjXGbK4ZJJW Z0r1R+hIzs+r9+lOzPW3nhHQWp8w61aIk4UXdaNjiV/Btjsqs4eTlQ3OpI2P5IvAmI4YnQSufYv 7fjyN5lL6eQNjbKgzQ08UytBqIVKosRsgW+mujs6xhgWJcIdLb2vhq+aa8je/R98fqsyYOjaqka 39xKxs8lFVu0C5T1KhzKRF5Zwupr7w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-19_03,2025-11-18_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511150032 Content-Type: text/plain; charset="utf-8" Since the low,high threshold for steal time can change based on the system, make these values tunable. Values are be to given as expected percentage value * 100. i.e one wants say 8% of steal time is high, then should specify 800 as the high threshold. Similar value computation holds true for low threshold. Provide one more tunable to control how often steal time compution is done. By default it is 1 second. If one thinks thats too aggressive can increase it. Max value is 10 seconds since one should act relatively fast based on steal values. Signed-off-by: Shrikanth Hegde --- arch/powerpc/platforms/pseries/lpar.c | 94 ++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms= /pseries/lpar.c index c16d97e1a1fe..090e5c48243b 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -662,7 +662,8 @@ machine_device_initcall(pseries, vcpudispatch_stats_pro= cfs_init); #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING =20 #define STEAL_MULTIPLE 10000 -#define PURR_UPDATE_TB NSEC_PER_SEC +static int steal_check_freq =3D 1; +#define PURR_UPDATE_TB (steal_check_freq * NSEC_PER_SEC) =20 static bool should_cpu_process_steal(int cpu) { @@ -2106,9 +2107,6 @@ void pseries_init_ec_vp_cores(void) available_cores =3D max(entitled_cores, virtual_procs); } =20 -#define STEAL_RATIO_HIGH 400 -#define STEAL_RATIO_LOW 150 - /* * [0]<----------->[EC]---->{AC}-->[VP] * EC =3D=3D Entitled Cores. Guaranteed number of cores by hypervsior. @@ -2120,6 +2118,9 @@ void pseries_init_ec_vp_cores(void) * If steal time is low, increase Available Cores */ =20 +static unsigned int steal_ratio_high =3D 400; +static unsigned int steal_ratio_low =3D 150; + void update_soft_entitlement(unsigned long steal_ratio) { static int prev_direction; @@ -2128,7 +2129,7 @@ void update_soft_entitlement(unsigned long steal_rati= o) if (!entitled_cores) return; =20 - if (steal_ratio >=3D STEAL_RATIO_HIGH && prev_direction > 0) { + 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. @@ -2145,7 +2146,7 @@ void update_soft_entitlement(unsigned long steal_rati= o) } available_cores--; =20 - } else if (steal_ratio <=3D STEAL_RATIO_LOW && prev_direction < 0) { + } 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. @@ -2160,13 +2161,90 @@ void update_soft_entitlement(unsigned long steal_ra= tio) =20 available_cores++; } - if (steal_ratio >=3D STEAL_RATIO_HIGH) + if (steal_ratio >=3D steal_ratio_high) prev_direction =3D 1; - else if (steal_ratio <=3D STEAL_RATIO_LOW) + else if (steal_ratio <=3D steal_ratio_low) prev_direction =3D -1; else prev_direction =3D 0; } + +/* + * Any value above this set threshold will reduce the available cores + * Value can't be more than 100% and can't be less than low threshould val= ue + * Specifying 500 means 5% steal time + */ + +static int pv_steal_ratio_high_set(void *data, u64 val) +{ + if (val > 10000 || val < steal_ratio_low) + return -EINVAL; + + steal_ratio_high =3D val; + return 0; +} + +static int pv_steal_ratio_high_get(void *data, u64 *val) +{ + *val =3D steal_ratio_high; + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(fops_pv_steal_ratio_high, pv_steal_ratio_high_get, + pv_steal_ratio_high_set, "%llu\n"); + +static int pv_steal_ratio_low_set(void *data, u64 val) +{ + if (val < 1 || val > steal_ratio_high) + return -EINVAL; + + steal_ratio_low =3D val; + return 0; +} + +static int pv_steal_ratio_low_get(void *data, u64 *val) +{ + *val =3D steal_ratio_low; + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(fops_pv_steal_ratio_low, pv_steal_ratio_low_get, + pv_steal_ratio_low_set, "%llu\n"); + +static int pv_steal_check_freq_set(void *data, u64 val) +{ + if (val < 1 || val > 10) + return -EINVAL; + + steal_check_freq =3D val; + return 0; +} + +static int pv_steal_check_freq_get(void *data, u64 *val) +{ + *val =3D steal_check_freq; + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(fops_pv_steal_check_freq, pv_steal_check_freq_get, + pv_steal_check_freq_set, "%llu\n"); + +static int __init steal_debugfs_init(void) +{ + if (!is_shared_processor() || is_kvm_guest()) + return 0; + + debugfs_create_file("steal_ratio_high", 0600, arch_debugfs_dir, + NULL, &fops_pv_steal_ratio_high); + debugfs_create_file("steal_ratio_low", 0600, arch_debugfs_dir, + NULL, &fops_pv_steal_ratio_low); + debugfs_create_file("steal_check_frequency", 0600, arch_debugfs_dir, + NULL, &fops_pv_steal_check_freq); + + return 0; +} + +machine_arch_initcall(pseries, steal_debugfs_init); #else void pseries_init_ec_vp_cores(void) { return; } void update_soft_entitlement(unsigned long steal_ratio) { return; } --=20 2.47.3