summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorOlav Haugan <ohaugan@codeaurora.org>2015-08-10 16:41:44 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:02:27 -0700
commit03a683a55c450e26f1ebde7400f64a4b7ecd68c2 (patch)
tree89d641bf72662652aff71607161baac88b731110 /drivers/base
parent4996dafe6875f2804d525e6ac74162e3efc4cda3 (diff)
sched: Add tunables for static cpu and cluster cost
Add per-cpu tunable to set the extra cost to use a CPU that is idle. Add the same for a cluster. Change-Id: I4aa53f3c42c963df7abc7480980f747f0413d389 Signed-off-by: Olav Haugan <ohaugan@codeaurora.org> [joonwoop@codeaurora.org: omitted changes for qhmp*.[c,h] stripped out CONFIG_SCHED_QHMP in drivers/base/cpu.c and include/linux/sched.h] Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/cpu.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 91bbb1959d8d..dee022638fe6 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -180,10 +180,106 @@ static struct attribute_group crash_note_cpu_attr_group = {
};
#endif
+#ifdef CONFIG_SCHED_HMP
+
+static ssize_t show_sched_static_cpu_pwr_cost(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 pwr_cost;
+
+ pwr_cost = sched_get_static_cpu_pwr_cost(cpuid);
+
+ rc = snprintf(buf, PAGE_SIZE-2, "%d\n", pwr_cost);
+
+ return rc;
+}
+
+static ssize_t __ref store_sched_static_cpu_pwr_cost(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 pwr_cost;
+
+ err = kstrtouint(strstrip((char *)buf), 0, &pwr_cost);
+ if (err)
+ return err;
+
+ err = sched_set_static_cpu_pwr_cost(cpuid, pwr_cost);
+
+ if (err >= 0)
+ err = count;
+
+ return err;
+}
+
+static ssize_t show_sched_static_cluster_pwr_cost(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 pwr_cost;
+
+ pwr_cost = sched_get_static_cluster_pwr_cost(cpuid);
+
+ rc = snprintf(buf, PAGE_SIZE-2, "%d\n", pwr_cost);
+
+ return rc;
+}
+
+static ssize_t __ref store_sched_static_cluster_pwr_cost(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 pwr_cost;
+
+ err = kstrtouint(strstrip((char *)buf), 0, &pwr_cost);
+ if (err)
+ return err;
+
+ err = sched_set_static_cluster_pwr_cost(cpuid, pwr_cost);
+
+ if (err >= 0)
+ err = count;
+
+ return err;
+}
+
+static DEVICE_ATTR(sched_static_cpu_pwr_cost, 0644,
+ show_sched_static_cpu_pwr_cost,
+ store_sched_static_cpu_pwr_cost);
+static DEVICE_ATTR(sched_static_cluster_pwr_cost, 0644,
+ show_sched_static_cluster_pwr_cost,
+ store_sched_static_cluster_pwr_cost);
+
+static struct attribute *hmp_sched_cpu_attrs[] = {
+ &dev_attr_sched_static_cpu_pwr_cost.attr,
+ &dev_attr_sched_static_cluster_pwr_cost.attr,
+ NULL
+};
+
+static struct attribute_group sched_hmp_cpu_attr_group = {
+ .attrs = hmp_sched_cpu_attrs,
+};
+
+#endif /* CONFIG_SCHED_HMP */
+
static const struct attribute_group *common_cpu_attr_groups[] = {
#ifdef CONFIG_KEXEC
&crash_note_cpu_attr_group,
#endif
+#ifdef CONFIG_SCHED_HMP
+ &sched_hmp_cpu_attr_group,
+#endif
NULL
};
@@ -191,6 +287,9 @@ static const struct attribute_group *hotplugable_cpu_attr_groups[] = {
#ifdef CONFIG_KEXEC
&crash_note_cpu_attr_group,
#endif
+#ifdef CONFIG_SCHED_HMP
+ &sched_hmp_cpu_attr_group,
+#endif
NULL
};