From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
maged michael <maged.michael@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Dave Watson <davejwatson@fb.com>,
Will Deacon <will.deacon@arm.com>, Andrew Hunter <ahh@google.com>,
David Sehr <sehr@google.com>, Paul Mackerras <paulus@samba.org>,
"H. Peter Anvin" <hpa@zytor.com>,
linux-arch <linux-arch@vger.kernel.org>, x86 <x86@kernel.org>,
"Russell King, ARM Linux" <linux@armlinux.org.uk>,
Greg Hackmann <ghackmann@google.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@redhat.com>,
Alan Stern <stern@rowland.harvard.edu>,
Paul <paulmck@linux.vnet.ibm.com>,
Andrea Parri <parri.andrea@gmail.com>,
Avi Kivity <avi@scylladb.com>, Boqun Feng <boqun.feng@gmail.com>,
Nicholas Piggin <npiggin@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-api <linux-api@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH for 4.16 v7 02/11] powerpc: membarrier: Skip memory barrier in switch_mm()
Date: Sat, 19 Jun 2021 10:02:02 -0500 [thread overview]
Message-ID: <20210619150202.GZ5077@gate.crashing.org> (raw)
In-Reply-To: <4d2026cc-28e1-7781-fc95-e6160bd8db86@csgroup.eu>
On Sat, Jun 19, 2021 at 11:35:34AM +0200, Christophe Leroy wrote:
>
>
> Le 18/06/2021 à 19:26, Mathieu Desnoyers a écrit :
> >----- On Jun 18, 2021, at 1:13 PM, Christophe Leroy
> >christophe.leroy@csgroup.eu wrote:
> >[...]
> >>
> >>I don't understand all that complexity to just replace a simple
> >>'smp_mb__after_unlock_lock()'.
> >>
> >>#define smp_mb__after_unlock_lock() smp_mb()
> >>#define smp_mb() barrier()
> >># define barrier() __asm__ __volatile__("": : :"memory")
> >>
> >>
> >>Am I missing some subtility ?
> >
> >On powerpc CONFIG_SMP, smp_mb() is actually defined as:
> >
> >#define smp_mb() __smp_mb()
> >#define __smp_mb() mb()
> >#define mb() __asm__ __volatile__ ("sync" : : : "memory")
> >
> >So the original motivation here was to skip a "sync" instruction whenever
> >switching between threads which are part of the same process. But based on
> >recent discussions, I suspect my implementation may be inaccurately doing
> >so though.
> >
>
> I see.
>
> Then, if you think a 'sync' is a concern, shouldn't we try and remove the
> forest of 'sync' in the I/O accessors ?
>
> I can't really understand why we need all those 'sync' and 'isync' and
> 'twi' around the accesses whereas I/O memory is usually mapped as 'Guarded'
> so memory access ordering is already garantied.
>
> I'm sure we'll save a lot with that.
The point of the twi in the I/O accessors was to make things easier to
debug if the accesses fail: for the twi insn to complete the load will
have to have completed as well. On a correctly working system you never
should need this (until something fails ;-) )
Without the twi you might need to enforce ordering in some cases still.
The twi is a very heavy hammer, but some of that that gives us is no
doubt actually needed.
Segher
WARNING: multiple messages have this Message-ID (diff)
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: maged michael <maged.michael@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Dave Watson <davejwatson@fb.com>,
Will Deacon <will.deacon@arm.com>,
"Russell King, ARM Linux" <linux@armlinux.org.uk>,
David Sehr <sehr@google.com>, Paul Mackerras <paulus@samba.org>,
"H. Peter Anvin" <hpa@zytor.com>,
linux-arch <linux-arch@vger.kernel.org>, x86 <x86@kernel.org>,
Andrew Hunter <ahh@google.com>,
Greg Hackmann <ghackmann@google.com>,
Ingo Molnar <mingo@redhat.com>,
Alan Stern <stern@rowland.harvard.edu>,
Paul <paulmck@linux.vnet.ibm.com>,
Andrea Parri <parri.andrea@gmail.com>,
Avi Kivity <avi@scylladb.com>, Boqun Feng <boqun.feng@gmail.com>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
Nicholas Piggin <npiggin@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-api <linux-api@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH for 4.16 v7 02/11] powerpc: membarrier: Skip memory barrier in switch_mm()
Date: Sat, 19 Jun 2021 10:02:02 -0500 [thread overview]
Message-ID: <20210619150202.GZ5077@gate.crashing.org> (raw)
In-Reply-To: <4d2026cc-28e1-7781-fc95-e6160bd8db86@csgroup.eu>
On Sat, Jun 19, 2021 at 11:35:34AM +0200, Christophe Leroy wrote:
>
>
> Le 18/06/2021 à 19:26, Mathieu Desnoyers a écrit :
> >----- On Jun 18, 2021, at 1:13 PM, Christophe Leroy
> >christophe.leroy@csgroup.eu wrote:
> >[...]
> >>
> >>I don't understand all that complexity to just replace a simple
> >>'smp_mb__after_unlock_lock()'.
> >>
> >>#define smp_mb__after_unlock_lock() smp_mb()
> >>#define smp_mb() barrier()
> >># define barrier() __asm__ __volatile__("": : :"memory")
> >>
> >>
> >>Am I missing some subtility ?
> >
> >On powerpc CONFIG_SMP, smp_mb() is actually defined as:
> >
> >#define smp_mb() __smp_mb()
> >#define __smp_mb() mb()
> >#define mb() __asm__ __volatile__ ("sync" : : : "memory")
> >
> >So the original motivation here was to skip a "sync" instruction whenever
> >switching between threads which are part of the same process. But based on
> >recent discussions, I suspect my implementation may be inaccurately doing
> >so though.
> >
>
> I see.
>
> Then, if you think a 'sync' is a concern, shouldn't we try and remove the
> forest of 'sync' in the I/O accessors ?
>
> I can't really understand why we need all those 'sync' and 'isync' and
> 'twi' around the accesses whereas I/O memory is usually mapped as 'Guarded'
> so memory access ordering is already garantied.
>
> I'm sure we'll save a lot with that.
The point of the twi in the I/O accessors was to make things easier to
debug if the accesses fail: for the twi insn to complete the load will
have to have completed as well. On a correctly working system you never
should need this (until something fails ;-) )
Without the twi you might need to enforce ordering in some cases still.
The twi is a very heavy hammer, but some of that that gives us is no
doubt actually needed.
Segher
next prev parent reply other threads:[~2021-06-19 15:16 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-29 20:20 [PATCH for 4.16 00/11] membarrier updates for 4.16 Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 v2 01/11] membarrier: selftest: Test private expedited cmd Mathieu Desnoyers
2018-01-29 20:20 ` [Linux-kselftest-mirror] " Mathieu Desnoyers
2018-01-29 20:20 ` mathieu.desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:25 ` [tip:sched/urgent] membarrier/selftest: Test private expedited command tip-bot for Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 v7 02/11] powerpc: membarrier: Skip memory barrier in switch_mm() Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 20:22 ` Ingo Molnar
2018-02-05 20:22 ` Ingo Molnar
[not found] ` <20180205202242.6ilyjh35byycf3ez-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-02-05 20:32 ` Mathieu Desnoyers
2018-02-05 20:32 ` Mathieu Desnoyers
2018-02-05 21:26 ` [tip:sched/urgent] powerpc, " tip-bot for Mathieu Desnoyers
2021-06-18 17:13 ` [PATCH for 4.16 v7 02/11] powerpc: " Christophe Leroy
2021-06-18 17:13 ` Christophe Leroy
2021-06-18 17:26 ` Mathieu Desnoyers
2021-06-18 17:26 ` Mathieu Desnoyers
2021-06-19 9:35 ` Christophe Leroy
2021-06-19 9:35 ` Christophe Leroy
2021-06-19 15:02 ` Segher Boessenkool [this message]
2021-06-19 15:02 ` Segher Boessenkool
2021-06-21 14:11 ` Christophe Leroy
2021-06-21 14:11 ` Christophe Leroy
2021-06-22 0:15 ` Segher Boessenkool
2021-06-22 0:15 ` Segher Boessenkool
2018-01-29 20:20 ` [PATCH for 4.16 v5 03/11] membarrier: Document scheduler barrier requirements Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:26 ` [tip:sched/urgent] " tip-bot for Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 v2 05/11] membarrier: selftest: Test global expedited cmd Mathieu Desnoyers
2018-01-29 20:20 ` [Linux-kselftest-mirror] " Mathieu Desnoyers
2018-01-29 20:20 ` mathieu.desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:27 ` [tip:sched/urgent] membarrier/selftest: Test global expedited command tip-bot for Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 v2 06/11] Introduce sync_core_before_usermode Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:28 ` [tip:sched/urgent] locking: Introduce sync_core_before_usermode() tip-bot for Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 v3 07/11] x86: Implement sync_core_before_usermode Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:28 ` [tip:sched/urgent] lockin/x86: Implement sync_core_before_usermode() tip-bot for Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 v4 09/11] membarrier: x86: Provide core serializing command Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:29 ` [tip:sched/urgent] membarrier/x86: " tip-bot for Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 10/11] membarrier: arm64: " Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:30 ` [tip:sched/urgent] membarrier/arm64: " tip-bot for Mathieu Desnoyers
[not found] ` <20180129202020.8515-1-mathieu.desnoyers-vg+e7yoeK/dWk0Htik3J/w@public.gmane.org>
2018-01-29 20:20 ` [PATCH for 4.16 v3 04/11] membarrier: provide GLOBAL_EXPEDITED command Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:27 ` [tip:sched/urgent] membarrier: Provide " tip-bot for Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 v3 08/11] membarrier: Provide core serializing command Mathieu Desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:29 ` [tip:sched/urgent] membarrier: Provide core serializing command, *_SYNC_CORE tip-bot for Mathieu Desnoyers
2018-01-29 20:20 ` [PATCH for 4.16 11/11] membarrier: selftest: Test private expedited sync core cmd Mathieu Desnoyers
2018-01-29 20:20 ` [Linux-kselftest-mirror] " Mathieu Desnoyers
2018-01-29 20:20 ` mathieu.desnoyers
2018-01-29 20:20 ` Mathieu Desnoyers
2018-02-05 21:30 ` [tip:sched/urgent] membarrier/selftest: Test private expedited sync core command tip-bot for Mathieu Desnoyers
2018-02-05 21:21 ` [PATCH for 4.16 00/11] membarrier updates for 4.16 Ingo Molnar
2018-02-05 21:21 ` Ingo Molnar
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=20210619150202.GZ5077@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=ahh@google.com \
--cc=avi@scylladb.com \
--cc=boqun.feng@gmail.com \
--cc=christophe.leroy@csgroup.eu \
--cc=davejwatson@fb.com \
--cc=ghackmann@google.com \
--cc=hpa@zytor.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=maged.michael@gmail.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=npiggin@gmail.com \
--cc=parri.andrea@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=sehr@google.com \
--cc=stern@rowland.harvard.edu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=will.deacon@arm.com \
--cc=x86@kernel.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.