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

Commit f079246b authored by Pavankumar Kondeti's avatar Pavankumar Kondeti Committed by Abhijeet Dharmapurikar
Browse files

sched/fair: start_cpu() fix for rtg_target case



It is possible that an offlined cpu be returned while adjusting the
start_cpu to the preferred cluster. The dereferencing of sched domain
via an offlined cpu will end up accessing stale pointers.

To fix it, check the preferred cpu mask against online mask. Moreover
since a cpu always fits its preferred cluster, move the check before
task_fits_max based ones.

Note that task_fits_max based start_cpu checks do not suffer from
returning an offline cpu because the {min/mid/max}_cap_orig_cpu are
updated in hotplug path such that they always point to an online cpu.

Change-Id: Ib3b03b5eac2c555a84e3e5719afce33e7be8abb2
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent 8c856f2d
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -7053,6 +7053,15 @@ static int start_cpu(struct task_struct *p, bool boosted,
	if (boosted)
		return rd->max_cap_orig_cpu;

	/* A task always fits on its rtg_target */
	if (rtg_target) {
		int rtg_target_cpu = cpumask_first_and(rtg_target,
						cpu_online_mask);

		if (rtg_target_cpu < nr_cpu_ids)
			return rtg_target_cpu;
	}

	/* Where the task should land based on its demand */
	if (rd->min_cap_orig_cpu != -1
			&& task_fits_max(p, rd->min_cap_orig_cpu))
@@ -7063,20 +7072,6 @@ static int start_cpu(struct task_struct *p, bool boosted,
	else
		start_cpu = rd->max_cap_orig_cpu;

	/*
	 * start it up to its preferred cluster if the preferred clusteris
	 * higher capacity
	 */
	if (start_cpu != -1 && rtg_target &&
			!cpumask_test_cpu(start_cpu, rtg_target)) {
		int rtg_target_cpu = cpumask_first(rtg_target);

		if (capacity_orig_of(start_cpu) <
			capacity_orig_of(rtg_target_cpu)) {
			start_cpu = rtg_target_cpu;
		}
	}

	return start_cpu;
}