Skip to contentSkip to conversation

show isolated & nohz_full cpus in sysfs

PATCH RESEND In review [email protected] 6 participants 10 messages Apr 24, 2015 – May 4, 2015 Driver core

lore
Share & tools
lore
#0 lore raw

cover show isolated & nohz_full cpus in sysfs

Currently there is no good way to get the isolated and nohz_full CPUs at runtime, because the kernel may have changed the CPUs specified on the commandline (when specifying all CPUs as isolated, or CPUs that do not exist, ...)

This series adds two files to /sys/devices/system/cpu, which can be used by system management tools like libvirt, openstack, etc. to ensure proper task placement.

These patches were kind of (but not formally) acked by Mike and Frederic, see https://lkml.org/lkml/2015/3/27/852

#1 lore raw

PATCH 1/2 show isolated cpus in sysfs

From: Rik van Riel <[email protected]>

After system bootup, there is no totally reliable way to see which CPUs are isolated, because the kernel may modify the CPUs specified on the isolcpus= kernel command line option.

Export the CPU list that actually got isolated in sysfs, specifically in the file /sys/devices/system/cpu/isolated

This can be used by system management tools like libvirt, openstack, and others to ensure proper placement of tasks.

---
 drivers/base/cpu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/base/cpu.c +12 -0
index f160ea44a86d..ea23ee7b545b 100644
@@ -265,6 +265,17 @@ static ssize_t print_cpus_offline(struct device *dev,
 }
 static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
 
