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

Commit 496c2d7a authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "sched/core: Fix race condition in clearing hmp request"

parents a3ed87c1 8cf40440
Loading
Loading
Loading
Loading
+25 −16
Original line number Diff line number Diff line
@@ -1248,15 +1248,16 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
		goto out;

	cpumask_andnot(&allowed_mask, new_mask, cpu_isolated_mask);
	cpumask_and(&allowed_mask, &allowed_mask, cpu_active_mask);

	dest_cpu = cpumask_any_and(cpu_active_mask, &allowed_mask);
	dest_cpu = cpumask_any(&allowed_mask);
	if (dest_cpu >= nr_cpu_ids) {
		dest_cpu = cpumask_any_and(cpu_active_mask, new_mask);
		cpumask_and(&allowed_mask, cpu_active_mask, new_mask);
		dest_cpu = cpumask_any(&allowed_mask);
		if (dest_cpu >= nr_cpu_ids) {
			ret = -EINVAL;
			goto out;
		}
		cpumask_copy(&allowed_mask, new_mask);
	}

	do_set_cpus_allowed(p, new_mask);
@@ -4635,6 +4636,8 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
	cpumask_var_t cpus_allowed, new_mask;
	struct task_struct *p;
	int retval;
	int dest_cpu;
	cpumask_t allowed_mask;

	rcu_read_lock();

@@ -4696,8 +4699,10 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
	}
#endif
again:
	cpumask_andnot(&allowed_mask, new_mask, cpu_isolated_mask);
	dest_cpu = cpumask_any_and(cpu_active_mask, &allowed_mask);
	if (dest_cpu < nr_cpu_ids) {
		retval = __set_cpus_allowed_ptr(p, new_mask, true);

		if (!retval) {
			cpuset_cpus_allowed(p, cpus_allowed);
			if (!cpumask_subset(new_mask, cpus_allowed)) {
@@ -4710,6 +4715,10 @@ again:
				goto again;
			}
		}
	} else {
		retval = -EINVAL;
	}

out_free_new_mask:
	free_cpumask_var(new_mask);
out_free_cpus_allowed:
@@ -5600,6 +5609,7 @@ int do_isolation_work_cpu_stop(void *data)
	 */
	nohz_balance_clear_nohz_mask(cpu);

	clear_hmp_request(cpu);
	local_irq_enable();
	return 0;
}
@@ -5724,7 +5734,6 @@ int sched_isolate_cpu(int cpu)

	migrate_sync_cpu(cpu, cpumask_first(&avail_cpus));
	stop_cpus(cpumask_of(cpu), do_isolation_work_cpu_stop, 0);
	clear_hmp_request(cpu);

	calc_load_migrate(rq);
	update_max_interval();