From mboxrd@z Thu Jan 1 00:00:00 1970 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 EC7B73769E7 for ; Wed, 17 Jun 2026 17:43:27 +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=1781718209; cv=none; b=iLqsOIeqvQWDR5MihSQsaiGvo/C37ppwdxk15zElobQ9CNCIKTsjG67naH07iZdWjgt6EdtEftm99Wf7BPhh2wyZFvYFcB7V2eKAPQd4I2r/U1mOAwWWH8RpHp+rNoZCrpAB81s83EA8HgjvstJiw58PAS6uXCXdaPMRS2vL8mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781718209; c=relaxed/simple; bh=JzJPKc21H8pZZq8N6Vbh6r0Qw2ALS0gCFGYtZjOkOgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HjFowMnPFxvoH8l2pI712BR4EhXmGC7usnbw9cPRGFpaqG7TRDq4SYSCsutm61VJf1VJ+g9NbKchyh6ODUcXMNJ6ty+PyfIoWO+OHvYIK0R9W/6OEgxrziZdLcZkMd0vugguvaFPQeewF07OK2WBx33YoNUA6SZHP+IIsuTXm0M= 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=OiwMCkw/; 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="OiwMCkw/" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65HFpp21744622; Wed, 17 Jun 2026 17:43:13 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=akqdjoOLD38kZE4G9 1ivjxHVgJiEWq0/Ka5nl/0hDaE=; b=OiwMCkw/Pb05+x0caxn3kP1Hkt//JBK7r mBZPIcwXmpVdkSZlHgvdKuwqo4MsVvHXvPYDL2hJz8nZx1/PyPfa4XfnWHgSnC/n F0vCPivQ9HFe1LJeGtu8WDs8grjvrXcNMF5kM+x0YGt52jcOGHBHf2RF8ETJfBk1 vG+7MWuwqAyMu14Qjkg6ok0c90eCblgqEGPJhIvyDmShEnUosyQ3Tf4IYbS0rMgH kBlQovUzeqz4t1Y8Wf5qQ2RqhWynEkgAhMGdRqtea3Fi77b+iaUzohHBGE0vhxRb WnnujbKQ2M6yOAmoA2bnm2KaYLiKkfZPWg8/aOKkpM8wXl2KNYE8A== 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 4eueqx4750-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jun 2026 17:43:12 +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 65HHYceM009661; Wed, 17 Jun 2026 17:43:11 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4eudvacbfm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jun 2026 17:43:11 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 65HHh7oY47907170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jun 2026 17:43:07 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B2C3820049; Wed, 17 Jun 2026 17:43:07 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A194C20040; Wed, 17 Jun 2026 17:43:00 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.28.77]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 17 Jun 2026 17:43:00 +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 v4 05/20] sysfs: Add preferred CPU file Date: Wed, 17 Jun 2026 23:11:24 +0530 Message-ID: <20260617174139.155540-6-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260617174139.155540-1-sshegde@linux.ibm.com> References: <20260617174139.155540-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: AW1haW4tMjYwNjE3MDE2NiBTYWx0ZWRfX954pKZRpDYT/ z0+CpuckI+I+s1er+tYTcBO4ZnqSdFDEk8FsAS3J5zMl9Ei1hbj5sasaU7lTjqjxI1PKWOKJ+Tb REoI7zf0OEZjHp0mASdZz+zWRUD7ck2B75ANCZUeYUix/VAm6m9F4aq0IL/TgiKCcdYBKx6GOHF ST0qd/KfDNuYweIHvf4MyURvRRig1+PBW17EyiW2cU99Kw/Vxb1f9iZO1DDo/x1yi7eTzw1skEK abXJgLbAAlIL+OwoMv1jDYtVa86PmGWrqBrQehl33FiSCxcIDTKBrN58xiXEMYtK3vQweao5iWg 2hM+gG9rtwusnCeVHuM2Jayasrb5Y7itXafbl/frtRL4j1oOK765kUUGEvskCahIa9ka1Z96xwa kEkceyt1w4/WUD4uBpbCyFa5G1sQROKwEdPPG7BB6mdHonbRW32olfSgWr5GkOQbEMWsAhCZk0k b2bzBLgKzedIJW/4gMg== X-Proofpoint-GUID: oj2gnzMehYOp8ONAL_aupHWBZTxR2RV9 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE3MDE2NiBTYWx0ZWRfX+UOwNvYpCU7b w24uKsORt6DDT6zB4+hC5hMKGcYmU7nVp6MPVSkgEDsmcCNueqKZLabHZZhbU242o0jxtHFtfX6 iS1Wwwow32/eox0cCoBzDsrI+KwH9Jk= X-Proofpoint-ORIG-GUID: H0H5mzvOifbqlvq82whfoMOtBzIhEf4V X-Authority-Analysis: v=2.4 cv=auGCzyZV c=1 sm=1 tr=0 ts=6a32dcb0 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=VwQbUJbxAAAA:8 a=md4hqiRJsRObfrzgdmAA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-17_02,2026-06-17_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606170166 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..5fb973d53287 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: Jun 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 active 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