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 A485C313E2B for ; Tue, 7 Apr 2026 19:21:20 +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=1775589693; cv=none; b=l9NBIDTGJcu4ebp9O2y2wS3LDMarIzt2r2lwBHdAdyVQkvFraNh18zhadkd88fijq7QgqwwPRlg22SWmy5mVDl/Gj8V9/txvUXcCYu/pXVx5Dw54dlXesqwvCcgMRFPVlG8sh5Aa1AB9WKMORqzwz3A0Mr9IZFq8HWFWjbXIe04= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775589693; c=relaxed/simple; bh=kCVsXNnhaa39Yb31n8EKRIbHkgw2eDODsFTb4hmi/Yc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ddqExWifKtafneDGXl00k2KFNsSU6OatOTBN4vcwnetR5vISFZIBNVElmV9QBBsTSDH5keRPths98j+mzmG9bbKtK93V2Dn9zol/I99ccXrOZN+2hrCXAsRyLaJKW3VoiSi2ByB/zZDDsEEmtz1Fsgl6HIKOikMfLvtpzDptdbo= 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=oFY3RP8y; 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="oFY3RP8y" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 637DdJg82591017; Tue, 7 Apr 2026 19:20:38 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=YN9MFmou6m6kTDp6C TBync+i/LQo9B9Yk3wXqi30NVs=; b=oFY3RP8y7l/6ZTPMdTX80m5eOk23WKO6Z QRljaS0j2qAMbPz9NQScEbafe+VAVAWLbsJIpQ6gi1X1PeZRVoFlPjQ64M5iD3He FBGNRsf4GOZHKYiI8YlmEsL9VO0cYObyn1W97R6Rt9vyFL1yJAfan7DL4KaBrcO4 KloiahkzUp/ZL4gBu4xkf9s5+l8WR4aTFj4wkCNRjGt0Fr2TaoLINTAqWTPMNVdB MqrqC/zmsXvSJ9f9JRxgEaQEdf//f5PBnp65UiG+TnB41QVjEEVnRz3Gjwte3ROE w5LYql1pgn0zTuHIRGLmNWJgELok+HA1gjY/psvPblUar3vTDLWdA== 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 4dcn2e4t4h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Apr 2026 19:20:37 +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 637IeqqL013844; Tue, 7 Apr 2026 19:20:36 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dcmf44jt7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Apr 2026 19:20:36 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 637JKVGG36831558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Apr 2026 19:20:32 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB4A020043; Tue, 7 Apr 2026 19:20:31 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21FB720040; Tue, 7 Apr 2026 19:20:27 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.20.194]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 7 Apr 2026 19:20:26 +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, tglx@linutronix.de, yury.norov@gmail.com, gregkh@linuxfoundation.org Cc: sshegde@linux.ibm.com, 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, mgorman@suse.de, bsegall@google.com, maddy@linux.ibm.com, srikar@linux.ibm.com, hdanton@sina.com, chleroy@kernel.org, vineeth@bitbyteword.org, joelagnelf@nvidia.com Subject: [PATCH v2 04/17] sysfs: Add preferred CPU file Date: Wed, 8 Apr 2026 00:49:37 +0530 Message-ID: <20260407191950.643549-5-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260407191950.643549-1-sshegde@linux.ibm.com> References: <20260407191950.643549-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-ORIG-GUID: qaPpvlBkYHLz0F0Ell0xYcvki9HvKH_u X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDE3NSBTYWx0ZWRfX2S+Nvub8SJtj SuS6VTwQaIO59ihn3G54fmHjXzh6kSIdpvml2ygkghHT0+0CIsTvdqaFs4l1TdTzJpGEg1MwgKy SNxJnxfh+eeoCLBj6o4I3pk+/+3plulOTgeTDm5JemXBmnHYlvKTsCquyvJMCPGKTCMKJNl6vGc eixBbxr/8DcPZKnyN3b0h8GCf0wSiPRvfYI2V8EBNeQtGtT9q8oWtbEFhgyvCGC8zoZ7x0ZOFVQ yWehuwV4y4kFZsSkF4+oUF9D+oVS6Ss5ihLZV+k44Hw6wf7NMYPzlaOTthbfxSL0USMIBfP+DH6 EiwCGFPQF/1XQht+4g69YMJz9tZBCiTRByMoar+rxNfV+qkaEYsUmv0mzqPE1BE4azRoBIa5woK aZyVgBoaTaZ79lFFDAz1I4Y0w0LeSAXBEV5qHgGt+7n8vUyVeaLOGKFNB1qvHlTh1t8Sbzfrk8v f+vhSV7UYcpGDH3lPRg== X-Authority-Analysis: v=2.4 cv=Cfw4Irrl c=1 sm=1 tr=0 ts=69d55905 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=VwQbUJbxAAAA:8 a=usQfwybhv0jOAWjiEAgA:9 X-Proofpoint-GUID: LXXDwIjydRF77iN1sETmzhF4AfYehfCS 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-04-07_04,2026-04-07_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 clxscore=1015 adultscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604070175 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 | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index 3a05604c21bf..ffa05605923b 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -788,3 +788,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: Apr 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 to reflect the current situation by using + STEAL_MONITOR scheduler feature. Expects CONFIG_PARAVIRT=y diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 875abdc9942e..0a6cf37f2001 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -391,6 +391,15 @@ static int cpu_uevent(const struct device *dev, struct kobj_uevent_env *env) } #endif +#ifdef CONFIG_PARAVIRT +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); +#endif + const struct bus_type cpu_subsys = { .name = "cpu", .dev_name = "cpu", @@ -531,6 +540,9 @@ static struct attribute *cpu_root_attrs[] = { #endif #ifdef CONFIG_GENERIC_CPU_AUTOPROBE &dev_attr_modalias.attr, +#endif +#ifdef CONFIG_PARAVIRT + &dev_attr_preferred.attr, #endif NULL }; -- 2.47.3