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

Commit e14d325a authored by Pavankumar Kondeti's avatar Pavankumar Kondeti
Browse files

sched: break the forever prev_cpu selection preference



The select_best_cpu() algorithm selects the previous CPU as the target
CPU if the task did not sleep for more than 2 msec (controlled by
/proc/sys/kernel/sched_select_prev_cpu_us). The complete CPU search is
not done for a long time for tasks which sleeps for a short duration
in between the long execution slices. Enforce a 100 msec threshold since
the last selection time to run the complete algorithm.

CRs-Fixed: 984463
Change-Id: I329eecc6bae8f130cd5598f6cee8ca5a01391cca
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent 11775467
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1324,6 +1324,7 @@ struct task_struct {
	u32 init_load_pct;
	u64 last_wake_ts;
	u64 last_switch_out_ts;
	u64 last_cpu_selected_ts;
#ifdef CONFIG_SCHED_QHMP
	u64 run_start;
#endif
+1 −0
Original line number Diff line number Diff line
@@ -2813,6 +2813,7 @@ static inline void mark_task_starting(struct task_struct *p)

	wallclock = sched_ktime_clock();
	p->ravg.mark_start = p->last_wake_ts = wallclock;
	p->last_cpu_selected_ts = wallclock;
	p->last_switch_out_ts = 0;
}

+9 −0
Original line number Diff line number Diff line
@@ -2548,6 +2548,9 @@ static unsigned int __read_mostly
sched_short_sleep_task_threshold = 2000 * NSEC_PER_USEC;
unsigned int __read_mostly sysctl_sched_select_prev_cpu_us = 2000;

static unsigned int __read_mostly
sched_long_cpu_selection_threshold = 100 * NSEC_PER_MSEC;

unsigned int __read_mostly sysctl_sched_restrict_cluster_spill;

void update_up_down_migrate(void)
@@ -3239,6 +3242,7 @@ bias_to_prev_cpu(struct cpu_select_env *env, struct cluster_cpu_stats *stats)
	struct sched_cluster *cluster;

	if (env->boost || env->reason || env->need_idle ||
				!task->ravg.mark_start ||
				!sched_short_sleep_task_threshold)
		return false;

@@ -3247,6 +3251,10 @@ bias_to_prev_cpu(struct cpu_select_env *env, struct cluster_cpu_stats *stats)
					unlikely(!cpu_active(prev_cpu)))
		return false;

	if (task->ravg.mark_start - task->last_cpu_selected_ts >=
				sched_long_cpu_selection_threshold)
		return false;

	/*
	 * This function should be used by task wake up path only as it's
	 * assuming p->last_switch_out_ts as last sleep time.
@@ -3384,6 +3392,7 @@ retry:
		if (stats.best_capacity_cpu >= 0)
			target = stats.best_capacity_cpu;
	}
	p->last_cpu_selected_ts = sched_ktime_clock();

out:
	rcu_read_unlock();