Skip to content

Commit

Permalink
show nohz_full cpus in sysfs
Browse files Browse the repository at this point in the history
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]>
Acked-by: Mike Galbraith <[email protected]>
Acked-by: Chris Metcalf <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Rik van Riel authored and gregkh committed May 20, 2015
1 parent 59f30ab commit 6570a9a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/base/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/acpi.h>
#include <linux/of.h>
#include <linux/cpufeature.h>
#include <linux/tick.h>

#include "base.h"

Expand Down Expand Up @@ -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)
{
/*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6570a9a

Please sign in to comment.