Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched/membarrier: fix missing local execution of ipi_sync_rq_state()

The function sync_runqueues_membarrier_state() should copy the
membarrier state from the @mm received as parameter to each runqueue
currently running tasks using that mm.

However, the use of smp_call_function_many() skips the current runqueue,
which is unintended. Replace by a call to on_each_cpu_mask().

Fixes: 227a4aadc75b ("sched/membarrier: Fix p->mm->membarrier_state racy load")
Reported-by: Nadav Amit <nadav.amit@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org # 5.4.x+
Link: https://lore.kernel.org/r/74F1E842-4A84-47BF-B6C2-5407DFDD4A4A@gmail.com

authored by

Mathieu Desnoyers and committed by
Ingo Molnar
ce29ddc4 50caf9c1

+1 -3
+1 -3
kernel/sched/membarrier.c
··· 471 } 472 rcu_read_unlock(); 473 474 - preempt_disable(); 475 - smp_call_function_many(tmpmask, ipi_sync_rq_state, mm, 1); 476 - preempt_enable(); 477 478 free_cpumask_var(tmpmask); 479 cpus_read_unlock();
··· 471 } 472 rcu_read_unlock(); 473 474 + on_each_cpu_mask(tmpmask, ipi_sync_rq_state, mm, true); 475 476 free_cpumask_var(tmpmask); 477 cpus_read_unlock();