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

Commit f1f7125e authored by Steve Muckle's avatar Steve Muckle Committed by Chris Redpath
Browse files

ANDROID: sched: cpufreq: use PELT rt_rq as estimate of required RT CPU capacity



A policy of going to fmax on any RT activity will be detrimental
for power on many platforms. Often RT accounts for only a small amount
of CPU activity so sending the CPU frequency to fmax is overkill. Worse
still, some platforms may not be able to even complete the CPU frequency
change before the RT activity has already completed.

Cpufreq governors have not treated RT activity this way in the past so
it is not part of the expected semantics of the RT scheduling class. The
DL class offers guarantees about task completion and could be used for
this purpose.

Modify the schedutil algorithm to instead use the new PELT rt_rq signal
as an estimate of RT utilization of the CPU.

Based on previous work by Vincent Guittot <vincent.guittot@linaro.org>.

Change-Id: I1ed605a3e2512a94d34217a8e57c3fd97cca60be
Signed-off-by: default avatarSteve Muckle <smuckle@linaro.org>
(switched from rt_avg to PELT rt)
Signed-off-by: default avatarChris Redpath <chris.redpath@arm.com>
parent 574a2d18
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -12,8 +12,6 @@
#define SCHED_CPUFREQ_DL	(1U << 1)
#define SCHED_CPUFREQ_IOWAIT	(1U << 2)

#define SCHED_CPUFREQ_RT_DL	(SCHED_CPUFREQ_RT | SCHED_CPUFREQ_DL)

#ifdef CONFIG_CPU_FREQ
struct update_util_data {
       void (*func)(struct update_util_data *data, u64 time, unsigned int flags);
+10 −8
Original line number Diff line number Diff line
@@ -179,12 +179,14 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
static void sugov_get_util(unsigned long *util, unsigned long *max, int cpu)
{
	struct rq *rq = cpu_rq(cpu);
	unsigned long cfs_max;
	unsigned long max_cap, rt;

	cfs_max = arch_scale_cpu_capacity(NULL, cpu);
	max_cap = arch_scale_cpu_capacity(NULL, cpu);

	*util = min(rq->cfs.avg.util_avg, cfs_max);
	*max = cfs_max;
	rt = sched_get_rt_rq_util(cpu);

	*util = min(rq->cfs.avg.util_avg+rt, max_cap);
	*max = max_cap;
}

static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,
@@ -272,7 +274,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,

	busy = sugov_cpu_is_busy(sg_cpu);

	if (flags & SCHED_CPUFREQ_RT_DL) {
	if (flags & SCHED_CPUFREQ_DL) {
		next_f = policy->cpuinfo.max_freq;
	} else {
		sugov_get_util(&util, &max, sg_cpu->cpu);
@@ -313,7 +315,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
			j_sg_cpu->iowait_boost_pending = false;
			continue;
		}
		if (j_sg_cpu->flags & SCHED_CPUFREQ_RT_DL)
		if (j_sg_cpu->flags & SCHED_CPUFREQ_DL)
			return policy->cpuinfo.max_freq;

		j_util = j_sg_cpu->util;
@@ -349,7 +351,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
	sg_cpu->last_update = time;

	if (sugov_should_update_freq(sg_policy, time)) {
		if (flags & SCHED_CPUFREQ_RT_DL)
		if (flags & SCHED_CPUFREQ_DL)
			next_f = sg_policy->policy->cpuinfo.max_freq;
		else
			next_f = sugov_next_freq_shared(sg_cpu, time);
@@ -651,7 +653,7 @@ static int sugov_start(struct cpufreq_policy *policy)
		memset(sg_cpu, 0, sizeof(*sg_cpu));
		sg_cpu->cpu = cpu;
		sg_cpu->sg_policy = sg_policy;
		sg_cpu->flags = SCHED_CPUFREQ_RT;
		sg_cpu->flags = SCHED_CPUFREQ_DL;
		sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq;
	}

+6 −0
Original line number Diff line number Diff line
@@ -3404,6 +3404,12 @@ int update_rt_rq_load_avg(u64 now, int cpu, struct rt_rq *rt_rq, int running)
	return ret;
}

unsigned long sched_get_rt_rq_util(int cpu)
{
	struct rt_rq *rt_rq = &(cpu_rq(cpu)->rt);
	return rt_rq->avg.util_avg;
}

/*
 * Optional action to be done while updating the load average
 */