From: Balbir Singh <bsingharora@gmail.com>
To: Anton Blanchard <anton@ozlabs.org>,
benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au,
npiggin@gmail.com, cyrilbur@gmail.com
Cc: linuxppc-dev@lists.ozlabs.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: Re: [PATCH] powerpc: During context switch, check before setting mm_cpumask
Date: Tue, 4 Oct 2016 10:25:31 +1100 [thread overview]
Message-ID: <b0537503-e415-ec23-f2c9-88d18209473e@gmail.com> (raw)
In-Reply-To: <1475476829-6296-1-git-send-email-anton@ozlabs.org>
On 03/10/16 17:40, Anton Blanchard wrote:
> From: Anton Blanchard <anton@samba.org>
>
> During context switch, switch_mm() sets our current CPU in mm_cpumask.
> We can avoid this atomic sequence in most cases by checking before
> setting the bit.
>
> Testing on a POWER8 using our context switch microbenchmark:
>
> tools/testing/selftests/powerpc/benchmarks/context_switch \
> --process --no-fp --no-altivec --no-vector
>
> Performance improves 2%.
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
> arch/powerpc/include/asm/mmu_context.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
> index 475d1be..5c45114 100644
> --- a/arch/powerpc/include/asm/mmu_context.h
> +++ b/arch/powerpc/include/asm/mmu_context.h
> @@ -72,7 +72,8 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
> struct task_struct *tsk)
> {
> /* Mark this context has been used on the new CPU */
> - cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
> + if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next)))
> + cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
>
I think this makes sense, in fact I think in the longer term we can
even use __set_bit() reorder-able version since we have a sync
coming out of schedule(). The read side for TLB flush can use a RMB
Acked-by: Balbir Singh <bsingharora@gmail.com>
Balbir Singh.
next prev parent reply other threads:[~2016-10-03 23:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-03 6:40 [PATCH] powerpc: During context switch, check before setting mm_cpumask Anton Blanchard
2016-10-03 23:25 ` Balbir Singh [this message]
2016-10-03 23:58 ` Benjamin Herrenschmidt
2016-10-04 0:20 ` Balbir Singh
2016-10-05 2:36 ` 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=b0537503-e415-ec23-f2c9-88d18209473e@gmail.com \
--to=bsingharora@gmail.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=anton@ozlabs.org \
--cc=benh@kernel.crashing.org \
--cc=cyrilbur@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=paulus@samba.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).