From mboxrd@z Thu Jan 1 00:00:00 1970 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 12F1042EEB0 for ; Thu, 14 May 2026 15:26:09 +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=1778772371; cv=none; b=bz2CcXiyx+LjCqYCtzep6s4sv9z8LOp3KIYpOPPcNM0dy0kjMHNtb8nG3RAuFWAh1CNVfcdX6juHlOArxs4i3UbXS8ay+4BjkLMAjPWDGvM9zJcTYV2FxFbNrxV79wQt0U2jvlBpRdk9BBbJ21E/P6fomFYu28V3++W0RFvmB7Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778772371; c=relaxed/simple; bh=VQ7I2N71i3j7teTQh4dw8UGGuxim+Wkl6wEu9UZY9Zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WjjQOV9+NfytDo0uXOGgdggAKz+qoD/jEdIOx03tVBeJ90BJjCo0cwiQ9x2Z5iYiKQN3gyj6sBQH05GVK9syMqVR5snweJS5SwaFULfm7UZLwmU/30MbUPCOI+DMTVD9ZjeFm/gOznsTd+rW67dJ31KMN7W/JKgu0hfqZC4VvOo= 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=nYAs4/jK; 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="nYAs4/jK" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64EA3GKP2775739; Thu, 14 May 2026 15:25:48 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=HUA3/1s2AeUKF33jX Wa/zzdS9jn9QYotrqHRY7AAXHQ=; b=nYAs4/jKD9elhqDtuglcLKiTQmHEYbZpP bruU42dPfW9yzz5kNGMi1T7jlb9vZKielQ5F82yqEmDzOlG7vrzbjA2LeagBFgRU 05uQK4pIj5mxFNLX8kkJGTx0WxEn+01a0ZX/siDDuILt2NFg26kWRQZZK1N2Ybly FFGpMpv185sqrIppcROlci5EI8F6RGG0Kx7xk4PvZkdEEngt6evM+qqyUpSBg5ay oh+AGo5bMKUrvRLAX3OzYzZELBPJ68iDjrdFX9yvHWh7BO1AG0yiO7H/xhFpBxP4 F2zQnkj1jz3mYGtGK1/Vazp4rr8uQlIPhm40nzC0ECT/uQHj6M5Iw== 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 4e3nv5d4q1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 15:25:47 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64EFPd6Q025234; Thu, 14 May 2026 15:25:46 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgmy6k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 15:25:46 +0000 (GMT) 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 64EFPglo35520948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 15:25:42 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95BBB20040; Thu, 14 May 2026 15:25:42 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBFB120043; Thu, 14 May 2026 15:25:34 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.213.185]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 May 2026 15:25:34 +0000 (GMT) From: Shrikanth Hegde To: linux-kernel@vger.kernel.org, mingo@kernel.org, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, yury.norov@gmail.com, kprateek.nayak@amd.com, iii@linux.ibm.com Cc: sshegde@linux.ibm.com, tglx@kernel.org, gregkh@linuxfoundation.org, pbonzini@redhat.com, seanjc@google.com, vschneid@redhat.com, huschle@linux.ibm.com, rostedt@goodmis.org, dietmar.eggemann@arm.com, mgorman@suse.de, bsegall@google.com, maddy@linux.ibm.com, srikar@linux.ibm.com, hdanton@sina.com, chleroy@kernel.org, vineeth@bitbyteword.org, frederic@kernel.org, arighi@nvidia.com, pauld@redhat.com, christian.loehle@arm.com, tj@kernel.org, tommaso.cucinotta@gmail.com, maz@kernel.org, rafael@kernel.org Subject: [PATCH v3 19/20] sched/core: Mark the direction of steal values to avoid oscillations Date: Thu, 14 May 2026 20:52:03 +0530 Message-ID: <20260514152204.481115-20-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260514152204.481115-1-sshegde@linux.ibm.com> References: <20260514152204.481115-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: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE1MyBTYWx0ZWRfXxb2usrzYNsiW eGWTyXVKRb22TWwxrAEHfWOZj34jhqSiHEMVZrpm2SzMOhHr5gz8hP2G+z9yqlvJwnqCeiEmZCN ThlvWCf9MKRBkG5Iq0FSMFOOiSymC5nmqi5+REp8wPu1jhb887l52rGUiEvylotY8m50uJSUFte RidMNeBHLMyja6GS3IfftyyuxTVPfOyw8P4L/WTJdtM8ci8xXqSS3nmhEItbwkUegUegsdSMrYT T6TuRi0Y5VA8wgH61/nNhhalJixY+OgcdpdCQKlxAZx5eIUSP7TO8d8BV7XmYbVPkKXpcG66EqQ +qxqcUp0HL0rPlK5QgVNawT/2Lmk2ubF//MV17kBl2X4B6m858ueGwhYT3FeEkagijlwpqP2jav ypfwg8ZjuIv/DoGUMXo478M3HRh4vXW/JO7xr90/0LSSJJHdSIlTLyD3xLKijysw0E6zwY7GS4X 2OcntCeSCCAUyMcf1Hw== X-Proofpoint-ORIG-GUID: R9cLJpA1QlsorrEag-qe1pgPavwhDjHe X-Authority-Analysis: v=2.4 cv=Jc6Ma0KV c=1 sm=1 tr=0 ts=6a05e97b cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=NVR8b6ZH4u3ztrVwBTQA:9 X-Proofpoint-GUID: 1ckuwVOSni10dfwxq9IoICyxppq-DCQu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-14_03,2026-05-13_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 clxscore=1015 phishscore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605140153 Cache the previous decision on steal time. So consecutive values of high values or low values are taken for increase/decrease of preferred CPUs. Signed-off-by: Shrikanth Hegde --- kernel/sched/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 955e74a41627..a9e8beb5108e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -11448,12 +11448,20 @@ void sched_steal_detection_work(struct work_struct *work) steal_ratio = (delta_steal * 100 * 100) / (delta_ns * num_online_cpus()); /* If the steal time values are high, reduce one core from preferred CPUs */ - if (steal_ratio > sm->high_threshold) + if (sm->previous_decision == 1 && steal_ratio > sm->high_threshold) arch_dec_preferred_cpus(sm, steal_ratio); /* If the steal time values are low, increase one core as preferred CPUs */ - if (steal_ratio < sm->low_threshold) + if (sm->previous_decision == -1 && steal_ratio < sm->low_threshold) arch_inc_preferred_cpus(sm, steal_ratio); + + /* mark the direction. This helps to avoid ping-pongs */ + if (steal_ratio > sm->high_threshold) + sm->previous_decision = 1; + else if (steal_ratio < sm->low_threshold) + sm->previous_decision = -1; + else + sm->previous_decision = 0; } void sched_trigger_steal_computation(int cpu) -- 2.47.3