+static ssize_t print_cpus_isolated(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	int n = 0, len = PAGE_SIZE-2;
+
+	n = scnprintf(buf, len, "%*pbl\n", cpumask_pr_args(cpu_isolated_map));
+
+	return n;
+}
+static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL);
+
 static void cpu_device_release(struct device *dev)
 {
 	/*
@@ -431,6 +442,7 @@ static struct attribute *cpu_root_attrs[] = {
 	&cpu_attrs[2].attr.attr,
 	&dev_attr_kernel_max.attr,
 	&dev_attr_offline.attr,
+	&dev_attr_isolated.attr,
 #ifdef CONFIG_GENERIC_CPU_AUTOPROBE
 	&dev_attr_modalias.attr,
 #endif
Signature · 1 line
2.1.0
#2 lore raw

Re: [PATCH 1/2] show isolated cpus in sysfs

Quoted 6 lines · On Fri, Apr 24, 2015 at 03:24:27PM -0400, [email protected] wrote:

From: Rik van Riel <[email protected]>

After system bootup, there is no totally reliable way to see which CPUs are isolated, because the kernel may modify the CPUs specified on the isolcpus= kernel command line option.

Quoted 8 lines

Export the CPU list that actually got isolated in sysfs, specifically in the file /sys/devices/system/cpu/isolated

This can be used by system management tools like libvirt, openstack, and others to ensure proper placement of tasks.

This patch should go through Peterz.

Quoted 37 lines
---
 drivers/base/cpu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/base/cpu.c +12 -0
index f160ea44a86d..ea23ee7b545b 100644
@@ -265,6 +265,17 @@ static ssize_t print_cpus_offline(struct device *dev,
 }
 static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
 
+static ssize_t print_cpus_isolated(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	int n = 0, len = PAGE_SIZE-2;
+
+	n = scnprintf(buf, len, "%*pbl\n", cpumask_pr_args(cpu_isolated_map));
+
+	return n;
+}
+static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL);
+
 static void cpu_device_release(struct device *dev)
 {
 	/*
@@ -431,6 +442,7 @@ static struct attribute *cpu_root_attrs[] = {
 	&cpu_attrs[2].attr.attr,
 	&dev_attr_kernel_max.attr,
 	&dev_attr_offline.attr,
+	&dev_attr_isolated.attr,
 #ifdef CONFIG_GENERIC_CPU_AUTOPROBE
 	&dev_attr_modalias.attr,
 #endif
Signature · 1 line
2.1.0
#3 lore raw

Re: [PATCH 1/2] show isolated cpus in sysfs

Quoted 4 lines · Frederic Weisbecker
Quoted 2 lines

This patch should go through Peterz.

Right, that's why the two patches kinda got lost. Rik, sorry about that and yes these two should go through Peterz.

Thanks.

Signature · 1 line
tejun
#4 lore raw

Re: [PATCH 1/2] show isolated cpus in sysfs

In reply to Frederic Weisbecker
Quoted 10 lines · Frederic Weisbecker
Quoted 9 lines · On Fri, Apr 24, 2015 at 03:24:27PM -0400, [email protected] wrote:

From: Rik van Riel <[email protected]>

After system bootup, there is no totally reliable way to see which CPUs are isolated, because the kernel may modify the CPUs specified on the isolcpus= kernel command line option.

Export the CPU list that actually got isolated in sysfs, specifically in the file /sys/devices/system/cpu/isolated

Quoted 7 lines
Quoted 5 lines

This can be used by system management tools like libvirt, openstack, and others to ensure proper placement of tasks.

This patch should go through Peterz.

Oh, fun. That's what I get for getting the get_maintainer.pl script, which told me to go through Greg KH instead :)

$ ./scripts/get_maintainer.pl -f drivers/base/cpu.c
Greg Kroah-Hartman <[email protected]> (supporter:DRIVER CORE,
KOBJ...)
[email protected] (open list)
Signature · 1 line
All rights reversed
maintainer
#5 lore raw

Re: [PATCH 1/2] show isolated cpus in sysfs

Quoted 19 lines · Rik van Riel
Quoted 10 lines · Frederic Weisbecker
Quoted 9 lines · On Fri, Apr 24, 2015 at 03:24:27PM -0400, [email protected] wrote:

From: Rik van Riel <[email protected]>

After system bootup, there is no totally reliable way to see which CPUs are isolated, because the kernel may modify the CPUs specified on the isolcpus= kernel command line option.

Export the CPU list that actually got isolated in sysfs, specifically in the file /sys/devices/system/cpu/isolated

Quoted 7 lines
Quoted 5 lines

This can be used by system management tools like libvirt, openstack, and others to ensure proper placement of tasks.

This patch should go through Peterz.

Quoted 7 lines

Oh, fun. That's what I get for getting the get_maintainer.pl script, which told me to go through Greg KH instead :)

$ ./scripts/get_maintainer.pl -f drivers/base/cpu.c
Greg Kroah-Hartman <[email protected]> (supporter:DRIVER CORE,
KOBJ...)
[email protected] (open list)

That's right, I can take this, I missed this the last time Rik sent these, that's my fault.

thanks,

greg k-h

#6 lore raw

Re: [PATCH 1/2] show isolated cpus in sysfs

Quoted 23 lines · Greg KH
Quoted 22 lines · Rik van Riel
Quoted 10 lines · Frederic Weisbecker
Quoted 9 lines · On Fri, Apr 24, 2015 at 03:24:27PM -0400, [email protected] wrote:

From: Rik van Riel <[email protected]>

After system bootup, there is no totally reliable way to see which CPUs are isolated, because the kernel may modify the CPUs specified on the isolcpus= kernel command line option.

Export the CPU list that actually got isolated in sysfs, specifically in the file /sys/devices/system/cpu/isolated

Quoted 7 lines
Quoted 5 lines

This can be used by system management tools like libvirt, openstack, and others to ensure proper placement of tasks.

This patch should go through Peterz.

Oh, fun. That's what I get for getting the get_maintainer.pl script, which told me to go through Greg KH instead :)

Quoted 7 lines
Quoted 4 lines
$ ./scripts/get_maintainer.pl -f drivers/base/cpu.c
Greg Kroah-Hartman <[email protected]> (supporter:DRIVER CORE,
KOBJ...)
[email protected] (open list)

That's right, I can take this, I missed this the last time Rik sent these, that's my fault.

Ping?

Let me harass you before we both forget and this
thing falls through the cracks again :)

Signature · 1 line
All rights reversed
#7 lore raw

PATCH 2/2 show nohz_full cpus in sysfs

In reply to [email protected]

From: Rik van Riel <[email protected]>

Currently there is no way to query which CPUs are in nohz_full mode from userspace.

Export the CPU list running in nohz_full mode in sysfs, specifically in the file /sys/devices/system/cpu/nohz_full

This can be used by system management tools like libvirt, openstack, and others to ensure proper task placement.

---
 drivers/base/cpu.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/base/cpu.c +17 -0
index ea23ee7b545b..78720e706176 100644
@@ -16,6 +16,7 @@
 #include <linux/acpi.h>
 #include <linux/of.h>
 #include <linux/cpufeature.h>
+#include <linux/tick.h>
 
 #include "base.h"
 
@@ -276,6 +277,19 @@ static ssize_t print_cpus_isolated(struct device *dev,
 }
 static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL);
 
+#ifdef CONFIG_NO_HZ_FULL
+static ssize_t print_cpus_nohz_full(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	int n = 0, len = PAGE_SIZE-2;
+
+	n = scnprintf(buf, len, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask));
+
+	return n;
+}
+static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL);
+#endif
+
 static void cpu_device_release(struct device *dev)
 {
 	/*
@@ -443,6 +457,9 @@ static struct attribute *cpu_root_attrs[] = {
 	&dev_attr_kernel_max.attr,
 	&dev_attr_offline.attr,
 	&dev_attr_isolated.attr,
+#ifdef CONFIG_NO_HZ_FULL
+	&dev_attr_nohz_full.attr,
+#endif
 #ifdef CONFIG_GENERIC_CPU_AUTOPROBE
 	&dev_attr_modalias.attr,
 #endif
Signature · 1 line
2.1.0
Acked-by on v1 2/2
#8 lore raw

Re: [PATCH 2/2] show nohz_full cpus in sysfs

Quoted 8 lines · On 04/24/2015 03:24 PM, [email protected] wrote:

From: Rik van Riel<[email protected]>

Currently there is no way to query which CPUs are in nohz_full mode from userspace.

Export the CPU list running in nohz_full mode in sysfs, specifically in the file /sys/devices/system/cpu/nohz_full

Quoted 7 lines

This can be used by system management tools like libvirt, openstack, and others to ensure proper task placement.

---
  drivers/base/cpu.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)

In the arch/tile distribution with our "dataplane" support, we have traditionally had a /sys/devices/system/cpu/dataplane file with the same semantics you are proposing. It's definitely helpful to userspace applications figuring out how to appropriately take over the machine they are being run on.

Signature · 2 lines
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com
Acked-by on the v1 series
#9 lore raw
In reply to [email protected]
Quoted 11 lines · On Fri, 2015-04-24 at 15:24 -0400, [email protected] wrote:

Currently there is no good way to get the isolated and nohz_full CPUs at runtime, because the kernel may have changed the CPUs specified on the commandline (when specifying all CPUs as isolated, or CPUs that do not exist, ...)

This series adds two files to /sys/devices/system/cpu, which can be used by system management tools like libvirt, openstack, etc. to ensure proper task placement.

These patches were kind of (but not formally) acked by Mike and Frederic, see https://lkml.org/lkml/2015/3/27/852