2015-04-24 19:24:41

by Rik van Riel

[permalink] [raw]
Subject: [PATCH 0/2 resend] 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


2015-04-24 19:24:45

by Rik van Riel

[permalink] [raw]
Subject: [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.

Suggested-by: Li Zefan <[email protected]>
Signed-off-by: Rik van Riel <[email protected]>
---
drivers/base/cpu.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index f160ea44a86d..ea23ee7b545b 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -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
--
2.1.0

2015-04-24 19:24:39

by Rik van Riel

[permalink] [raw]
Subject: [PATCH 2/2] show nohz_full cpus in sysfs

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.

Signed-off-by: Rik van Riel <[email protected]>
---
drivers/base/cpu.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index ea23ee7b545b..78720e706176 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -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
--
2.1.0

2015-04-24 21:11:35

by Frederic Weisbecker

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

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
>
> This can be used by system management tools like libvirt,
> openstack, and others to ensure proper placement of tasks.
>
> Suggested-by: Li Zefan <[email protected]>
> Signed-off-by: Rik van Riel <[email protected]>

This patch should go through Peterz.

> ---
> drivers/base/cpu.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index f160ea44a86d..ea23ee7b545b 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -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
> --
> 2.1.0
>

2015-04-24 21:16:37

by Tejun Heo

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

On Fri, Apr 24, 2015 at 11:11:29PM +0200, Frederic Weisbecker wrote:
> > Suggested-by: Li Zefan <[email protected]>
> > Signed-off-by: Rik van Riel <[email protected]>
>
> 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.

--
tejun

2015-04-24 21:22:53

by Rik van Riel

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

On 04/24/2015 05:11 PM, Frederic Weisbecker wrote:
> 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
>>
>> This can be used by system management tools like libvirt,
>> openstack, and others to ensure proper placement of tasks.
>>
>> Suggested-by: Li Zefan <[email protected]>
>> Signed-off-by: Rik van Riel <[email protected]>
>
> 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)

--
All rights reversed

2015-04-24 21:49:07

by Greg Kroah-Hartman

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

On Fri, Apr 24, 2015 at 05:22:12PM -0400, Rik van Riel wrote:
> On 04/24/2015 05:11 PM, Frederic Weisbecker wrote:
> > 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
> >>
> >> This can be used by system management tools like libvirt,
> >> openstack, and others to ensure proper placement of tasks.
> >>
> >> Suggested-by: Li Zefan <[email protected]>
> >> Signed-off-by: Rik van Riel <[email protected]>
> >
> > 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)

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

thanks,

greg k-h

2015-04-25 05:29:09

by Mike Galbraith

[permalink] [raw]
Subject: Re: [PATCH 0/2 resend] show isolated & nohz_full cpus in sysfs

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

Acked-by: Mike Galbraith <[email protected]>

2015-04-28 19:18:48

by Chris Metcalf

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

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
>
> This can be used by system management tools like libvirt,
> openstack, and others to ensure proper task placement.
>
> Signed-off-by: Rik van Riel<[email protected]>
> ---
> 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.

Acked-by: Chris Metcalf <[email protected]>
--
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

2015-05-04 21:16:36

by Rik van Riel

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

On 04/24/2015 05:49 PM, Greg KH wrote:
> On Fri, Apr 24, 2015 at 05:22:12PM -0400, Rik van Riel wrote:
>> On 04/24/2015 05:11 PM, Frederic Weisbecker wrote:
>>> 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
>>>>
>>>> This can be used by system management tools like libvirt,
>>>> openstack, and others to ensure proper placement of tasks.
>>>>
>>>> Suggested-by: Li Zefan <[email protected]>
>>>> Signed-off-by: Rik van Riel <[email protected]>
>>>
>>> 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)
>
> 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 :)

--
All rights reversed