Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933641AbcCNF1w (ORCPT ); Mon, 14 Mar 2016 01:27:52 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:36308 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933415AbcCNF0W (ORCPT ); Mon, 14 Mar 2016 01:26:22 -0400 From: Michael Turquette X-Google-Original-From: Michael Turquette To: peterz@infradead.org, rjw@rjwysocki.net Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Juri.Lelli@arm.com, steve.muckle@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, Michael Turquette Subject: [PATCH 4/8] cpufreq/schedutil: sysfs capacity margin tunable Date: Sun, 13 Mar 2016 22:22:08 -0700 Message-Id: <1457932932-28444-5-git-send-email-mturquette+renesas@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1457932932-28444-1-git-send-email-mturquette+renesas@baylibre.com> References: <1457932932-28444-1-git-send-email-mturquette+renesas@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1901 Lines: 61 With the addition of the global cfs capacity margin helpers in patch, "sched/cpufreq: new cfs capacity margin helpers", we can now export sysfs tunables from the schedutil governor. This allows privileged users to tune the value more easily. The margin value is global to cfs, not per-policy. As such schedutil does not store any state about the margin. Schedutil restores the margin value to its default value when exiting. Signed-off-by: Michael Turquette --- drivers/cpufreq/cpufreq_schedutil.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/cpufreq/cpufreq_schedutil.c b/drivers/cpufreq/cpufreq_schedutil.c index 5aa26bf..12e49b9 100644 --- a/drivers/cpufreq/cpufreq_schedutil.c +++ b/drivers/cpufreq/cpufreq_schedutil.c @@ -246,8 +246,32 @@ static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *bu static struct governor_attr rate_limit_us = __ATTR_RW(rate_limit_us); +static ssize_t capacity_margin_show(struct gov_attr_set *not_used, + char *buf) +{ + return sprintf(buf, "%lu\n", cpufreq_get_cfs_capacity_margin()); +} + +static ssize_t capacity_margin_store(struct gov_attr_set *attr_set, + const char *buf, size_t count) +{ + unsigned long margin; + int ret; + + ret = sscanf(buf, "%lu", &margin); + if (ret != 1) + return -EINVAL; + + cpufreq_set_cfs_capacity_margin(margin); + + return count; +} + +static struct governor_attr capacity_margin = __ATTR_RW(capacity_margin); + static struct attribute *sugov_attributes[] = { &rate_limit_us.attr, + &capacity_margin.attr, NULL }; @@ -381,6 +405,7 @@ static int sugov_exit(struct cpufreq_policy *policy) mutex_lock(&global_tunables_lock); + cpufreq_reset_cfs_capacity_margin(); count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook); policy->governor_data = NULL; if (!count) -- 2.1.4