From 33f05bd16a4ac2f6f36c9eb88016e2375dcb597c Mon Sep 17 00:00:00 2001 From: Christian Loehle Date: Thu, 5 Sep 2024 10:26:41 +0100 Subject: TEST: cpufreq/schedutil: iowait boost cap sysfs Add a knob to cap applied iowait_boost per sysfs. This is to test for potential regressions. Signed-off-by: Christian Loehle --- kernel/sched/cpufreq_schedutil.c | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -11,6 +11,7 @@ struct sugov_tunables { struct gov_attr_set attr_set; unsigned int rate_limit_us; + unsigned int iowait_boost_cap; }; struct sugov_policy { @@ -35,6 +36,8 @@ struct sugov_policy { bool limits_changed; bool need_freq_update; + + unsigned int iowait_boost_cap; }; struct sugov_cpu { @@ -316,6 +319,9 @@ static unsigned long sugov_iowait_apply( sg_cpu->iowait_boost_pending = false; + if (sg_cpu->iowait_boost > sg_cpu->sg_policy->iowait_boost_cap) + sg_cpu->iowait_boost = sg_cpu->sg_policy->iowait_boost_cap; + /* * sg_cpu->util is already in capacity scale; convert iowait_boost * into the same scale so we can compare. @@ -554,6 +560,14 @@ static ssize_t rate_limit_us_show(struct return sprintf(buf, "%u\n", tunables->rate_limit_us); } + +static ssize_t iowait_boost_cap_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_cap); +} + static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, size_t count) { @@ -572,10 +586,30 @@ rate_limit_us_store(struct gov_attr_set return count; } +static ssize_t +iowait_boost_cap_store(struct gov_attr_set *attr_set, const char *buf, size_t count) +{ + struct sugov_tunables *tunables = to_sugov_tunables(attr_set); + struct sugov_policy *sg_policy; + unsigned int iowait_boost_cap; + + if (kstrtouint(buf, 10, &iowait_boost_cap)) + return -EINVAL; + + tunables->iowait_boost_cap = iowait_boost_cap; + + list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook) + sg_policy->iowait_boost_cap = iowait_boost_cap; + + return count; +} + static struct governor_attr rate_limit_us = __ATTR_RW(rate_limit_us); +static struct governor_attr iowait_boost_cap = __ATTR_RW(iowait_boost_cap); static struct attribute *sugov_attrs[] = { &rate_limit_us.attr, + &iowait_boost_cap.attr, NULL }; ATTRIBUTE_GROUPS(sugov); @@ -765,6 +799,8 @@ static int sugov_init(struct cpufreq_pol tunables->rate_limit_us = cpufreq_policy_transition_delay_us(policy); + tunables->iowait_boost_cap = SCHED_CAPACITY_SCALE; + policy->governor_data = sg_policy; sg_policy->tunables = tunables; @@ -833,6 +869,8 @@ static int sugov_start(struct cpufreq_po sg_policy->limits_changed = false; sg_policy->cached_raw_freq = 0; + sg_policy->iowait_boost_cap = SCHED_CAPACITY_SCALE; + sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS); if (policy_is_shared(policy))