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>
This commit is contained in:
Sai Gurrappadi
2013-12-19 16:30:02 -08:00
committed by Huang, Tao
parent e3d26340f7
commit b9cd6df053

View File

@@ -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,
};