[PATCH 11/17] sysfs: Add paravirt CPU file
From: Shrikanth Hegde <hidden>
Date: 2025-11-19 12:46:14
Also in:
lkml
Subsystem:
driver core, kobjects, debugfs and sysfs, the rest · Maintainers:
Greg Kroah-Hartman, "Rafael J. Wysocki", Danilo Krummrich, Linus Torvalds
Add paravirt file in /sys/devices/system/cpu.
This offers
- User can quickly check which CPUs are marked as paravirt.
- Userspace algorithm such as sched_ext or with isolcpus could
use the mask and make decision.
- daemon such as irqbalance could use this mask and don't spread
irq's into paravirt CPUs.
For example:
cat /sys/devices/system/cpu/paravirt
600-719 <<< arch marked these are paravirt.
cat /sys/devices/system/cpu/paravirt
<<< No paravirt CPUs at the moment.
Signed-off-by: Shrikanth Hegde <redacted>
---
Documentation/ABI/testing/sysfs-devices-system-cpu | 9 +++++++++
drivers/base/cpu.c | 12 ++++++++++++
2 files changed, 21 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu
index 8aed6d94c4cd..1da77430b776 100644
--- a/Documentation/ABI/testing/sysfs-devices-system-cpu
+++ b/Documentation/ABI/testing/sysfs-devices-system-cpu@@ -777,3 +777,12 @@ Date: Nov 2022 Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> Description: (RO) the list of CPUs that can be brought online. + +What: /sys/devices/system/cpu/paravirt +Date: Sep 2025 +Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org> +Description: + (RO) the list of CPUs that are current marked as paravirt CPUs. + These CPUs are not meant to be used at the moment due to + contention of underlying physical CPU resource. Dynamically + changes to reflect the current situation.
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index fa0a2eef93ac..c216e13c4e2d 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c@@ -374,6 +374,15 @@ static int cpu_uevent(const struct device *dev, struct kobj_uevent_env *env) } #endif +#ifdef CONFIG_PARAVIRT +static ssize_t paravirt_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(cpu_paravirt_mask)); +} +static DEVICE_ATTR_RO(paravirt); +#endif + const struct bus_type cpu_subsys = { .name = "cpu", .dev_name = "cpu",
@@ -513,6 +522,9 @@ static struct attribute *cpu_root_attrs[] = { #endif #ifdef CONFIG_GENERIC_CPU_AUTOPROBE &dev_attr_modalias.attr, +#endif +#ifdef CONFIG_PARAVIRT + &dev_attr_paravirt.attr, #endif NULL };
--
2.47.3