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

Commit af362094 authored by Chris Redpath's avatar Chris Redpath Committed by Quentin Perret
Browse files

ANDROID: sched: Unconditionally honor sync flag for energy-aware wakeups



Since we don't do energy-aware wakeups when we are overutilized, always
honoring sync wakeups in this state does not prevent wake-wide mechanics
overruling the flag as normal.

This patch is based upon previous work to build EAS for android products.

sync-hint code taken from commit 4a5e890ec60d
"sched/fair: add tunable to force selection at cpu granularity" written
by Juri Lelli <juri.lelli@arm.com>

Signed-off-by: default avatarChris Redpath <chris.redpath@arm.com>
(cherry-picked from commit f1ec666a62dec1083ed52fe1ddef093b84373aaf)
[ Moved the feature to find_energy_efficient_cpu() ]
Signed-off-by: default avatarQuentin Perret <quentin.perret@arm.com>
Change-Id: I4b3d79141fc8e53dc51cd63ac11096c2e3cb10f5
parent c27c5610
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };

extern unsigned int sysctl_sched_latency;
extern unsigned int sysctl_sched_min_granularity;
extern unsigned int sysctl_sched_sync_hint_enable;
extern unsigned int sysctl_sched_cstate_aware;
extern unsigned int sysctl_sched_wakeup_granularity;
extern unsigned int sysctl_sched_child_runs_first;
+13 −2
Original line number Diff line number Diff line
@@ -40,6 +40,11 @@
unsigned int sysctl_sched_latency			= 6000000ULL;
unsigned int normalized_sysctl_sched_latency		= 6000000ULL;

/*
 * Enable/disable honoring sync flag in energy-aware wakeups.
 */
unsigned int sysctl_sched_sync_hint_enable = 1;

/*
 * Enable/disable using cstate knowledge in idle sibling selection
 */
@@ -6945,7 +6950,7 @@ static DEFINE_PER_CPU(cpumask_t, energy_cpus);
 * let's keep things simple by re-using the existing slow path.
 */

static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int sync)
{
	unsigned long prev_energy = ULONG_MAX, best_energy = ULONG_MAX;
	struct root_domain *rd = cpu_rq(smp_processor_id())->rd;
@@ -6955,6 +6960,12 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
	struct sched_domain *sd;
	cpumask_t *candidates;

	if (sysctl_sched_sync_hint_enable && sync) {
		cpu = smp_processor_id();
		if (cpumask_test_cpu(cpu, &p->cpus_allowed))
			return cpu;
	}

	rcu_read_lock();
	pd = rcu_dereference(rd->pd);
	if (!pd || READ_ONCE(rd->overutilized))
@@ -7049,7 +7060,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f
		record_wakee(p);

		if (static_branch_unlikely(&sched_energy_present)) {
			new_cpu = find_energy_efficient_cpu(p, prev_cpu);
			new_cpu = find_energy_efficient_cpu(p, prev_cpu, sync);
			if (new_cpu >= 0)
				return new_cpu;
			new_cpu = prev_cpu;
+7 −0
Original line number Diff line number Diff line
@@ -345,6 +345,13 @@ static struct ctl_table kern_table[] = {
		.extra1		= &min_sched_granularity_ns,
		.extra2		= &max_sched_granularity_ns,
	},
	{
		.procname	= "sched_sync_hint_enable",
		.data		= &sysctl_sched_sync_hint_enable,
		.maxlen		= sizeof(unsigned int),
		.mode		= 0644,
		.proc_handler	= proc_dointvec,
	},
	{
		.procname	= "sched_wakeup_granularity_ns",
		.data		= &sysctl_sched_wakeup_granularity,