diff options
| author | Olav Haugan <ohaugan@codeaurora.org> | 2016-06-02 18:06:10 -0700 |
|---|---|---|
| committer | Olav Haugan <ohaugan@codeaurora.org> | 2016-09-24 10:59:54 -0700 |
| commit | de1a32cd143b4db85bf18fab02782a4e8af79b17 (patch) | |
| tree | 57df9ad27f1c4af1b264eec31e61f34631cceb55 | |
| parent | 0a17b36a20d65df27ccf2de068ea517b19f6a53f (diff) | |
drivers/base: cpu: Add node for cpu isolation
Add a new per-cpu node to control isolation of CPU.
Usage:
echo 1 > isolate - Isolate the core
echo 0 > isolate - Unisolate the core
Change-Id: I6a13e8dda99130ca794e5b6f51600f4c57a3e921
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
| -rw-r--r-- | drivers/base/cpu.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index dee022638fe6..c8bfb6077224 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -180,6 +180,58 @@ static struct attribute_group crash_note_cpu_attr_group = { }; #endif +#ifdef CONFIG_HOTPLUG_CPU + +static ssize_t show_cpu_isolated(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct cpu *cpu = container_of(dev, struct cpu, dev); + ssize_t rc; + int cpuid = cpu->dev.id; + unsigned int isolated = cpu_isolated(cpuid); + + rc = snprintf(buf, PAGE_SIZE-2, "%d\n", isolated); + + return rc; +} + +static ssize_t __ref store_cpu_isolated(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct cpu *cpu = container_of(dev, struct cpu, dev); + int err; + int cpuid = cpu->dev.id; + unsigned int isolated; + + err = kstrtouint(strstrip((char *)buf), 0, &isolated); + if (err) + return err; + + if (isolated > 1) + return -EINVAL; + + if (isolated) + sched_isolate_cpu(cpuid); + else + sched_unisolate_cpu(cpuid); + + return count; +} + +static DEVICE_ATTR(isolate, 0644, show_cpu_isolated, store_cpu_isolated); + +static struct attribute *cpu_isolated_attrs[] = { + &dev_attr_isolate.attr, + NULL +}; + +static struct attribute_group cpu_isolated_attr_group = { + .attrs = cpu_isolated_attrs, +}; + +#endif + #ifdef CONFIG_SCHED_HMP static ssize_t show_sched_static_cpu_pwr_cost(struct device *dev, @@ -280,6 +332,9 @@ static const struct attribute_group *common_cpu_attr_groups[] = { #ifdef CONFIG_SCHED_HMP &sched_hmp_cpu_attr_group, #endif +#ifdef CONFIG_HOTPLUG_CPU + &cpu_isolated_attr_group, +#endif NULL }; @@ -290,6 +345,9 @@ static const struct attribute_group *hotplugable_cpu_attr_groups[] = { #ifdef CONFIG_SCHED_HMP &sched_hmp_cpu_attr_group, #endif +#ifdef CONFIG_HOTPLUG_CPU + &cpu_isolated_attr_group, +#endif NULL }; |
