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

Commit 12f679ce authored by Puja Gupta's avatar Puja Gupta Committed by Gerrit - the friendly Code Review server
Browse files

sched: Don't update idle_cpus_mask during core isolation



Remove code to update nohz.idle_cpus_mask from
do_isolation_work_cpu_stop(), instead update find_new_ilb() to exclude
isolated_cpus. This is done to fix the issue where cpu is not present
in nohz.idle_cpus_mask but NOHZ_TICK_STOPPED is set. As a result even
if the cpu is unisolated, task won't see the cpu as idle due to
inconsistent nohz.idle_cpus_mask.
Also restore nohz_balance_exit_idle() to upstream version.

Signed-off-by: default avatarPuja Gupta <pujag@codeaurora.org>
[markivx: Trivial conflict due to asym code in nohz_needed]
Signed-off-by: default avatarVikram Mulukutla <markivx@codeaurora.org>

Change-Id: Ia0dfa18ca9d55512c461801234de889a173e13da
[satyap@codeaurora.org: trivial merge conflict resolution]
Signed-off-by: default avatarSatya Durga Srinivasu Prabhala <satyap@codeaurora.org>
parent 6b34662c
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -5742,12 +5742,6 @@ int do_isolation_work_cpu_stop(void *data)
	migrate_tasks(rq, &rf, false);
	raw_spin_unlock(&rq->lock);

	/*
	 * We might have been in tickless state. Clear NOHZ flags to avoid
	 * us being kicked for helping out with balancing
	 */
	nohz_balance_clear_nohz_mask(cpu);

	clear_walt_request(cpu);
	local_irq_enable();
	return 0;
+15 −11
Original line number Diff line number Diff line
@@ -10468,21 +10468,16 @@ static void nohz_balancer_kick(bool only_update)
	return;
}

void nohz_balance_clear_nohz_mask(int cpu)
{
	if (likely(cpumask_test_cpu(cpu, nohz.idle_cpus_mask))) {
		cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
		atomic_dec(&nohz.nr_cpus);
	}
}

void nohz_balance_exit_idle(unsigned int cpu)
{
	if (unlikely(test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))) {
		/*
		 * Completely isolated CPUs don't ever set, so we must test.
		 */
		nohz_balance_clear_nohz_mask(cpu);
		if (likely(cpumask_test_cpu(cpu, nohz.idle_cpus_mask))) {
			cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
			atomic_dec(&nohz.nr_cpus);
		}
		clear_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
	}
}
@@ -10792,6 +10787,7 @@ static inline bool nohz_kick_needed(struct rq *rq, bool only_update)
	struct sched_domain *sd;
	int nr_busy, i, cpu = rq->cpu;
	bool kick = false;
	cpumask_t cpumask;

	if (unlikely(rq->idle_balance) && !only_update)
		return false;
@@ -10807,7 +10803,8 @@ static inline bool nohz_kick_needed(struct rq *rq, bool only_update)
	 * None are in tickless mode and hence no need for NOHZ idle load
	 * balancing.
	 */
	if (likely(!atomic_read(&nohz.nr_cpus)))
	cpumask_andnot(&cpumask, nohz.idle_cpus_mask, cpu_isolated_mask);
	if (cpumask_empty(&cpumask))
		return false;

	if (only_update) {
@@ -10856,7 +10853,7 @@ static inline bool nohz_kick_needed(struct rq *rq, bool only_update)
	if (sd) {
		for_each_cpu(i, sched_domain_span(sd)) {
			if (i == cpu ||
			    !cpumask_test_cpu(i, nohz.idle_cpus_mask))
			    !cpumask_test_cpu(i, &cpumask))
				continue;

			if (sched_asym_prefer(i, cpu)) {
@@ -10884,6 +10881,13 @@ static __latent_entropy void run_rebalance_domains(struct softirq_action *h)
	enum cpu_idle_type idle = this_rq->idle_balance ?
						CPU_IDLE : CPU_NOT_IDLE;

	/*
	 * Since core isolation doesn't update nohz.idle_cpus_mask, there
	 * is a possibility this nohz kicked cpu could be isolated. Hence
	 * return if the cpu is isolated.
	 */
	if (cpu_isolated(this_rq->cpu))
		return;
	/*
	 * If this cpu has a pending nohz_balance_kick, then do the
	 * balancing on behalf of the other idle cpus whose ticks are
+0 −1
Original line number Diff line number Diff line
@@ -1627,7 +1627,6 @@ extern const struct sched_class idle_sched_class;
extern void update_group_capacity(struct sched_domain *sd, int cpu);

extern void trigger_load_balance(struct rq *rq);
extern void nohz_balance_clear_nohz_mask(int cpu);

extern void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask);