cpufreq: Make iowait boost a policy option
Subsystems (3)
PATCH 1/2 cpufreq: Make iowait boost a policy option
Make iowait boost a cpufreq policy option and enable it for intel_pstate cpufreq driver. Governors like schedutil can use it to determine if boosting for tasks that wake up with p->in_iowait set is needed.
--- drivers/cpufreq/intel_pstate.c | 1 + include/linux/cpufreq.h | 3 +++ 2 files changed, 4 insertions(+)
drivers/cpufreq/intel_pstate.c +1 -0
@@ -2239,6 +2239,7 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency =INTEL_CPUFREQ_TRANSITION_LATENCY ; policy->transition_delay_us =INTEL_CPUFREQ_TRANSITION_DELAY ; + policy->iowait_boost_enable =1 ;/* This reflects the intel_pstate_get_cpu_pstates() setting. */ policy->cur = policy->cpuinfo.min_freq;
include/linux/cpufreq.h +3 -0
@@ -127,6 +127,9 @@ struct cpufreq_policy {*/ unsigned int transition_delay_us; +/* Boost switch for tasks with p->in_iowait set */ +unsigned int iowait_boost_enable; +/* Cached frequency lookup from cpufreq_driver_resolve_freq. */ unsigned int cached_target_freq;int cached_resolved_idx;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
PATCH 2/2 sched: Use iowait boost policy option in schedutil
If cpufreq policy has iowait boost enabled, use it. Also make it a schedutil configuration from sysfs so it can be turned on/off if needed (by default use the policy value).
--- kernel/sched/cpufreq_schedutil.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
kernel/sched/cpufreq_schedutil.c +34 -0
@@ -24,6 +24,7 @@struct sugov_tunables {struct gov_attr_set attr_set;unsigned int rate_limit_us; +unsigned int iowait_boost_enable; };struct sugov_policy {
@@ -47,6 +48,7 @@ struct sugov_policy {bool work_in_progress;bool need_freq_update; +unsigned int iowait_boost_enable; };struct sugov_cpu {
@@ -171,6 +173,11 @@ static void sugov_get_util(unsigned long *util, unsigned long *max)static void sugov_set_iowait_boost (struct sugov_cpu *sg_cpu,u64 time,unsigned int flags) { +struct sugov_policy *sg_policy = sg_cpu->sg_policy; + +if (!sg_policy->tunables->iowait_boost_enable) +return ; +if (flags &SCHED_CPUFREQ_IOWAIT ) { sg_cpu->iowait_boost = sg_cpu->iowait_boost_max; }else if (sg_cpu->iowait_boost) {
@@ -386,10 +393,34 @@ static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *bureturn count; } +static ssize_t iowait_boost_enable_show (struct gov_attr_set *attr_set, +char *buf) +{ +struct sugov_tunables *tunables =to_sugov_tunables (attr_set); + +return sprintf (buf,"%u\n" , tunables->iowait_boost_enable); +} + +static ssize_t iowait_boost_enable_store (struct gov_attr_set *attr_set, +const char *buf,size_t count) +{ +struct sugov_tunables *tunables =to_sugov_tunables (attr_set); +unsigned int enable; + +if (kstrtouint (buf,10 , &enable)) +return -EINVAL ; + + tunables->iowait_boost_enable = enable; + +return count; +} +static struct governor_attr rate_limit_us =__ATTR_RW (rate_limit_us); +static struct governor_attr iowait_boost_enable =__ATTR_RW (iowait_boost_enable);static struct attribute *sugov_attributes[] = { &rate_limit_us.attr, + &iowait_boost_enable.attr,NULL };
@@ -543,6 +574,9 @@ static int sugov_init(struct cpufreq_policy *policy) tunables->rate_limit_us *= lat; } +if (policy->iowait_boost_enable) + tunables->iowait_boost_enable = policy->iowait_boost_enable; + policy->governor_data = sg_policy; sg_policy->tunables = tunables;
Signature · 1 line
2.13.0.303.g4ebf302169-goog
Rafael J. Wysocki
maintainerRe: [PATCH 2/2] sched: Use iowait boost policy option in schedutil
Quoted 77 lines · Joel Fernandes
If cpufreq policy has iowait boost enabled, use it. Also make it a schedutil configuration from sysfs so it can be turned on/off if needed (by default use the policy value).
Signed-off-by Joel Fernandes <[email protected]>--- kernel/sched/cpufreq_schedutil.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)kernel/sched/cpufreq_schedutil.c +31
-0@@ -24,6 +24,7 @@struct sugov_tunables {struct gov_attr_set attr_set;unsigned int rate_limit_us; +unsigned int iowait_boost_enable; };struct sugov_policy {@@ -47,6 +48,7 @@ struct sugov_policy {bool work_in_progress;bool need_freq_update; +unsigned int iowait_boost_enable; };struct sugov_cpu {@@ -171,6 +173,11 @@ static void sugov_get_util(unsigned long *util, unsigned long *max)static void sugov_set_iowait_boost (struct sugov_cpu *sg_cpu,u64 time,unsigned int flags) { +struct sugov_policy *sg_policy = sg_cpu->sg_policy; + +if (!sg_policy->tunables->iowait_boost_enable) +return ; +if (flags &SCHED_CPUFREQ_IOWAIT ) { sg_cpu->iowait_boost = sg_cpu->iowait_boost_max; }else if (sg_cpu->iowait_boost) {@@ -386,10 +393,34 @@ static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *bureturn count; } +static ssize_t iowait_boost_enable_show (struct gov_attr_set *attr_set, +char *buf) +{ +struct sugov_tunables *tunables =to_sugov_tunables (attr_set); + +return sprintf (buf,"%u\n" , tunables->iowait_boost_enable); +} + +static ssize_t iowait_boost_enable_store (struct gov_attr_set *attr_set, +const char *buf,size_t count) +{ +struct sugov_tunables *tunables =to_sugov_tunables (attr_set); +unsigned int enable; + +if (kstrtouint (buf,10 , &enable)) +return -EINVAL ; + + tunables->iowait_boost_enable = enable; + +return count; +} +static struct governor_attr rate_limit_us =__ATTR_RW (rate_limit_us); +static struct governor_attr iowait_boost_enable =__ATTR_RW (iowait_boost_enable);static struct attribute *sugov_attributes[] = { &rate_limit_us.attr, + &iowait_boost_enable.attr,NULL };
kernel/sched/cpufreq_schedutil.c static int sugov_init(struct cpufreq_policy *policy) · line 578
Quoted 5 lines
kernel/sched/cpufreq_schedutil.c +2
-0@@ -543,6 +574,9 @@ static int sugov_init(struct cpufreq_policy *policy) tunables->rate_limit_us *= lat; } +if (policy->iowait_boost_enable) + tunables->iowait_boost_enable = policy->iowait_boost_enable;
Well, that's just
tunables->iowait_boost_enable = policy->iowait_boost_enable;
so I'm not sure about the role of the if ().
Also, do we only need the policy field as an initial value here? That's sort of confusing, because intel_pstate does iowait boosting in the active mode too and then it is unconditional.
Quoted 6 lines
kernel/sched/cpufreq_schedutil.c +1
-1+ policy->governor_data = sg_policy; sg_policy->tunables = tunables; --2.13.0.303.g4ebf302169-goog
Thanks,
Rafael
Re: [PATCH 2/2] sched: Use iowait boost policy option in schedutil
Hi Rafael,
On Thu, May 18, 2017 at 6:08 PM, Rafael J. Wysocki <[email protected]> wrote:
[..]
Quoted 13 lines
Quoted 13 lines
static struct
governor_attrrate_limit_us=__ATTR_RW(rate_limit_us);kernel/sched/cpufreq_schedutil.c +2
-0+static struct governor_attr iowait_boost_enable =__ATTR_RW (iowait_boost_enable);static struct attribute *sugov_attributes[] = { &rate_limit_us.attr, + &iowait_boost_enable.attr,NULL };@@ -543,6 +574,9 @@ static int sugov_init(struct cpufreq_policy *policy) tunables->rate_limit_us *= lat; }
Quoted 8 lines
kernel/sched/cpufreq_schedutil.c static int sugov_init(struct cpufreq_policy *policy) · line 578
Quoted 2 lines
kernel/sched/cpufreq_schedutil.c +2
-0+if (policy->iowait_boost_enable) + tunables->iowait_boost_enable = policy->iowait_boost_enable;Well, that's just
tunables->iowait_boost_enable=policy->iowait_boost_enable;so I'm not sure about the role of the if ().
Yes you're right, will fix.
Quoted 5 lines
Also, do we only need the policy field as an initial value here? That's sort of confusing, because
intel_pstatedoes iowait boosting in the active mode too and then it is unconditional.
I didn't get your comment. Could you clarify what you meant by 'intel_pstate does iowait boosting in the active mode' ? Is there another path outside the governor where intel_pstate does iowait boosting, or are you referring to the hardware behavior?
thanks,
-Joel
Rafael J. Wysocki
maintainerRe: [PATCH 2/2] sched: Use iowait boost policy option in schedutil
Quoted 34 lines · Joel Fernandes
Hi Rafael,
On Thu, May 18, 2017 at 6:08 PM, Rafael J. Wysocki <[email protected]> wrote:
[..]Quoted 13 lines
Quoted 13 lines
static struct
governor_attrrate_limit_us=__ATTR_RW(rate_limit_us);kernel/sched/cpufreq_schedutil.c +2
-0+static struct governor_attr iowait_boost_enable =__ATTR_RW (iowait_boost_enable);static struct attribute *sugov_attributes[] = { &rate_limit_us.attr, + &iowait_boost_enable.attr,NULL };@@ -543,6 +574,9 @@ static int sugov_init(struct cpufreq_policy *policy) tunables->rate_limit_us *= lat; }Quoted 8 lines
kernel/sched/cpufreq_schedutil.c static int sugov_init(struct cpufreq_policy *policy) · line 578
Quoted 2 lines
kernel/sched/cpufreq_schedutil.c +2
-0+if (policy->iowait_boost_enable) + tunables->iowait_boost_enable = policy->iowait_boost_enable;Well, that's just
tunables->iowait_boost_enable=policy->iowait_boost_enable;so I'm not sure about the role of the if ().
Yes you're right, will fix.
Quoted 5 lines
Also, do we only need the policy field as an initial value here? That's sort of confusing, because
intel_pstatedoes iowait boosting in the active mode too and then it is unconditional.
Quoted 4 lines
I didn't get your comment. Could you clarify what you meant by '
intel_pstatedoes iowait boosting in the active mode' ? Is there another path outside the governor whereintel_pstatedoes iowait boosting,
Yes.
Quoted 1 line
or are you referring to the hardware behavior?
No.
In the active mode intel_pstate acts as a governor too and it does iowait boosting unconditionally then.
But that's OK on a second thought, as the policy field will affect the passive mode only anyway and setting it on init will actually cause the behavior to be consistent.
Thanks,
Rafael
Viresh Kumar
maintainerRe: [PATCH 2/2] sched: Use iowait boost policy option in schedutil
In reply to Joel FernandesQuoted 3 lines · Joel Fernandes
If cpufreq policy has iowait boost enabled, use it. Also make it a schedutil configuration from sysfs so it can be turned on/off if needed (by default use the policy value).
As I understand it, you want to make iowait boost optional. It may be worth mentioning why we want to do that in the commit somewhere. I am quite sure you don't want for some of the ARM platforms. Can you please elaborate?
PeterZ once indicated that he is against adding any tunables for the schedutil governor. This is another one we have now.
Quoted 10 lines
Signed-off-by Joel Fernandes <[email protected]>--- kernel/sched/cpufreq_schedutil.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)kernel/sched/cpufreq_schedutil.c +0
-0
kernel/sched/cpufreq_schedutil.c line 27
Quoted 4 lines
kernel/sched/cpufreq_schedutil.c +1
-0@@ -24,6 +24,7 @@struct sugov_tunables {struct gov_attr_set attr_set;unsigned int rate_limit_us; +unsigned int iowait_boost_enable;
Maybe just:
bool iowait_boost;
kernel/sched/cpufreq_schedutil.c struct sugov_policy { · line 51
Quoted 8 lines
kernel/sched/cpufreq_schedutil.c +1
-0};struct sugov_policy {@@ -47,6 +48,7 @@ struct sugov_policy {bool work_in_progress;bool need_freq_update; +unsigned int iowait_boost_enable;
I don't see this being used at all. Am I missing something ?
Quoted 63 lines
kernel/sched/cpufreq_schedutil.c +32
-1};struct sugov_cpu {@@ -171,6 +173,11 @@ static void sugov_get_util(unsigned long *util, unsigned long *max)static void sugov_set_iowait_boost (struct sugov_cpu *sg_cpu,u64 time,unsigned int flags) { +struct sugov_policy *sg_policy = sg_cpu->sg_policy; + +if (!sg_policy->tunables->iowait_boost_enable) +return ; +if (flags &SCHED_CPUFREQ_IOWAIT ) { sg_cpu->iowait_boost = sg_cpu->iowait_boost_max; }else if (sg_cpu->iowait_boost) {@@ -386,10 +393,34 @@ static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *bureturn count; } +static ssize_t iowait_boost_enable_show (struct gov_attr_set *attr_set, +char *buf) +{ +struct sugov_tunables *tunables =to_sugov_tunables (attr_set); + +return sprintf (buf,"%u\n" , tunables->iowait_boost_enable); +} + +static ssize_t iowait_boost_enable_store (struct gov_attr_set *attr_set, +const char *buf,size_t count) +{ +struct sugov_tunables *tunables =to_sugov_tunables (attr_set); +unsigned int enable; + +if (kstrtouint (buf,10 , &enable)) +return -EINVAL ; + + tunables->iowait_boost_enable = enable; + +return count; +} +static struct governor_attr rate_limit_us =__ATTR_RW (rate_limit_us); +static struct governor_attr iowait_boost_enable =__ATTR_RW (iowait_boost_enable);static struct attribute *sugov_attributes[] = { &rate_limit_us.attr, + &iowait_boost_enable.attr,NULL };@@ -543,6 +574,9 @@ static int sugov_init(struct cpufreq_policy *policy) tunables->rate_limit_us *= lat; } +if (policy->iowait_boost_enable) + tunables->iowait_boost_enable = policy->iowait_boost_enable; + policy->governor_data = sg_policy; sg_policy->tunables = tunables; --2.13.0.303.g4ebf302169-goog
Re: [PATCH 2/2] sched: Use iowait boost policy option in schedutil
Quoted 8 lines · Viresh Kumar
Quoted 3 lines · Joel Fernandes
If cpufreq policy has iowait boost enabled, use it. Also make it a schedutil configuration from sysfs so it can be turned on/off if needed (by default use the policy value).
As I understand it, you want to make iowait boost optional. It may be worth mentioning why we want to do that in the commit somewhere. I am quite sure you don't want for some of the ARM platforms. Can you please elaborate?
Yes, I actually have power measurements too which I will include in v2. This is for an arm64 based Qualcomm SoC.
thanks,
-Joel
Re: [PATCH 2/2] sched: Use iowait boost policy option in schedutil
In reply to Viresh KumarOn Thu, May 18, 2017 at 9:39 PM, Viresh Kumar <[email protected]> wrote:
[..]
Quoted 12 lines
kernel/sched/cpufreq_schedutil.c line 27
Quoted 9 lines
kernel/sched/cpufreq_schedutil.c +1
-0@@ -24,6 +24,7 @@struct sugov_tunables {struct gov_attr_set attr_set;unsigned int rate_limit_us; +unsigned int iowait_boost_enable;Maybe just:
Quoted 1 line
bool
iowait_boost;
Yes, Rafael mentioned this for the cpufreq framework part, I will do it this way in v2.
Quoted 12 lines
kernel/sched/cpufreq_schedutil.c struct sugov_policy { · line 51
Quoted 9 lines
kernel/sched/cpufreq_schedutil.c +1
-0};struct sugov_policy {@@ -47,6 +48,7 @@ struct sugov_policy {bool work_in_progress;bool need_freq_update; +unsigned int iowait_boost_enable;I don't see this being used at all. Am I missing something ?
Ah! Yes you're right, this is spurious, I will drop it. Thanks for spotting it.
-Joel
Rafael J. Wysocki
maintainerQuoted 27 lines · Joel Fernandes
Make iowait boost a cpufreq policy option and enable it for
intel_pstatecpufreq driver. Governors like schedutil can use it to determine if boosting for tasks that wake up withp->in_iowaitset is needed.Signed-off-by Joel Fernandes <[email protected]>--- drivers/cpufreq/intel_pstate.c | 1 + include/linux/cpufreq.h | 3 +++ 2 files changed, 4 insertions(+)drivers/cpufreq/intel_pstate.c +1
-0@@ -2239,6 +2239,7 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency =INTEL_CPUFREQ_TRANSITION_LATENCY ; policy->transition_delay_us =INTEL_CPUFREQ_TRANSITION_DELAY ; + policy->iowait_boost_enable =1 ;/* This reflects the intel_pstate_get_cpu_pstates() setting. */ policy->cur = policy->cpuinfo.min_freq;include/linux/cpufreq.h +0
-0
include/linux/cpufreq.h struct cpufreq_policy { · line 131
Quoted 5 lines
include/linux/cpufreq.h +2
-0@@ -127,6 +127,9 @@ struct cpufreq_policy {*/ unsigned int transition_delay_us; +/* Boost switch for tasks with p->in_iowait set */ +unsigned int iowait_boost_enable;
Could that be a bool field?
Quoted 7 lines
include/linux/cpufreq.h +1
-1+/* Cached frequency lookup from cpufreq_driver_resolve_freq. */ unsigned int cached_target_freq;int cached_resolved_idx; --2.13.0.303.g4ebf302169-goog
Thanks,
Rafael
On Thu, May 18, 2017 at 6:03 PM, Rafael J. Wysocki <[email protected]> wrote:
[..]
Quoted 8 lines
Quoted 8 lines
include/linux/cpufreq.h +0
-0@@ -127,6 +127,9 @@ struct cpufreq_policy {*/ unsigned int transition_delay_us;
Quoted 4 lines
include/linux/cpufreq.h struct cpufreq_policy { · line 131
Quoted 2 lines
include/linux/cpufreq.h +2
-0+/* Boost switch for tasks with p->in_iowait set */ +unsigned int iowait_boost_enable;Could that be a bool field?
Yes that would be better, will do.
thanks,
-Joel
Viresh Kumar
maintainerQuoted 9 lines · Joel Fernandes
Make iowait boost a cpufreq policy option and enable it for
intel_pstatecpufreq driver. Governors like schedutil can use it to determine if boosting for tasks that wake up withp->in_iowaitset is needed.Signed-off-by Joel Fernandes <[email protected]>--- drivers/cpufreq/intel_pstate.c | 1 + include/linux/cpufreq.h | 3 +++ 2 files changed, 4 insertions(+)
Hi Joel,
Please refer to MAINTAINERS file to find the list of people/list you need to send these patches to. You can take help from scripts/get_maintainers.pl as well.
--
viresh
Quoted 11 lines · Viresh Kumar
Quoted 9 lines · Joel Fernandes
Make iowait boost a cpufreq policy option and enable it for
intel_pstatecpufreq driver. Governors like schedutil can use it to determine if boosting for tasks that wake up withp->in_iowaitset is needed.Signed-off-by Joel Fernandes <[email protected]>--- drivers/cpufreq/intel_pstate.c | 1 + include/linux/cpufreq.h | 3 +++ 2 files changed, 4 insertions(+)
Quoted 5 lines
Hi Joel,
Please refer to
MAINTAINERSfile to find the list of people/list you need to send these patches to. You can take help fromscripts/get_maintainers.plas well.
Ok with me.
thanks,