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

Commit 8544ede9 authored by Miguel de Dios's avatar Miguel de Dios Committed by Harshit Jain
Browse files

kernel: sched: Mitigate non-boosted tasks preempting boosted tasks



Currently when a boosted task is scheduled we use prefer_idle to try and
get it to an idle core. Once it's scheduled, there is a possibility we
can schedule a non-boosted task on the same core where the boosted task
is running on. This change aims to mitigate that possibility by checking
if the core we're targeting has a boosted task and if so, use the next
best idle core instead.

Bug: 131626264
Bug: 144961676
Change-Id: I3d321e1c71f96526f55f7f3a56e32db411311aa2
Signed-off-by: default avatarMiguel de Dios <migueldedios@google.com>
Signed-off-by: default avatarJimmy Shiu <jimmyshiu@google.com>
Signed-off-by: default avatarminaripenguin <minaripenguin@users.noreply.github.com>
parent 334ba2f8
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -7464,6 +7464,7 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
	bool next_group_higher_cap = false;
	int isolated_candidate = -1;
	struct root_domain *rd;
	struct task_struct *curr_tsk;

	*backup_cpu = -1;

@@ -7852,6 +7853,13 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
	 *   b) IDLE CPU: best_idle_cpu
	 */

    if (target_cpu != -1 && !idle_cpu(target_cpu) &&
			best_idle_cpu != -1) {
		curr_tsk = READ_ONCE(cpu_rq(target_cpu)->curr);
		if (curr_tsk && schedtune_task_boost_rcu_locked(curr_tsk))
			target_cpu = best_idle_cpu;
	}

	if (prefer_idle && (best_idle_cpu != -1)) {
		trace_sched_find_best_target(p, prefer_idle, min_util, cpu,
					     best_idle_cpu, best_active_cpu,
+18 −0
Original line number Diff line number Diff line
@@ -592,6 +592,24 @@ int schedtune_task_boost(struct task_struct *p)
	return task_boost;
}

/*  The same as schedtune_task_boost except assuming the caller has the rcu read
 *  lock.
 */
int schedtune_task_boost_rcu_locked(struct task_struct *p)
{
	struct schedtune *st;
	int task_boost;

	if (unlikely(!schedtune_initialized))
		return 0;

	/* Get task boost value */
	st = task_schedtune(p);
	task_boost = st->boost;

	return task_boost;
}

int schedtune_prefer_idle(struct task_struct *p)
{
	struct schedtune *st;
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ struct target_nrg {

int schedtune_cpu_boost(int cpu);
int schedtune_task_boost(struct task_struct *tsk);
int schedtune_task_boost_rcu_locked(struct task_struct *tsk);

int schedtune_prefer_idle(struct task_struct *tsk);