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

Commit 1bfb9a0d authored by Steve Muckle's avatar Steve Muckle
Browse files

sched: treat sync waker CPUs with 1 task as idle



When a CPU with one task performs a sync wakeup, its
one task is expected to sleep immediately so this CPU
should be treated as idle for the purposes of CPU selection
for the waking task.

This is only done when idle CPUs are the preferred targets
for non-small task wakeups. When prefer_idle is 0, the
CPU is left as non-idle in the selection logic so it is still
a preferred candidate for the sync wakeup.

Change-Id: I65c6535169293e8ba0c37fb5e88aec336338f7d7
Signed-off-by: default avatarSteve Muckle <smuckle@codeaurora.org>
parent b3c5c54d
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1914,6 +1914,7 @@ static int select_best_cpu(struct task_struct *p, int target, int reason,
	int boost = sched_boost();
	int cstate, min_cstate = INT_MAX;
	int prefer_idle = reason ? 1 : sysctl_sched_prefer_idle;
	int curr_cpu = smp_processor_id();

	trace_sched_task_load(p, small_task, boost, reason, sync, prefer_idle);

@@ -1979,9 +1980,14 @@ static int select_best_cpu(struct task_struct *p, int target, int reason,
		/*
		 * Partition CPUs based on whether they are completely idle
		 * or not. For completely idle CPUs we choose the one in
		 * the lowest C-state and then break ties with power cost
		 * the lowest C-state and then break ties with power cost.
		 *
		 * For sync wakeups we only consider the waker CPU as idle if
		 * prefer_idle is set. Otherwise if prefer_idle is unset sync
		 * wakeups will get biased away from the waker CPU.
		 */
		if (idle_cpu(i)) {
		if (idle_cpu(i) || (sync && i == curr_cpu && prefer_idle &&
				    cpu_rq(i)->nr_running == 1)) {
			if (cstate > min_cstate)
				continue;