[RFC PATCH 6/7] powerpc/64s/radix: reset mm_cpumask for single thread process when possible
Nicholas Piggin
npiggin at gmail.com
Wed Nov 1 10:28:19 AEDT 2017
On Tue, 31 Oct 2017 18:18:27 +1100
Nicholas Piggin <npiggin at gmail.com> wrote:
> diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
> index 49cc581a31cd..db7e696e4faf 100644
> --- a/arch/powerpc/mm/tlb-radix.c
> +++ b/arch/powerpc/mm/tlb-radix.c
> @@ -255,10 +255,18 @@ void radix__flush_tlb_mm(struct mm_struct *mm)
> return;
>
> preempt_disable();
> - if (!mm_is_thread_local(mm))
> - _tlbie_pid(pid, RIC_FLUSH_TLB);
> - else
> + if (!mm_is_thread_local(mm)) {
> + if (atomic_read(&mm->mm_users) == 1 && current->mm == mm) {
> + _tlbie_pid(pid, RIC_FLUSH_ALL);
> + atomic_set(&mm->context.active_cpus, 1);
> + cpumask_clear(mm_cpumask(mm));
> + cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm));
Ben and Michael pointed out this could be racy. At least mmget_not_zero
could in theory come in here, grab the mm, and use_mm it. Needs a bit
more auditing throughout the tree first.
We could close races by putting a lock around the mm_is_thread_local test
and resetting the cpumask and counter, taken in mm switch path as well.
Would be nice to avoid that if the use_mm/mmget/etc APIs don't get in the
way.
Thanks,
Nick
More information about the Linuxppc-dev
mailing list