From nobody Tue Dec 2 02:29:42 2025 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 191DC35C18B for ; Wed, 19 Nov 2025 12:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763556357; cv=none; b=WIcJJ5LXPIS5eHEKAb8d81e0jCWoFvwtePph/UM/tTVqaXQgd01kBvKuvvGz7ou+H0yVXF71aDzabvDehDNZpkoOIIQm2VCFtoQ6YbI99lEkWH5GVj/yyb7GiJE9qjahMs+c6t56OAGX2HIcZs6e7GnEcW5nErG6HWxxvYiK8f0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763556357; c=relaxed/simple; bh=SS2Vd7EFiHgpHjr34NwbQQQIwGHsFIymNFNAfiPrOeQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aSERH5FOuGz74ySQEqrUOm5HDRK4OhtsN3JiLNnGvCpRAXQsDtiQzAPZPhnv6KT4S+sSOdOMCGEq1CLGtDLFhRygt9veOTRriHsy4h/VxwDMc0wJFhSGZDTAclooOdbcK1pGKXnEm8kHdRttFhhETkff+025X2ue/ffu2zPZwX8= 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=aTvocoys; 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="aTvocoys" 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 5AJ6MKO4022349; Wed, 19 Nov 2025 12:45:35 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=q6alubEg5FFRdzA8k nogoUcxkGqjuD5s+4s7T3Fi5SI=; b=aTvocoyshYnOqcVsc66DzfhmzeDO4jG64 Lp2Min0JC5jmxpgwGVFQzlzhXt7Tb+iyrxVx13RmZBj36PYRgGH8fcZdw8QekiBQ C5glrfE+7Iljf0mmGVLQWR5UvB+C+yCrw+iPVqv4FagLsxwEZaxl941FS4/7KUK7 poOmll6uYj3PZwHD+0wbvem10hoy98tEcE+zY/cQYgrUkQmuBCueMYJI1kcxDqvB jMlBrW17V9FATfcvlZZzhv4jpF4+BObhlgvu7Qcb8Zz25NJyPDjCV8KdsFrpIFhB V+CZrqDvKvOwB5/ELhIaQ/ZK9TQCkJygfZHJ7PIlDolD+pAhPwFSw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aejgwymb5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 12:45:34 +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 5AJCeO9v021061; Wed, 19 Nov 2025 12:45:34 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 4aejgwymb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 12:45:34 +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 5AJAwIHI030795; Wed, 19 Nov 2025 12:45:33 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4af47y0rnq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Nov 2025 12:45:33 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5AJCjTSW25494154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 12:45:29 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EA5420043; Wed, 19 Nov 2025 12:45:29 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E28120040; Wed, 19 Nov 2025 12:45:25 +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:45:24 +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 07/17] sched/fair: Don't consider paravirt CPUs for wakeup and load balance Date: Wed, 19 Nov 2025 18:14:39 +0530 Message-ID: <20251119124449.1149616-8-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: fZSzzI_BnME7a9KEmWYLlcAmJ9tKBc-G X-Authority-Analysis: v=2.4 cv=YqwChoYX c=1 sm=1 tr=0 ts=691dbbee cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=zGSZXhnX_8tdEcBSxkwA:9 X-Proofpoint-ORIG-GUID: P9go1sgTFOV9d9mFhD6E5KAFZTLYQFZP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMiBTYWx0ZWRfXze4pwxp4ycs3 8s7NHNcqDvPPV3lQnjqILTiFE5xdb6EfpMyeN3iyl6MG6dTJBrnXAWqeBbYnGsJX09FgvPwKSeU oNc7X4aw6ls4gVC2+97Hn8otdcGfdAjewMGBnBNxhMSXVPLjkXkLWGW70PRYb8fLkEGOhK5qIGM OGkSYGTq+U+yNR69+JVjvxus7JyTpzsFPnM/djNNiK4Yw/PM+MWspePsC9qqa/Rop2U1A+kXm7l 0Xe3ARAoy7DiY/GfHjT2FasY8+L8u8Q0J/oPFSoUZ0s5bjgP9wWCJ2pDaV5vm4rdl0J8vW2T3CR +Xq0coKm8GGQFz++0hfQH/Rf5anUf0QYc5mpCuWJ2T637N0pyyAhbwPz5znMooRaCpWVuSSwb77 zn+DRQSxXK1AegcKRKPbsz4RqUWapA== 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" For CFS load balancer, - mask out paravirt CPUs from list of cpus to balance. - This helps to restrict/expand the workload depending on the mask. At wakeup, - If prev_cpu is paravirt, see if recent_used_cpu can be chosen. If not choose current cpu. - For EAS system, put a warning if wake up happens on paravirt CPU. At this point, not expecting any EAS system will have a overcommit of CPUs. Signed-off-by: Shrikanth Hegde --- kernel/sched/fair.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 015e00b370c9..760813802cb9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7358,6 +7358,9 @@ static int wake_affine(struct sched_domain *sd, struc= t task_struct *p, { int target =3D nr_cpumask_bits; =20 + if (cpu_paravirt(prev_cpu)) + return this_cpu; + if (sched_feat(WA_IDLE)) target =3D wake_affine_idle(this_cpu, prev_cpu, sync); =20 @@ -7441,6 +7444,11 @@ static inline int sched_balance_find_dst_cpu(struct = sched_domain *sd, struct tas { int new_cpu =3D cpu; =20 + if (cpu_paravirt(prev_cpu)) { + schedstat_inc(p->stats.nr_wakeups_paravirt); + return cpu; + } + if (!cpumask_intersects(sched_domain_span(sd), p->cpus_ptr)) return prev_cpu; =20 @@ -7777,10 +7785,25 @@ static int select_idle_sibling(struct task_struct *= p, int this_cpu, int prev, in unsigned long task_util, util_min, util_max; int i, recent_used_cpu, prev_aff =3D -1; =20 + /* Likely prev,target belong to same LLC, it is better at wakeup + * to move away from them. at best return recent_used_cpu if it + * is usable + */ + if (cpu_paravirt(prev) || cpu_paravirt(target)) { + schedstat_inc(p->stats.nr_wakeups_paravirt); + + recent_used_cpu =3D p->recent_used_cpu; + if (!cpu_paravirt(recent_used_cpu)) + return recent_used_cpu; + else + return this_cpu; + } + /* * On asymmetric system, update task utilization because we will check * that the task fits with CPU's capacity. */ + if (sched_asym_cpucap_active()) { sync_entity_load_avg(&p->se); task_util =3D task_util_est(p); @@ -8539,8 +8562,14 @@ select_task_rq_fair(struct task_struct *p, int prev_= cpu, int wake_flags) =20 if (!is_rd_overutilized(this_rq()->rd)) { new_cpu =3D find_energy_efficient_cpu(p, prev_cpu); - if (new_cpu >=3D 0) + + /* System supporting Energy model isn't expected + * have a CPU marked as paravirt + */ + if (new_cpu >=3D 0) { + WARN_ON_ONCE(cpu_paravirt(new_cpu)); return new_cpu; + } new_cpu =3D prev_cpu; } =20 @@ -11832,6 +11861,11 @@ static int sched_balance_rq(int this_cpu, struct r= q *this_rq, =20 cpumask_and(cpus, sched_domain_span(sd), cpu_active_mask); =20 +#ifdef CONFIG_PARAVIRT + /* Don't spread load to paravirt CPUs */ + cpumask_andnot(cpus, cpus, cpu_paravirt_mask); +#endif + schedstat_inc(sd->lb_count[idle]); =20 redo: --=20 2.47.3