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

Commit d660893f authored by Pavankumar Kondeti's avatar Pavankumar Kondeti Committed by Satya Durga Srinivasu Prabhala
Browse files

sched/fair: Add bias towards previous CPU for high wakeup rate tasks



Skip the CPU selection algorithm for high wakeup rate tasks and select
the previous CPU if it is idle.

Change-Id: I99493c8c37e091c79723ee22a5230fbb6f4e33b9
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: default avatarSatya Durga Srinivasu Prabhala <satyap@codeaurora.org>
parent eac9d4d3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -705,6 +705,7 @@ struct task_struct {
	struct sched_entity		se;
	struct sched_rt_entity		rt;
	u64 last_sleep_ts;
	u64 last_cpu_selected_ts;
#ifdef CONFIG_SCHED_WALT
	struct ravg ravg;
	/*
+2 −0
Original line number Diff line number Diff line
@@ -2276,6 +2276,8 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
	p->se.nr_migrations		= 0;
	p->se.vruntime			= 0;
	p->last_sleep_ts		= 0;
	p->last_cpu_selected_ts		= 0;

	INIT_LIST_HEAD(&p->se.group_node);

#ifdef CONFIG_FAIR_GROUP_SCHED
+36 −0
Original line number Diff line number Diff line
@@ -7537,6 +7537,39 @@ static inline int wake_to_idle(struct task_struct *p)
		 (p->flags & PF_WAKE_UP_IDLE);
}

#define SCHED_SELECT_PREV_CPU_NSEC	2000000
#define SCHED_FORCE_CPU_SELECTION_NSEC	20000000

static inline bool
bias_to_prev_cpu(struct task_struct *p, struct cpumask *rtg_target)
{
	int prev_cpu = task_cpu(p);
#ifdef CONFIG_SCHED_WALT
	u64 ms = p->ravg.mark_start;
#else
	u64 ms = sched_clock();
#endif

	if (cpu_isolated(prev_cpu) || !idle_cpu(prev_cpu))
		return false;

	if (!ms)
		return false;

	if (ms - p->last_cpu_selected_ts >= SCHED_SELECT_PREV_CPU_NSEC) {
		p->last_cpu_selected_ts = ms;
		return false;
	}

	if (ms - p->last_sleep_ts >= SCHED_SELECT_PREV_CPU_NSEC)
		return false;

	if (rtg_target && !cpumask_test_cpu(prev_cpu, rtg_target))
		return false;

	return true;
}

#ifdef CONFIG_SCHED_WALT
static inline struct cpumask *find_rtg_target(struct task_struct *p)
{
@@ -7636,6 +7669,9 @@ static int find_energy_efficient_cpu(struct sched_domain *sd,
		prefer_idle = sched_feat(EAS_PREFER_IDLE) ?
				(schedtune_prefer_idle(p) > 0) : 0;

		if (bias_to_prev_cpu(p, rtg_target))
			return prev_cpu;

		eenv->max_cpu_count = EAS_CPU_BKP + 1;

		fbt_env.rtg_target = rtg_target;