From nobody Sun Dec 14 19:27:53 2025 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 1998E298C35 for ; Fri, 23 May 2025 18:15:29 +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=1748024131; cv=none; b=B4w5hF/uTvbrp08v30rXZKVH70sYrwpIfHgRTv2BPJGPc+4/i4Ox4kX42OLw4JHXmqG7G+mJ21F/sIiCSaQmThgdf106kQzMsScJul0/coGRaCsIZWEYyPSUYPbjAtlUYxltEU/Xwm33Q9Mog0pKTpu32RH+2hzlOeer9y64++c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748024131; c=relaxed/simple; bh=uEEALTgv5lzy7LE8QU7g4Lc8ltq4KwyZdv5BPG/HTTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IoS7k+T2u0gCYmgu6JjaLWRWLGWiKvxBjvhWu/O5UUsPl1nROIE3p5Iq0x4HzF8iz3dlMrhBBC9b7LQUgkSmQy1geZiAxdDvJxUs21Sm6rodPNMGMBkIVAQhTVXTLTR6ToLnJe05Ys5dTQNbIsDxSW730MEeZsoCpfwiE3OUAUo= 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=lEv/JUp5; 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="lEv/JUp5" 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 54NGWCjp019438; Fri, 23 May 2025 18:15:08 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=5gfYDFqufAz2exnVp 0F5z7SK3SvetXUnFifkGj7Ui4Q=; b=lEv/JUp5Rr7Iiz7vgD9LKQcuAHHRnFy+E f4xq8N0/5gKGdB/1M+5uHx2e0y1Kp2xTj3dDnQrNJ+Dx4U/1+IyetS/dmIPmf3aU xCmzW1Br6qJ3OveEwbl5Cvx0M1oxhR22eT49qZa4m0/iI40HLaaWcsI6R2qM/oSP q53+B65+C2KxqxX7wpiD274CddMtWGG5ymQU5rxO2LTcr0WpITHsv29t1Xq2gyeB 4Y7/tXof+I1tKHH/wljCFyNQGZKzqV+Zd0l+zAOpiAKMAvw4R36daEKbijK//1c8 JbBTKmdE6DdkABxvkg56of3oNflio+nk3mNp7faWgnEZ+nHSPsGtQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 46t669q2c9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:08 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 54NI15Y0016502; Fri, 23 May 2025 18:15:07 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 46t669q2c6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:07 +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 54NHva0i031973; Fri, 23 May 2025 18:15:06 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 46rwmqfvgr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:06 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 54NIF2d950397544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 May 2025 18:15:02 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5342D2004D; Fri, 23 May 2025 18:15:02 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D197020040; Fri, 23 May 2025 18:14:58 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.221.90]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 23 May 2025 18:14:58 +0000 (GMT) From: Shrikanth Hegde To: 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 Cc: sshegde@linux.ibm.com, vschneid@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, jstultz@google.com, kprateek.nayak@amd.com, huschle@linux.ibm.com, srikar@linux.ibm.com, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk Subject: [RFC PATCH 1/5] cpumask: Introduce cpu parked mask Date: Fri, 23 May 2025 23:44:44 +0530 Message-ID: <20250523181448.3777233-2-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250523181448.3777233-1-sshegde@linux.ibm.com> References: <20250523181448.3777233-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-Authority-Analysis: v=2.4 cv=RrPFLDmK c=1 sm=1 tr=0 ts=6830bb2c cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=dt9VzEwgFbYA:10 a=VnNF1IyMAAAA:8 a=yoKQFJCjtn0IRW-TtgoA:9 X-Proofpoint-ORIG-GUID: pUONPhN9KHOsk5Q3d8nIq_trzcGGgKqW X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIzMDE2NCBTYWx0ZWRfXworABcV5JF6p VB+MOYYXAuLyCl1ZSbN+jj/JlfDWi3dvfwrnX6/ozV4QgGMsCsLM7giuYeWaigMbWW7pPQwVFWF p+9ghOuW5pj8fA8NfemmabfguBPjrY6gyWdstwVaN158NFKydr9D2yDIJLtnHxLWYxhSDDh8ami ulrfaWxNOTbefYFe5to8CUtTJjYwMrSIJLBp0re6tuXXL7xw6k49/6ico961s6fAvbh3CRx0DdA Bub4mJqRabFo/TqBQFHfIYgJBdiRiewY1C0yUrHs3O+tHiwDYc4RFO8NNVpt1mT8uEmKTboUGLJ rAJmXfgYhzyT7ad2hn7ExsE6RFraOBD/2WqBJxv2HGGGRb+k12kuUK5arsVUFdDVDCi8kezYBiQ qyhUoRny1L07MQQjD1knChfJfS92pQ/7f7Rq5cVJUthwkCtclQUhTfYiKHsW5GsJDEFyeZVr X-Proofpoint-GUID: VZ_NEmXUshB2UHwK9Wi_Gs2rwAhtX7Ql X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-23_06,2025-05-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=0 clxscore=1015 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505160000 definitions=main-2505230164 Content-Type: text/plain; charset="utf-8" CPU is said to be parked, when underlying physical CPU is not=20 available. This happens when there is contention for CPU resource in para-virtualized case. One should avoid using these CPUs.=20 Build and maintain this state of parked CPUs. Scheduler will use this information and push the tasks out as soon as it can.=20 Signed-off-by: Shrikanth Hegde --- - Not sure if __read_mostly attribute suits for cpu_parked=20 since it can change often. Since often means a few mins, it is long time from scheduler perspective, hence kept it.=20 include/linux/cpumask.h | 14 ++++++++++++++ kernel/cpu.c | 3 +++ 2 files changed, 17 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 6a569c7534db..501848303800 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -84,6 +84,7 @@ static __always_inline void set_nr_cpu_ids(unsigned int n= r) * cpu_enabled_mask - has bit 'cpu' set iff cpu can be brought online * cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler * cpu_active_mask - has bit 'cpu' set iff cpu available to migration + * cpu_parked_mask - has bit 'cpu' set iff cpu is parked * * If !CONFIG_HOTPLUG_CPU, present =3D=3D possible, and active =3D=3D onl= ine. * @@ -93,6 +94,11 @@ static __always_inline void set_nr_cpu_ids(unsigned int = nr) * representing which CPUs are currently plugged in. And * cpu_online_mask is the dynamic subset of cpu_present_mask, * indicating those CPUs available for scheduling. + * + * A CPU is said to be parked when underlying physical CPU(pCPU) is not + * available at the moment. It is recommended not to run any workload on + * that CPU. + * * If HOTPLUG is enabled, then cpu_present_mask varies dynamically, * depending on what ACPI reports as currently plugged in, otherwise @@ -118,12 +124,14 @@ extern struct cpumask __cpu_enabled_mask; extern struct cpumask __cpu_present_mask; extern struct cpumask __cpu_active_mask; extern struct cpumask __cpu_dying_mask; +extern struct cpumask __cpu_parked_mask; #define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask) #define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask) #define cpu_enabled_mask ((const struct cpumask *)&__cpu_enabled_mask) #define cpu_present_mask ((const struct cpumask *)&__cpu_present_mask) #define cpu_active_mask ((const struct cpumask *)&__cpu_active_mask) #define cpu_dying_mask ((const struct cpumask *)&__cpu_dying_mask) +#define cpu_parked_mask ((const struct cpumask *)&__cpu_parked_mask) =20 extern atomic_t __num_online_cpus; =20 @@ -1146,6 +1154,7 @@ void init_cpu_possible(const struct cpumask *src); #define set_cpu_present(cpu, present) assign_cpu((cpu), &__cpu_present_mas= k, (present)) #define set_cpu_active(cpu, active) assign_cpu((cpu), &__cpu_active_mask, = (active)) #define set_cpu_dying(cpu, dying) assign_cpu((cpu), &__cpu_dying_mask, (dy= ing)) +#define set_cpu_parked(cpu, parked) assign_cpu((cpu), &__cpu_parked_mas= k, (parked)) =20 void set_cpu_online(unsigned int cpu, bool online); =20 @@ -1235,6 +1244,11 @@ static __always_inline bool cpu_dying(unsigned int c= pu) return cpumask_test_cpu(cpu, cpu_dying_mask); } =20 +static __always_inline bool cpu_parked(unsigned int cpu) +{ + return cpumask_test_cpu(cpu, cpu_parked_mask); +} + #else =20 #define num_online_cpus() 1U diff --git a/kernel/cpu.c b/kernel/cpu.c index a59e009e0be4..532fbfbe3226 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -3110,6 +3110,9 @@ EXPORT_SYMBOL(__cpu_dying_mask); atomic_t __num_online_cpus __read_mostly; EXPORT_SYMBOL(__num_online_cpus); =20 +struct cpumask __cpu_parked_mask __read_mostly; +EXPORT_SYMBOL(__cpu_parked_mask); + void init_cpu_present(const struct cpumask *src) { cpumask_copy(&__cpu_present_mask, src); --=20 2.39.3 From nobody Sun Dec 14 19:27:53 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 4240E298CC0 for ; Fri, 23 May 2025 18:15:29 +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=1748024131; cv=none; b=AZRkZ7oBkVq6Vc0OqgiF5vc+i6tmyFqvnZiXrSBdCB7b/PbHb9JFinfBaC+uxYuHZvZP2qAsWGXT55a08YkUX0lZVdCDRMU8mrzxPm8xSYJlC4NlzFqM4nXu2KeBXGZ4Xa9ajwkZaN6BPxmPkhuI2d6aA9ayeSkRJQGqW/MQVL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748024131; c=relaxed/simple; bh=BGfqZTuP7Vt9lOg14mcWWOIpVPUWN4w5uRBVNbskkMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oy0NQjLlqKXuJv0AMe5+kQg9HPbgfYh4cpOrpl1JDoKCs/FPu/mx/F3FTBid/NY4XN8xjCT+nlD71Pam3Ou0Jkd6fknSsEueYsfFxqQ/gBIM+bDTb7yv9OF0KBveRIc7E8TPBQdtNFmEaJfN1VKOwAO+BLMs/X52n+41/5coi/o= 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=DKg+WyIW; 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="DKg+WyIW" 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 54NGWJJe016985; Fri, 23 May 2025 18:15:11 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=ahgyIAPZYQH6AgIzs h4KBNjDs9nMRhTXach6oWE73cA=; b=DKg+WyIWpAPHkI8drbDNdOzNutN9AtdmP NpSS9YaJzqpXVEm0xaf7ZCQ/Kc+aIOdrEQ/aDvAPgiBy5pdB+eUGaue54c/vecbF wc22tQlpW6VrGeSrA8NKF22hsxBg+KuvrZ4lbghN5054ZHUE4oVgHHfaKEfvsSdx U4iyCdIBT2mhDTFmFGJ55Awc6Nzr/eGhGrdalzgIp1Nyf1CvXpNtJuFcttBXmbh7 cTzKq8XQOk8Y8Xp92k2Sgmbo8odUcL4RJV4uR02K4XeGqjTi1l6EwbPx5aOSwcw6 SCeSn6jBHqPFxsuPamg9zN/bNlIg++EoWMnS4/G2OhK5ASIPf8MRg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 46t5537756-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:11 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 54NIC03C000493; Fri, 23 May 2025 18:15:10 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 46t5537752-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:10 +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 54NID0EX010595; Fri, 23 May 2025 18:15:10 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 46rwnmqvec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:09 +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 54NIF6Yu35783076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 May 2025 18:15:06 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30F0A20043; Fri, 23 May 2025 18:15:06 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A985C20040; Fri, 23 May 2025 18:15:02 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.221.90]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 23 May 2025 18:15:02 +0000 (GMT) From: Shrikanth Hegde To: 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 Cc: sshegde@linux.ibm.com, vschneid@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, jstultz@google.com, kprateek.nayak@amd.com, huschle@linux.ibm.com, srikar@linux.ibm.com, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk Subject: [RFC PATCH 2/5] sched/core: Don't use parked cpu for selection Date: Fri, 23 May 2025 23:44:45 +0530 Message-ID: <20250523181448.3777233-3-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250523181448.3777233-1-sshegde@linux.ibm.com> References: <20250523181448.3777233-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: YLwwGwA9IWnT4Je-WvNgMHY5Ib8e_CzM X-Proofpoint-ORIG-GUID: yswSzh8SjNuDaW-I9Mryv0bRxQywTAq7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIzMDE2NCBTYWx0ZWRfX441L4+sE5tc0 1HtZZyzepEPev5kvqV/lNXakghMKM32G1z0TixhfdPHb9lrNo3bBjBU1wfkrxcm1aAfrvBISZBy ufo11FbNqHeMBertPebn/UXv4Q2urprJXAWxESYL3IjoPksWCAOezI7B81RGt84S+sgKMd9cJqS edF1wjNxiBKvI88UCT/deWlLtmF/aSlQGJYE40JVQPrMfquDF+hPoY6A6AvdVCySHee5j3GBRSV bVD7xdnbz7q3yPinHVNk9dPjl6VDy4Vg1gwLjA3DWmXLRu+FV5XyU1DPQlDYGg7+/VT6GtJRgwC VayseCWnMQma9NI9qE+e/JclKajGLDGY7n+Ibqq6z/Rr/usAQnaKNyL+WH0X4lQSKoW5/uC+w3r qGwq59K/BY9JQBC5hVEemqNxN0MFAPk33k8WxPa6BPOndGWtPh0GqdW8ofKGX+g97i4Ksm2t X-Authority-Analysis: v=2.4 cv=BOmzrEQG c=1 sm=1 tr=0 ts=6830bb2f cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=dt9VzEwgFbYA:10 a=VnNF1IyMAAAA:8 a=SeSF_3wNJrZcFQq4b1oA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-23_06,2025-05-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=622 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 suspectscore=0 impostorscore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 adultscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505160000 definitions=main-2505230164 Content-Type: text/plain; charset="utf-8" When the current running task is pushed using stop class mechanism, the new CPU that going to be chosen shouldn't be a parked CPU.=20 Signed-off-by: Shrikanth Hegde --- kernel/sched/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 62b3416f5e43..9ec12f9b3b08 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3526,7 +3526,7 @@ static int select_fallback_rq(int cpu, struct task_st= ruct *p) nodemask =3D cpumask_of_node(nid); =20 /* Look for allowed, online CPU in same node. */ - for_each_cpu(dest_cpu, nodemask) { + for_each_cpu_andnot(dest_cpu, nodemask, cpu_parked_mask) { if (is_cpu_allowed(p, dest_cpu)) return dest_cpu; } @@ -3534,7 +3534,7 @@ static int select_fallback_rq(int cpu, struct task_st= ruct *p) =20 for (;;) { /* Any allowed, online CPU? */ - for_each_cpu(dest_cpu, p->cpus_ptr) { + for_each_cpu_andnot(dest_cpu, p->cpus_ptr, cpu_parked_mask) { if (!is_cpu_allowed(p, dest_cpu)) continue; =20 --=20 2.39.3 From nobody Sun Dec 14 19:27:53 2025 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 2A91929B213 for ; Fri, 23 May 2025 18:15:35 +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=1748024137; cv=none; b=bb5FGKm7owlyGZ+Q9J9LiT1/G48eZLxQwkoKFi5L3bbf0w5W415xW+Bjw1OHFABnu36qvHYOXUzaBRm36vSYcahd9Pv8ZlYfq37n/OERs/TjtLF1LvIQWKjCQ42Oj4Zz9kyZ4EmZydYmePcxaimxTGkEdlmxsMWSvjJfdsEwgZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748024137; c=relaxed/simple; bh=nnyHGB6U1C7Kgu6nFbXrmHpQU0Zq4siWHKTYtL0SA4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l0nugCnTpSAzA0VHLYaUg54XudGXzsHjjfpeM1EFLkENr/qqmTi6yqrLEbygfMbtRCnzkpPyXz0f7VaIC2xTFUz42NTo7gn6m4c73+vBlBsHph+IXjlSPODuQmUjoL4i8qQVJCy6T+jVEUojcgnVcQkXMyaloqnHn3u2kZisrlw= 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=hFNdGPTc; 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="hFNdGPTc" 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 54NGWEaF008733; Fri, 23 May 2025 18:15: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=Cwj2bbP73sprJZTIk y8dfVd0Rf+prF9LI0VrT4FGTOE=; b=hFNdGPTcF4BBR9ImsYLStRXNghJSjgMkq 8OLzgYd/oNJSVC30qjH3/nOF0jGjfvF1R+7BrBMhrEWqadfEt+PSJtvQLA2Ly9v8 JwSS3uD1v6Hh0RsZB66HLh0kK24YFRjcSPAaOH/1X+1tmg5o9qXl/jILUD/Dxjcq KY/twxhC6Ik8zLA01Y/dnx97ios6+w8hUYLlycKImsoL2BN6pTxGeyJjtY0i/vRi wFgrZTpibVNOXS6xHEDHIMYQ4Yh+kZs5CUS2J9jWu1vzqK7jR17IhR1prYkPyqot btloRoNkmMhyZDHDR/2p2TF7VxI9khX1ltS84pjymKHNgRFKMHfRg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 46sxhwhesp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:15 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 54NIFFpU000308; Fri, 23 May 2025 18:15:15 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 46sxhwhesm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:15 +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 54NHa88R032024; Fri, 23 May 2025 18:15:14 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 46rwmqfvh8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:13 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 54NIFAx928770756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 May 2025 18:15:10 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0EB922004D; Fri, 23 May 2025 18:15:10 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 88A2120040; Fri, 23 May 2025 18:15:06 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.221.90]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 23 May 2025 18:15:06 +0000 (GMT) From: Shrikanth Hegde To: 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 Cc: sshegde@linux.ibm.com, vschneid@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, jstultz@google.com, kprateek.nayak@amd.com, huschle@linux.ibm.com, srikar@linux.ibm.com, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk Subject: [RFC PATCH 3/5] sched/fair: Don't use parked cpu for load balancing Date: Fri, 23 May 2025 23:44:46 +0530 Message-ID: <20250523181448.3777233-4-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250523181448.3777233-1-sshegde@linux.ibm.com> References: <20250523181448.3777233-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-Spam-Details-Enc: AW1haW4tMjUwNTIzMDE2MCBTYWx0ZWRfX4aSuiwL5n6c8 wBsEekn/gjJagKBEvEwkxfLqe0dx2Y9bzMbEOBmSjE6n58KtotB4gqjPZJuBAMWx2S4g9C7q7i4 995snCu9zaIzCcS62KHC8BeKNninEQfTpUN/EUqPWgltruzOrB8/PMTZTRPeLCAYzyBVSBy2Ljp YaPGoVD0WHTW4sCV79dafGlKjrjW5CHFHCWx1dZjiPkUFp+4PudS1blAnSlvvnPF5B5vo4dkAnd W8lqKhAhWCTPUBQIhLGQxQ8fUzivdSXC70MUCl6NamfQUIOWh6XFR6tS3EZdwB7NqnT399UiXWl zk0riaBiI8/7sf81IUNRss6ffS2m6PYqTt0dQ/nf/ZEfQ6cVP72jSQHn8SQ3RpDjIm1JiS4gV7K XwKtXag5NaR3Z/PDhSwH1/12t0+70PEu/0uVe3a6jFSvGEtQ6zRELKbdfbSzZ+8xmMce7xPC X-Proofpoint-GUID: eaGTPgHY3EZr-nUxp4AbzqN_hzfpbuK- X-Authority-Analysis: v=2.4 cv=O685vA9W c=1 sm=1 tr=0 ts=6830bb33 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=dt9VzEwgFbYA:10 a=VnNF1IyMAAAA:8 a=A_CrLDhOnlH3o789EtUA:9 X-Proofpoint-ORIG-GUID: zIJN5OVqRKkafCGM_wMMIM7SQAR6Rykl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-23_06,2025-05-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=579 spamscore=0 mlxscore=0 phishscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 clxscore=1011 malwarescore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505160000 definitions=main-2505230160 Content-Type: text/plain; charset="utf-8" While doing load balance, don't consider the parked CPUs. As far as load balance is considered, a parked CPU is as good as offline CPU.=20 Signed-off-by: Shrikanth Hegde --- kernel/sched/fair.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 125912c0e9dd..f48f55ca1522 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -11761,6 +11761,7 @@ static int sched_balance_rq(int this_cpu, struct rq= *this_rq, }; =20 cpumask_and(cpus, sched_domain_span(sd), cpu_active_mask); + cpumask_andnot(cpus, cpus, cpu_parked_mask); =20 schedstat_inc(sd->lb_count[idle]); =20 --=20 2.39.3 From nobody Sun Dec 14 19:27:53 2025 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 D7BED216E23 for ; Fri, 23 May 2025 18:15:33 +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=1748024135; cv=none; b=cbpjLVtwai0hU9hHJH7gDd7KW//MX2im6IEfTwZcUrF3vvrV3D9DZ6jQW9PLDnNVKgmIKkVPMs50bZVlto1MHd9dKHibpO5WT0wxV4bnoN50CcKT0iqmlxS8pBSCGLx2y8/m5MuUOngT/wBBH5P8dcFNNbLhZUO8t8UreVri+NM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748024135; c=relaxed/simple; bh=IIsLa1Gg5jSN4+6L9GGrZzQCaQ87vJoIQedlME/3x/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RPWVz2R5AaOYFhF/bZAcqUxJutpYpXUbHpNiG40cMsVq6yyB+5IcfKIkhQzcRT0wIWj0dOpKhv/4oHCOi0YAylZo/mCWWccYZhJXPJenvHf8HGa4BFxoRwLLgbocUCXqTmxkDsAsBfgaPbxeO8Xh48zZwhbd2rZxJrt/Nh17st0= 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=EG2jtmvk; 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="EG2jtmvk" 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 54NGWDOj008590; Fri, 23 May 2025 18:15: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=gqehOyeB5e+CQSzXz etpQXDaQKD3ArJmDEuvcL0lX6o=; b=EG2jtmvke59gButpl3lYbW3GzQD54fkZY VghzWL3D0JV0Y/EEinWMcPYJyED3tUFWD4e2OvnIqxaByU483y4p3g3giUcY2NZj LK45kpaHX4AJpK1McEUF6u+sz5s5nTuly+RjOUizHMLd51QpL7q6At5mIErYr9QX n3kFoQmOVgGE/Njr7AgssRkmbw4/PhJ9dDn26vTFhDTif+2m9G2zMRc/wgNH2SbH WZJQaWCT6QahFVBXwxND+nfpQe+TufHUQL0beNpzTQX4lRB2oXjUz64OVA0LpcRO XvcWe5/F7/XHGQsYt5D0d6dtY1aOGLMSoAqf+bRqffJYb7aXrmGKg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 46sxhwhet3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:19 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 54NIFJOm000349; Fri, 23 May 2025 18:15:19 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 46sxhwhesy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:19 +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 54NEtxhs010640; Fri, 23 May 2025 18:15:17 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 46rwnmqvf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:17 +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 54NIFD3334079206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 May 2025 18:15:14 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D72C12004B; Fri, 23 May 2025 18:15:13 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66F0420040; Fri, 23 May 2025 18:15:10 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.221.90]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 23 May 2025 18:15:10 +0000 (GMT) From: Shrikanth Hegde To: 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 Cc: sshegde@linux.ibm.com, vschneid@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, jstultz@google.com, kprateek.nayak@amd.com, huschle@linux.ibm.com, srikar@linux.ibm.com, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk Subject: [RFC PATCH 4/5] sched/core: Push current task when cpu is parked Date: Fri, 23 May 2025 23:44:47 +0530 Message-ID: <20250523181448.3777233-5-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250523181448.3777233-1-sshegde@linux.ibm.com> References: <20250523181448.3777233-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-Spam-Details-Enc: AW1haW4tMjUwNTIzMDE2MCBTYWx0ZWRfX6PLl1Q6F0j/N TNnl5NG362/L75G87cO4cxrvLHhTjxofMh6BpH6TgghzvNLNCJf693UjG+KUN4MsMjMV3jBtINo /La2YgoNPh2N9wfD7+uS0ahrF/6PnYAcCT3waeRJ2LggIkRX+VMQtnxURJdDHwfsAtgVCj3HIjJ oVe2+v22Gn035UzVO7xIq16lPhYh45umuEB/XTOek8+eLqpNEpqcg8wgGk5Sv6Ro2iXfn/oyOkY YrvKH5Rglrrrc/htg4WaCIDuwFyCLz18S9zDWoKXSGnVA4eU3F7W/mw7tHcECmMPe+TgHQMcpmd F2ndHqAlS2fNByRIZ6a+p/bGIzpVr2/fDv6YCvy3hymy9I2OUqMtMhIPsstHK9ig7B5EJOpxy9M hVoXLePz3YW916xTcaDu6twrZFByTXBJf4EeVC8Mi97pZ42HzxkFcQcKRLnmwICN2HIOYxM6 X-Proofpoint-GUID: EnoBjhOu6EEQfhM5cAt1HK1_26oUbDRR X-Authority-Analysis: v=2.4 cv=O685vA9W c=1 sm=1 tr=0 ts=6830bb37 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=dt9VzEwgFbYA:10 a=VnNF1IyMAAAA:8 a=DrkLi_EIzDYcL8ylMrQA:9 X-Proofpoint-ORIG-GUID: Hv1-KohCJnmpbnNnIHpSRgCTekBVe3tw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-23_06,2025-05-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 phishscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 clxscore=1015 malwarescore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505160000 definitions=main-2505230160 Content-Type: text/plain; charset="utf-8" When a CPU becomes parked, all tasks present on that CPU should vacate it. Use existing __balance_push_cpu_stop mechanism to move out current running task.=20 Which CPUs need to be parked is to be decided by architecture.=20 Signed-off-by: Shrikanth Hegde --- Note: Maybe this could be done only for CFS, EXT tasks if it is not recommended for RT,DL etc.=20 kernel/sched/core.c | 39 +++++++++++++++++++++++++++++++++++++++ kernel/sched/sched.h | 1 + 2 files changed, 40 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9ec12f9b3b08..dd8e824bc030 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5656,6 +5656,10 @@ void sched_tick(void) =20 sched_clock_tick(); =20 + /* push the current task out if cpu is parked */ + if (cpu_parked(cpu)) + push_current_task(rq); + rq_lock(rq, &rf); donor =3D rq->donor; =20 @@ -8482,6 +8486,41 @@ void __init sched_init_smp(void) } #endif /* CONFIG_SMP */ =20 +#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_CPU) +static DEFINE_PER_CPU(struct cpu_stop_work, push_task_work); + +/* A parked CPU is when underlying physical CPU is not available. + * Scheduling on such CPU is going to cause OS preemption. + * In case any task is scheduled on such CPU, move it out. In + * select_fallback_rq a non parked CPU will be chosen and henceforth + * task shouldn't come back to this CPU + */ +void push_current_task(struct rq *rq) +{ + struct task_struct *push_task =3D rq->curr; + unsigned long flags; + + /* idle task can't be pused out */ + if (rq->curr =3D=3D rq->idle || !cpu_parked(rq->cpu)) + return; + + if (kthread_is_per_cpu(push_task) || + is_migration_disabled(push_task)) + return; + + local_irq_save(flags); + get_task_struct(push_task); + preempt_disable(); + + stop_one_cpu_nowait(rq->cpu, __balance_push_cpu_stop, push_task, + this_cpu_ptr(&push_task_work)); + preempt_enable(); + local_irq_restore(flags); +} +#else +void push_current_task(struct rq *rq) { }; +#endif + int in_sched_functions(unsigned long addr) { return in_lock_functions(addr) || diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index c5a6a503eb6d..86bcd9401d41 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -104,6 +104,7 @@ extern void calc_global_load_tick(struct rq *this_rq); extern long calc_load_fold_active(struct rq *this_rq, long adjust); =20 extern void call_trace_sched_update_nr_running(struct rq *rq, int count); +void push_current_task(struct rq *rq); =20 extern int sysctl_sched_rt_period; extern int sysctl_sched_rt_runtime; --=20 2.39.3 From nobody Sun Dec 14 19:27:53 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 7120829AAE7 for ; Fri, 23 May 2025 18:15:33 +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=1748024135; cv=none; b=cEPTryeL/dOJ/2bNQbA6uzxgFWSm2ntjAmcgYMnXyBR4oMs3ZgZDQ0cbvGp8VNTaY6Ppzj4UFWcxPg4Bg/s3vk4cx74Qmwe1Xl6DBaFDjoQ5I5YVm8nWSFa5pw4nDLCSKEYLj5eWbt186BOakepWbEcajWXsPyZqhcA8SDk91cY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748024135; c=relaxed/simple; bh=5oX9Rmj3klh97hVy6nCpHS7vtK+pbqvHEGA1kWNSTeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XRI3iMjmsdMRaHYZuTJE/fssfr9cPeRmJcaSWRfm/mv4Fdhm7F2+/Dc71FnAiXYIUV3VaKCml0qegGg4erQPmxvXHjD8tcvpzkXCVGiC0I6ny0nOYDbaWQXXxMQTs2AI5lKnaUV9DOKa2khjScfi8Uz0U+DmvkxTV766yILck54= 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=f43sUQSL; 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="f43sUQSL" 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 54NGWMip020876; Fri, 23 May 2025 18:15: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=DKP2mXJ0kjW2nE9c6 1Isby21HssLLGbAvp7HWzQSgLU=; b=f43sUQSL8/KHnPbKIa4e4xWuQkuf9fdjd 2lN+hUYdRNdmBZHAsXrh2R8g+d/w/nmb4l51mEdTdKbUPrJAMoKgQQ4TnvvIw+qc QxpOZqPZNM+Xlrju9UrGisYEexeDuRz90ZvSS7JDMMJly/iQXqJ7KCYbXjvl+KeB efdYhTBGfjTtCByQRbP+ZTcPORVERc2qh6jaeWXw1526/lgflulR055Pf5WhxUEP d5pVbm/BCbbtDnk239szKTNz12DXv+5LRWAeTy5PkBGUViFdGGJxzH6OoRIcUrts ALo90yB8LutzVvCZ/f8Kb39Kuu4mqfPoEpqDI6Sf+xGKkTorVXJTg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 46t9m7wsw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:23 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 54NIFMsB011862; Fri, 23 May 2025 18:15:22 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 46t9m7wsvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:22 +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 54NIBrHn032066; Fri, 23 May 2025 18:15:21 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 46rwmqfvhv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 May 2025 18:15:21 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 54NIFHrI48234990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 May 2025 18:15:17 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAED02004F; Fri, 23 May 2025 18:15:17 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B3DF20040; Fri, 23 May 2025 18:15:14 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.221.90]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 23 May 2025 18:15:14 +0000 (GMT) From: Shrikanth Hegde To: 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 Cc: sshegde@linux.ibm.com, vschneid@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, jstultz@google.com, kprateek.nayak@amd.com, huschle@linux.ibm.com, srikar@linux.ibm.com, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk Subject: [DEBUG PATCH 5/5] powerpc: Use manual hint for cpu parking Date: Fri, 23 May 2025 23:44:48 +0530 Message-ID: <20250523181448.3777233-6-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250523181448.3777233-1-sshegde@linux.ibm.com> References: <20250523181448.3777233-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-Authority-Analysis: v=2.4 cv=SMZCVPvH c=1 sm=1 tr=0 ts=6830bb3b cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=dt9VzEwgFbYA:10 a=VnNF1IyMAAAA:8 a=L5heHK9TWKRAitwTlzAA:9 X-Proofpoint-GUID: SGtagqzBv-s_MaMtM2G0TRB7ovplG56S X-Proofpoint-ORIG-GUID: o399fyKNSRD8S9xXrHdE4z__l5-TD0wl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIzMDE2NCBTYWx0ZWRfXxSLjDx4XMxtq irqfXuxp7lRQqN3myuUB4074N79DF7QRZ4P4k6KJYNaiqD4sI+Syoy8MryZ3ZDCBfXLnx8LZLgP jqbe/L5TM4c4aVNQGOutR25P8NkTuDV2CwQFlfqrLVBeut0SC/pidllz8A2eSxQ+1VtHoqzIJ67 BeJLyLpMveKqF8Y4pwo26TQqPJP82IcZghHf8/KL6YUb4fapThAqY8TjMJkPcDGOScwUKNRKqh7 u9hJMX+vV7J29gtoIQ77xxOLdkhU24yAmJzJlKVvEF54rDu3CcKDBcSy1pkixwdUO5u3VfirkNo hQPidoXh/le5XkWtxDyozSed5g/7PpV0iIn7dOQy5CaBUHp10NMpzI1tn1CsqXmMmCyXAgQCqhv PvvjjO+i1B1xytJVwqx5smg7yModBtVmDi9R8ItNiZ06z74B/ATwlhq4wvksinMTdBLKdjPT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-23_06,2025-05-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 suspectscore=0 bulkscore=0 clxscore=1011 adultscore=0 phishscore=0 mlxscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2505160000 definitions=main-2505230164 Content-Type: text/plain; charset="utf-8" Use sysfs to provide hint. Depending on the system configuration one needs to decide the number. vp - virtual processor or vCPU.=20 For example, when 40 > vp_manual_hint means scheduler is supposed to use only 0-39 vCPUs. By default, vp_manual_hint is set to all possible CPUs=20 and it has be at least 1.=20 This is for illustration only. Not meant to be merged. One can modify as per their arch. =20 Signed-off-by: Shrikanth Hegde --- arch/powerpc/kernel/smp.c | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 5ac7084eebc0..37eb6aa71613 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -64,6 +64,7 @@ #include =20 #include +#include =20 #ifdef DEBUG #include @@ -82,6 +83,7 @@ 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; +static int vp_manual_hint =3D NR_CPUS; =20 DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map); DEFINE_PER_CPU(cpumask_var_t, cpu_smallcore_map); @@ -1727,6 +1729,7 @@ static void __init build_sched_topology(void) BUG_ON(i >=3D ARRAY_SIZE(powerpc_topology) - 1); =20 set_sched_topology(powerpc_topology); + vp_manual_hint =3D num_present_cpus(); } =20 void __init smp_cpus_done(unsigned int max_cpus) @@ -1807,4 +1810,46 @@ void __noreturn arch_cpu_idle_dead(void) start_secondary_resume(); } =20 +/* + * sysfs hint to mark CPUs as parked. This will help in restricting + * the workload to specified number of CPUs. + * For example 40 > vp_manual_hint means, workload will run on + * 0-39 CPUs. + */ + +static int pv_vp_manual_hint_set(void *data, u64 val) +{ + int cpu; + + if (val =3D=3D 0 || vp_manual_hint > num_present_cpus()) + vp_manual_hint =3D num_present_cpus(); + + if (val !=3D vp_manual_hint) + vp_manual_hint =3D val; + + for_each_present_cpu(cpu) { + if (cpu >=3D vp_manual_hint) + set_cpu_parked(cpu, true); + else + set_cpu_parked(cpu, false); + } + return 0; +} + +static int pv_vp_manual_hint_get(void *data, u64 *val) +{ + *val =3D vp_manual_hint; + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(fops_pv_vp_manual_hint, pv_vp_manual_hint_get, pv_= vp_manual_hint_set, "%llu\n"); + +static __init int paravirt_debugfs_init(void) +{ + if (is_shared_processor()) + debugfs_create_file("vp_manual_hint", 0600, arch_debugfs_dir, NULL, &fop= s_pv_vp_manual_hint); + return 0; +} + +device_initcall(paravirt_debugfs_init) #endif --=20 2.39.3