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

Commit b9d1ecec authored by Saravana Kannan's avatar Saravana Kannan Committed by Jonathan Avila
Browse files

cpufreq: schedutil: Ignore CPU load older than WALT window size



The old code used to ignore CPU load older than 1 tick. Since the WALT
window size can be more than 1 tick (and is configurable), this can cause
an incorrect frequency drop in the middle of a WALT window. Use WALT window
size to ignore CPU load instead.

Change-Id: If42420f595ba9722866174c2cda8b6c2fdf34f92
Signed-off-by: default avatarSaravana Kannan <skannan@codeaurora.org>
Signed-off-by: default avatarRohit Gupta <rohgup@codeaurora.org>
[avilaj@codeaurora.org: Fixed merge conflicts.]
Signed-off-by: default avatarJonathan Avila <avilaj@codeaurora.org>
parent e8964510
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ struct sugov_cpu {
};

static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu);
static unsigned int stale_ns;

/************************ Governor internals ***********************/

@@ -538,12 +539,28 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
{
	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
	struct cpufreq_policy *policy = sg_policy->policy;
	u64 last_freq_update_time = sg_policy->last_freq_update_time;
	unsigned long util = 0, max = 1;
	unsigned int j;

	for_each_cpu(j, policy->cpus) {
		struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
		unsigned long j_util, j_max;
		s64 delta_ns;

		/*
		 * If the CPU utilization was last updated before the previous
		 * frequency update and the time elapsed between the last update
		 * of the CPU utilization and the last frequency update is long
		 * enough, don't take the CPU into account as it probably is
		 * idle now (and clear iowait_boost for it).
		 */
		delta_ns = last_freq_update_time - j_sg_cpu->last_update;
		if (delta_ns > stale_ns) {
			sugov_iowait_reset(j_sg_cpu, last_freq_update_time,
					   false);
			continue;
		}

		j_util = sugov_get_util(j_sg_cpu);
		j_max = j_sg_cpu->max;
@@ -859,6 +876,7 @@ static int sugov_init(struct cpufreq_policy *policy)

	policy->governor_data = sg_policy;
	sg_policy->tunables = tunables;
	stale_ns = sched_ravg_window + (sched_ravg_window >> 3);

	ret = kobject_init_and_add(&tunables->attr_set.kobj, &sugov_tunables_ktype,
				   get_governor_parent_kobj(policy), "%s",