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 DE3C031ED84 for ; Wed, 19 Nov 2025 06:23:00 +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=1763533383; cv=none; b=vETn79E7hL4jcrITTuHOuGqzrrYVermeWVUoFtxPXhbpznv0TE1rKvTUV+frR82il9DDgv7g43bgsxeUvf3xKNIsf0bOlA3E2fKAuBQHq421i/mDzT+68c2GT42wUMJTfvYpR6NxOkOBspqA3sQ5jMhgTMBIn+NpkCAf9H6HHpg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763533383; c=relaxed/simple; bh=MqiQpjnN49QjL54CkTYwS3pompwMAxCIRnOx7B59kjc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+jEQ3iAbbYKVZok+2l+sR4+om2GsBNVnUXL3ipF+NMv9HpG4o/hUu7nx6E9YUSr50G60R4wTijCz0Tlp8bCdrvvYtozz5kCstR+pXUCzbrl6US8PptANN/GdpUgLcfPszGvehRXTrQM/ov2l5uflI3iWf+ZjfqHqBPTC8frgCg= 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=o37QeSkZ; 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="o37QeSkZ" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AJ5ZEh0017282; Wed, 19 Nov 2025 06:22:41 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=o37QeSkZMic2ZQKQ8Tz6zz8IDKWSnsE0F CM9LtXVmzFpYVoKfjqvokK0nAgQZ82zQkNcJSIsp8BejRvSX59xqQrpM9GvndwZT 8esHTA5tmCRsIN9IlqVh/PSQd9/GLfJYog+rhVrpU5LMVvzmD+Wsybn4/3dyp/+6 TfLk7nPVqSUFuKmoUijCjDagqAvH+jA25hq/u1Je5ouzK2E1ck+rmK1krilnYhy8 BJoyHIqLtJhG3vINsjchlRcsarppn6lrWtltWkVTxxie3G9+I4LrqNfMwN2F0FnQ nsUumGvDwrEytmo99gX/eb9bSNWz+c4wlWXZVFzAwQ7zKKab52SRQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aejjtx56p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 06:22:41 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 5AJ6JRNU028691; Wed, 19 Nov 2025 06:22:40 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 4aejjtx56m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 06:22:40 +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 5AJ2lxZB030791; Wed, 19 Nov 2025 06:22:40 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4af47xy94n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 06:22:39 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5AJ6MaY249676648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 06:22:36 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E72FF2004D; Wed, 19 Nov 2025 06:22:35 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F47E20040; Wed, 19 Nov 2025 06:22:32 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.25.220]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 19 Nov 2025 06:22:31 +0000 (GMT) From: Shrikanth Hegde To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: sshegde@linux.ibm.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, tglx@linutronix.de, yury.norov@gmail.com, maddy@linux.ibm.com, srikar@linux.ibm.com, gregkh@linuxfoundation.org, pbonzini@redhat.com, seanjc@google.com, kprateek.nayak@amd.com, vschneid@redhat.com, iii@linux.ibm.com, huschle@linux.ibm.com, rostedt@goodmis.org, dietmar.eggemann@arm.com, christophe.leroy@csgroup.eu Subject: [RFC PATCH v4 15/17] powerpc: add debugfs file for controlling handling on steal values Date: Wed, 19 Nov 2025 11:50:58 +0530 Message-ID: <20251119062100.1112520-16-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251119062100.1112520-1-sshegde@linux.ibm.com> References: <20251119062100.1112520-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: NRNUqgjkv0GcbfqgAqz-QbJz39sCqPjH X-Proofpoint-ORIG-GUID: -Vb2pUpvoiq2DrbIRBOkU-NUB7BTcK5R X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMiBTYWx0ZWRfXzgw/ylopScYt X6NcsuUjliEN/PP4tm2QBiiBVvdiAbiYD8fCOeTykHK7HfHMkbNi+NBHQehishpG5kQ3I298yhY CU9m2p+sDFtLrTDr1/AihHKLcFIjsIrjysTzSCHa6xuYejD8qd1cVqmOUQvrseHoNwx9TJrax1E soN0zZHCGkKwTXF3BAuMT6aRA0zPRcs0A21m4VxuPZSzx37TwgrbvHG70pmJ3o/T8+pxCf8rjij qDO5j2PlN7n2TufKa17Vt0YarOuXuo7M6GHvmlN1RIV58WyJuNhe8Ed2xCdhvcOr2+n8ClOk1td HSkaKK5QtA3PR2y4BqKWjjDLz77AycP4MGyiQNaLU7w5c3yIZoIw+JYQQ7XLa5nr05ooVDewvjH sGHmDFwSmpElUodG+xH5i36tAEAHvA== X-Authority-Analysis: v=2.4 cv=SvOdKfO0 c=1 sm=1 tr=0 ts=691d6231 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=KSc5eBifJ7cFlDAX9ZYA: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-11-19_01,2025-11-18_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 clxscore=1015 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 impostorscore=0 malwarescore=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