linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org,
	"Aneesh Kumar K . V" <aneesh.kumar@linux.vnet.ibm.com>,
	Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [RFC PATCH 6/7] powerpc/64s/radix: reset mm_cpumask for single thread process when possible
Date: Wed, 1 Nov 2017 10:28:19 +1100	[thread overview]
Message-ID: <20171101102819.3d955de6@roar.ozlabs.ibm.com> (raw)
In-Reply-To: <20171031071828.28448-1-npiggin@gmail.com>

On Tue, 31 Oct 2017 18:18:27 +1100
Nicholas Piggin <npiggin@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

  parent reply	other threads:[~2017-10-31 23:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20171031064432.25190-1-npiggin@gmail.com>
2017-10-31  7:18 ` [RFC PATCH 6/7] powerpc/64s/radix: reset mm_cpumask for single thread process when possible Nicholas Piggin
2017-10-31  7:18   ` [RFC PATCH 7/7] powerpc/64s/radix: Only flush local TLB for spurious fault flushes Nicholas Piggin
2017-10-31 23:28   ` Nicholas Piggin [this message]
2017-11-01  5:09   ` [RFC PATCH 6/7] powerpc/64s/radix: reset mm_cpumask for single thread process when possible Balbir Singh
2017-11-01  5:16     ` Nicholas Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171101102819.3d955de6@roar.ozlabs.ibm.com \
    --to=npiggin@gmail.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).