summaryrefslogtreecommitdiff
path: root/drivers/cpuquiet
diff options
context:
space:
mode:
authorSai Gurrappadi <sgurrappadi@nvidia.com>2013-12-19 16:30:02 -0800
committerDiwakar Tundlam <dtundlam@nvidia.com>2014-03-04 14:12:08 -0800
commit6207687cdae17f932b5c2a67935ed586b283461b (patch)
tree40e2ccc1329a9b32c56387795a9402bfb9c57ca7 /drivers/cpuquiet
parentfb16c8893ca3aa486c73525accd46c26ca3d557a (diff)
cpuquiet: Add Sysfs node for nr_run_thresholds
Added sysfs node that exposes the nr_runnable threshold at which cores are quiesenced/woken up. To write into this node: echo 1core# 2core# ... n_core# > nr_run_thresholds Bug 1427140 Change-Id: I7cabd63692cf92f7fe8d1064437b1d73002d4ba5 Signed-off-by: Sai Gurrappadi <sgurrappadi@nvidia.com> Reviewed-on: http://git-master/r/369017 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Diffstat (limited to 'drivers/cpuquiet')
-rw-r--r--drivers/cpuquiet/governors/runnable_threads.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/cpuquiet/governors/runnable_threads.c b/drivers/cpuquiet/governors/runnable_threads.c
index 77ce4b88566b..f670d1a1aec5 100644
--- a/drivers/cpuquiet/governors/runnable_threads.c
+++ b/drivers/cpuquiet/governors/runnable_threads.c
@@ -198,12 +198,63 @@ static void runnables_work_func(struct work_struct *work)
}
}
+#define MAX_BYTES 100
+
+static ssize_t show_thresholds(struct cpuquiet_attribute *attr, char *buf)
+{
+ char buffer[MAX_BYTES];
+ unsigned int i;
+ int size = 0;
+ buffer[0] = 0;
+ for_each_possible_cpu(i) {
+ if (i == ARRAY_SIZE(nr_run_thresholds) - 1)
+ break;
+ if (size >= sizeof(buffer))
+ break;
+ size += snprintf(buffer + size, sizeof(buffer) - size,
+ "%u->%u core threshold: %u\n",
+ i + 1, i + 2, nr_run_thresholds[i]);
+ }
+ return snprintf(buf, sizeof(buffer), "%s", buffer);
+}
+
+static ssize_t store_thresholds(struct cpuquiet_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret, i = 0;
+ char *val, *str, input[MAX_BYTES];
+ unsigned int thresholds[NR_CPUS];
+
+ if (!count || count >= MAX_BYTES)
+ return -EINVAL;
+ strncpy(input, buf, count);
+ input[count] = '\0';
+ str = input;
+ memcpy(thresholds, nr_run_thresholds, sizeof(nr_run_thresholds));
+ while ((val = strsep(&str, " ")) != NULL) {
+ if (*val == '\0')
+ continue;
+ if (i == ARRAY_SIZE(nr_run_thresholds) - 1)
+ break;
+ ret = kstrtouint(val, 10, &thresholds[i]);
+ if (ret)
+ return -EINVAL;
+ i++;
+ }
+
+ memcpy(nr_run_thresholds, thresholds, sizeof(thresholds));
+ return count;
+}
+
CPQ_BASIC_ATTRIBUTE(sample_rate, 0644, uint);
CPQ_BASIC_ATTRIBUTE(nr_run_hysteresis, 0644, uint);
+CPQ_ATTRIBUTE_CUSTOM(nr_run_thresholds, 0644,
+ show_thresholds, store_thresholds);
static struct attribute *runnables_attributes[] = {
&sample_rate_attr.attr,
&nr_run_hysteresis_attr.attr,
+ &nr_run_thresholds_attr.attr,
NULL,
};