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 2C181428494 for ; Thu, 14 May 2026 15:24:22 +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=1778772263; cv=none; b=MduXfpPTP7JsKzctAwJuhNCMdp2myHEjGmFEUg9YQrQR6XPKyxGjpH1b6wTPcEy8O9ott1mD255VseMoSMO7okCJgHNmNHqDwQsD3lqXRdY4d4Q3MufukTXxPDBhXAz0SHLIHgIFACYhw87QQkRq3UnaOiVlxkZoUVDngaxwsRY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778772263; c=relaxed/simple; bh=zJxzGEtaMTGEejCH5zSI1EaUMbu0tJGJjtrt+3d2moo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jTBV5xOysqLKhhI7lupMeRgLPwR0j880e7KVxEqnQ5FzODXpDFUfu8N7tghjmzI+orc9aM0vOFEcU8vzF6+YjFiezEyP4EbX+pB11zolUF8P3dhHQ22UigF71YWMxykKGh42TzPdi8LUq5GMyHiEkoA4TNl1G0b/79rStVTvjvk= 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=XHuNT/9U; 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="XHuNT/9U" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64E6ovli2611836; Thu, 14 May 2026 15:23:51 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=1wyUE/Vf+QvEfbbo0 1k/AR2Fe1WshRgZPA1M/cqOgzw=; b=XHuNT/9UqGe6IDRGdFW7CF2ODdkP+liKh vH+i39hXZnHciQzrfF4qJhjyU6+9iXU9jarmNHQBPS1PkwLY71Su8q/KH9u5AL7R 0PS9FLSFr0lPu5QyQ58z34bqC0sg1ck5CZ6HNYbuDeg8Zve4a/IOMBWL5fbW9kjo OnEtE0RsxN7SZMG+pqkrBvgA/znrNUn1KGvx/2+tOX+RD3jZE+zWetJuI3TkIl5N aN6Tq+QI+0AOulMiIvAoeYKMDkXaRJ5qLuKqw3wFQQmr38z7WTVfIuCTLAk8Dm61 RCn2CzYTE0s5rvTx/L5amLibh8/BA6KH6jR4yejCZevUdqrjXPkZQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nve54ch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 15:23:50 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64EF9WSi024570; Thu, 14 May 2026 15:23:49 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgvxmj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 May 2026 15:23:48 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64EFNj7m13304300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 May 2026 15:23:45 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E77C20043; Thu, 14 May 2026 15:23:45 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0074520040; Thu, 14 May 2026 15:23:37 +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:23:37 +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 05/20] sysfs: Add preferred CPU file Date: Thu, 14 May 2026 20:51:49 +0530 Message-ID: <20260514152204.481115-6-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-Authority-Analysis: v=2.4 cv=Y/XIdBeN c=1 sm=1 tr=0 ts=6a05e906 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=VwQbUJbxAAAA:8 a=usQfwybhv0jOAWjiEAgA:9 X-Proofpoint-GUID: ZJP5Nr7rWEDrDLdy6B5U5NCWtLWO8Lbi X-Proofpoint-ORIG-GUID: HKNiChaFyvwuQaM85H-18RIGBImU4jLm X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE0MDE1MyBTYWx0ZWRfX0xWggG8Dyke0 50LPHmCl9VskXRtZT0gdXohktEM+/znRhmjdCFY+NX1e3Er4lg+pJgQGBAo6mLtTRDhdO8HdFDE 8tRX2UU6fSyfW5nUKctAFz69gvCT32nrEoUB/yUaQBLB5s2bJITpiVyMbThj3xXeTfPooQhiBfL nZ1W28UcbrCysokGbe39W20ZnR5LwNvjDHUGORa+6xwU4RNWqj/KytmHbm7lErAGNeuxR6LTmdI gEgL8/4s0J72g+ZWCz4oMd7DpTrfMFdhZnNjpUJTwLTXPkvcR5Ab24i730QYU+K62FftEu/ztXp Ix907tYiscdxk+/RaKUYfdE871lOyfjK96FE6cGvVIPLpMKqBUKO6vJw+m3By3M77RIXliV5ovq BNlU81209ET3TATGyvROtZjWzB3eg07wwTMXHSuKIv5f1e1LKYYAjdIDLNt8XOeHxbS4QnvA7IM 5fpgb2t3bNfDMXpe+Cw== 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 clxscore=1015 priorityscore=1501 lowpriorityscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 adultscore=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 Add "preferred" file in /sys/devices/system/cpu This offers - User can quickly check which CPUs are marked as preferred at this moment. - Userspace algorithms irqbalance could use this mask to send irq into preferred CPUs. For example: cat /sys/devices/system/cpu/online 0-719 cat /sys/devices/system/cpu/preferred 0-599 <<< Implies 0-599 are preferred for workloads and 600-719 should be avoided at this moment. cat /sys/devices/system/cpu/preferred 0-719 <<< All CPUs are usable. There is no preferrence. Signed-off-by: Shrikanth Hegde --- Documentation/ABI/testing/sysfs-devices-system-cpu | 11 +++++++++++ drivers/base/cpu.c | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index 82d10d556cc8..354058c07d65 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -806,3 +806,14 @@ Date: Nov 2022 Contact: Linux kernel mailing list Description: (RO) the list of CPUs that can be brought online. + +What: /sys/devices/system/cpu/preferred +Date: May 2026 +Contact: Linux kernel mailing list +Description: + (RO) the list of preferred CPUs at this moment. + These are the only CPUs meant to be used at the moment. + Using CPU outside of the list could lead to more + contention of underlying physical CPU resource. Dynamically + changes based on steal time. With CONFIG_PREFERRED_CPU=n it + is same as online CPUs. See sched-arch.rst for more details. diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 875abdc9942e..0c6647805805 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -391,6 +391,13 @@ static int cpu_uevent(const struct device *dev, struct kobj_uevent_env *env) } #endif +static ssize_t preferred_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(cpu_preferred_mask)); +} +static DEVICE_ATTR_RO(preferred); + const struct bus_type cpu_subsys = { .name = "cpu", .dev_name = "cpu", @@ -532,6 +539,7 @@ static struct attribute *cpu_root_attrs[] = { #ifdef CONFIG_GENERIC_CPU_AUTOPROBE &dev_attr_modalias.attr, #endif + &dev_attr_preferred.attr, NULL }; -- 2.47.3