All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev@lists.ozlabs.org, aneesh.kumar@linux.vnet.ibm.com
Subject: Re: [PATCH 3/6] powerpc/mm: Ensure cpumask update is ordered
Date: Mon, 24 Jul 2017 21:20:07 +1000	[thread overview]
Message-ID: <20170724212007.7f472332@roar.ozlabs.ibm.com> (raw)
In-Reply-To: <20170724042803.25848-3-benh@kernel.crashing.org>

On Mon, 24 Jul 2017 14:28:00 +1000
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> There is no guarantee that the various isync's involved with
> the context switch will order the update of the CPU mask with
> the first TLB entry for the new context being loaded by the HW.
> 
> Be safe here and add a memory barrier to order any subsequent
> load/store which may bring entries into the TLB.
> 
> The corresponding barrier on the other side already exists as
> pte updates use pte_xchg() which uses __cmpxchg_u64 which has
> a sync after the atomic operation.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  arch/powerpc/include/asm/mmu_context.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
> index ed9a36ee3107..ff1aeb2cd19f 100644
> --- a/arch/powerpc/include/asm/mmu_context.h
> +++ b/arch/powerpc/include/asm/mmu_context.h
> @@ -110,6 +110,7 @@ static inline void switch_mm_irqs_off(struct mm_struct *prev,
>  	/* Mark this context has been used on the new CPU */
>  	if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next))) {
>  		cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
> +		smp_mb();
>  		new_on_cpu = true;
>  	}
>  

I think this is the right thing to do, but it should be commented.
Is hwsync the right barrier? (i.e., it will order the page table walk)

Thanks,
Nick

  reply	other threads:[~2017-07-24 11:20 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24  4:27 [PATCH 1/6] powerpc/mm: Move pgdir setting into a helper Benjamin Herrenschmidt
2017-07-24  4:27 ` [PATCH 2/6] powerpc/mm: Avoid double irq save/restore in activate_mm Benjamin Herrenschmidt
2017-07-24  4:28 ` [PATCH 3/6] powerpc/mm: Ensure cpumask update is ordered Benjamin Herrenschmidt
2017-07-24 11:20   ` Nicholas Piggin [this message]
2017-07-24 20:54     ` Benjamin Herrenschmidt
2017-08-11 11:06     ` Nicholas Piggin
2017-08-11 22:40       ` Benjamin Herrenschmidt
2017-08-17 12:58       ` Michael Ellerman
2017-08-23 12:01   ` [3/6] " Michael Ellerman
2017-07-24  4:28 ` [PATCH 4/6] powerpc/mm: Use mm_is_thread_local() instread of open-coding Benjamin Herrenschmidt
2017-07-24  4:28 ` [PATCH 5/6] powerpc/mm: Optimize detection of thread local mm's Benjamin Herrenschmidt
2017-07-24 11:25   ` Nicholas Piggin
2017-07-24 13:46     ` Michael Ellerman
2017-07-25  0:34       ` Nicholas Piggin
2017-07-25 12:00         ` Michael Ellerman
2017-07-24 20:58     ` Benjamin Herrenschmidt
2017-07-25  0:44       ` Nicholas Piggin
2017-07-25  1:03         ` Benjamin Herrenschmidt
2017-07-25 10:55           ` Nicholas Piggin
2017-08-04 12:06   ` Frederic Barrat
2017-08-04 12:58     ` Benjamin Herrenschmidt
2017-08-21 17:27   ` Frederic Barrat
2017-08-21 17:35     ` Benjamin Herrenschmidt
2017-08-22 13:18       ` Frederic Barrat
2017-08-22 16:55         ` Benjamin Herrenschmidt
2017-08-24 16:40       ` Frederic Barrat
2017-08-24 18:47         ` Benjamin Herrenschmidt
2017-08-25  4:53           ` Frederic Barrat
2017-08-25  7:44             ` Benjamin Herrenschmidt
2017-08-25  8:03               ` Frederic Barrat
2017-08-22  4:28     ` Michael Ellerman
2017-07-24  4:28 ` [PATCH 6/6] powerpc/mm: Make switch_mm_irqs_off() out of line Benjamin Herrenschmidt
2017-08-24 12:37 ` [1/6] powerpc/mm: Move pgdir setting into a helper Michael Ellerman

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=20170724212007.7f472332@roar.ozlabs.ibm.com \
    --to=npiggin@gmail.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.