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

Commit 9c0b4078 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Sched/fair: Improve the scheduler"

parents 9e5eebf2 26faf5bc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3070,7 +3070,7 @@ static ssize_t proc_sched_task_boost_write(struct file *file,
	err = kstrtoint(strstrip(buffer), 0, &sched_boost);
	if (err)
		goto out;
	if (sched_boost < 0 || sched_boost > 2) {
	if (sched_boost < TASK_BOOST_NONE || sched_boost >= TASK_BOOST_END) {
		err = -EINVAL;
		goto out;
	}
+8 −0
Original line number Diff line number Diff line
@@ -112,6 +112,14 @@ struct task_group;
					 (task->flags & PF_FROZEN) == 0 && \
					 (task->state & TASK_NOLOAD) == 0)

enum task_boost_type {
	TASK_BOOST_NONE = 0,
	TASK_BOOST_ON_MID,
	TASK_BOOST_ON_MAX,
	TASK_BOOST_STRICT_MAX,
	TASK_BOOST_END,
};

#ifdef CONFIG_DEBUG_ATOMIC_SLEEP

/*
+1 −1
Original line number Diff line number Diff line
@@ -7800,7 +7800,7 @@ const u32 sched_prio_to_wmult[40] = {
 */
int set_task_boost(int boost, u64 period)
{
	if (boost < 0 || boost > 2)
	if (boost < TASK_BOOST_NONE || boost >= TASK_BOOST_END)
		return -EINVAL;
	if (boost) {
		current->boost = boost;
+35 −8
Original line number Diff line number Diff line
@@ -3916,7 +3916,7 @@ static inline bool task_fits_max(struct task_struct *p, int cpu)
			walt_should_kick_upmigrate(p, cpu))
			return false;
	} else { /* mid cap cpu */
		if (task_boost > 1)
		if (task_boost > TASK_BOOST_ON_MID)
			return false;
	}

@@ -3941,6 +3941,7 @@ struct find_best_target_env {
	bool boosted;
	int fastpath;
	int start_cpu;
	bool strict_max;
};

static inline void adjust_cpus_for_packing(struct task_struct *p,
@@ -6822,7 +6823,8 @@ static int get_start_cpu(struct task_struct *p)
	int start_cpu = rd->min_cap_orig_cpu;
	int task_boost = per_task_boost(p);
	bool boosted = schedtune_task_boost(p) > 0 ||
			task_boost_policy(p) == SCHED_BOOST_ON_BIG;
			task_boost_policy(p) == SCHED_BOOST_ON_BIG ||
			task_boost == TASK_BOOST_ON_MID;
	bool task_skip_min = task_skip_min_cpu(p);

	/*
@@ -6830,12 +6832,12 @@ static int get_start_cpu(struct task_struct *p)
	 * or just mid will be -1, there never be any other combinations of -1s
	 * beyond these
	 */
	if (task_skip_min || boosted || task_boost == 1) {
	if (task_skip_min || boosted) {
		start_cpu = rd->mid_cap_orig_cpu == -1 ?
			rd->max_cap_orig_cpu : rd->mid_cap_orig_cpu;
	}

	if (task_boost == 2) {
	if (task_boost > TASK_BOOST_ON_MID) {
		start_cpu = rd->max_cap_orig_cpu;
		return start_cpu;
	}
@@ -6902,6 +6904,9 @@ static void find_best_target(struct sched_domain *sd, cpumask_t *cpus,
	if (prefer_idle && boosted)
		target_capacity = 0;

	if (fbt_env->strict_max)
		most_spare_wake_cap = LONG_MIN;

	/* Find start CPU based on boost value */
	start_cpu = fbt_env->start_cpu;
	/* Find SD for the start CPU */
@@ -7217,7 +7222,8 @@ static void find_best_target(struct sched_domain *sd, cpumask_t *cpus,
		 * accommodated in the higher capacity CPUs.
		 */
		if ((prefer_idle && best_idle_cpu != -1) ||
		    (boosted && (best_idle_cpu != -1 || target_cpu != -1))) {
		    (boosted && (best_idle_cpu != -1 || target_cpu != -1 ||
		     (fbt_env->strict_max && most_spare_cap_cpu != -1)))) {
			if (boosted) {
				if (!next_group_higher_cap)
					break;
@@ -7600,8 +7606,8 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int sy
	int placement_boost = task_boost_policy(p);
	u64 start_t = 0;
	int delta = 0;
	int boosted = (schedtune_task_boost(p) > 0) ||
				(per_task_boost(p) > 0);
	int task_boost = per_task_boost(p);
	int boosted = (schedtune_task_boost(p) > 0) || (task_boost > 0);
	int start_cpu = get_start_cpu(p);

	if (start_cpu < 0)
@@ -7653,6 +7659,8 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu, int sy
		fbt_env.need_idle = need_idle;
		fbt_env.start_cpu = start_cpu;
		fbt_env.boosted = boosted;
		fbt_env.strict_max = is_rtg &&
			(task_boost == TASK_BOOST_STRICT_MAX);

		find_best_target(NULL, candidates, p, &fbt_env);
	} else {
@@ -8524,6 +8532,16 @@ static inline int migrate_degrades_locality(struct task_struct *p,
}
#endif

static inline bool can_migrate_boosted_task(struct task_struct *p,
			int src_cpu, int dst_cpu)
{
	if (per_task_boost(p) == TASK_BOOST_STRICT_MAX &&
		task_in_related_thread_group(p) &&
		(capacity_orig_of(dst_cpu) < capacity_orig_of(src_cpu)))
		return false;
	return true;
}

/*
 * can_migrate_task - may task p from runqueue rq be migrated to this_cpu?
 */
@@ -8544,6 +8562,12 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
	if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
		return 0;

	/*
	 * don't allow pull boost task to smaller cores.
	 */
	if (!can_migrate_boosted_task(p, env->src_cpu, env->dst_cpu))
		return 0;

	if (!cpumask_test_cpu(env->dst_cpu, &p->cpus_allowed)) {
		int cpu;

@@ -10632,7 +10656,10 @@ static int load_balance(int this_cpu, struct rq *this_rq,
			 * if the curr task on busiest CPU can't be
			 * moved to this_cpu:
			 */
			if (!cpumask_test_cpu(this_cpu, &busiest->curr->cpus_allowed)) {
			if (!cpumask_test_cpu(this_cpu,
						&busiest->curr->cpus_allowed)
				|| !can_migrate_boosted_task(busiest->curr,
						cpu_of(busiest), this_cpu)) {
				raw_spin_unlock_irqrestore(&busiest->lock,
							    flags);
				env.flags |= LBF_ALL_PINNED;