Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2517b9d7 authored by Miguel de Dios's avatar Miguel de Dios Committed by Pranav Vashi
Browse files

kernel: sched: cpufreq_schedutil: Make iowait boost optional.



Bug: 120438505
Change-Id: I59e3675a320ce71c3c90be3904756b125300ba6b
Signed-off-by: default avatarMiguel de Dios <migueldedios@google.com>
Signed-off-by: default avatarAlexander Winkowski <dereference23@outlook.com>
Signed-off-by: default avatarPranav Vashi <neobuddy89@gmail.com>
parent e93d7345
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ struct sugov_tunables {
	struct gov_attr_set attr_set;
	unsigned int		up_rate_limit_us;
	unsigned int		down_rate_limit_us;
	bool iowait_boost_enable;
};

struct sugov_policy {
@@ -238,6 +239,11 @@ static void sugov_get_util(unsigned long *util, unsigned long *max, int cpu)
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;

	/* Clear iowait_boost if the CPU apprears to have been idle. */
	if (sg_cpu->iowait_boost) {
		s64 delta_ns = time - sg_cpu->last_update;
@@ -535,12 +541,35 @@ static ssize_t down_rate_limit_us_store(struct gov_attr_set *attr_set,
	return 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 snprintf(buf, PAGE_SIZE, "%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);
        bool enable;
        if (kstrtobool(buf, &enable))
                return -EINVAL;

        tunables->iowait_boost_enable = enable;
        return count;
}

static struct governor_attr up_rate_limit_us = __ATTR_RW(up_rate_limit_us);
static struct governor_attr down_rate_limit_us = __ATTR_RW(down_rate_limit_us);
static struct governor_attr iowait_boost_enable =
	__ATTR_RW(iowait_boost_enable);

static struct attribute *sugov_attributes[] = {
	&up_rate_limit_us.attr,
	&down_rate_limit_us.attr,
	&iowait_boost_enable.attr,
	NULL
};

@@ -733,6 +762,7 @@ static int sugov_init(struct cpufreq_policy *policy)
				cpufreq_policy_transition_delay_us(policy);
	tunables->down_rate_limit_us =
				cpufreq_policy_transition_delay_us(policy);
	tunables->iowait_boost_enable = false;

	policy->governor_data = sg_policy;
	sg_policy->tunables = tunables;