Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1251324 > unrolled thread
| Started by | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| First post | 2015-10-20 09:20 +0200 |
| Last post | 2015-10-25 14:20 +0100 |
| Articles | 17 — 5 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Boqun Feng <boqun.feng@gmail.com> - 2015-10-20 09:20 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Peter Zijlstra <peterz@infradead.org> - 2015-10-20 11:30 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-20 23:30 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Peter Zijlstra <peterz@infradead.org> - 2015-10-21 10:20 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-21 21:40 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Boqun Feng <boqun.feng@gmail.com> - 2015-10-26 03:10 +0100
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Michael Ellerman <mpe@ellerman.id.au> - 2015-10-26 03:30 +0100
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Boqun Feng <boqun.feng@gmail.com> - 2015-10-26 10:00 +0100
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Paul Mackerras <paulus@ozlabs.org> - 2015-10-26 04:30 +0100
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Boqun Feng <boqun.feng@gmail.com> - 2015-10-26 10:00 +0100
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Boqun Feng <boqun.feng@gmail.com> - 2015-10-21 10:50 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-21 21:40 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Peter Zijlstra <peterz@infradead.org> - 2015-10-21 21:50 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Boqun Feng <boqun.feng@gmail.com> - 2015-10-22 14:10 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Peter Zijlstra <peterz@infradead.org> - 2015-10-24 12:30 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Boqun Feng <boqun.feng@gmail.com> - 2015-10-24 14:00 +0200
Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier Boqun Feng <boqun.feng@gmail.com> - 2015-10-25 14:20 +0100
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2015-10-20 09:20 +0200 |
| Subject | Re: [PATCH tip/locking/core v4 1/6] powerpc: atomic: Make *xchg and *cmpxchg a full barrier |
| Message-ID | <qlznc-52e-15@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > > Am I missing something here? If not, it seems to me that you need > the leading lwsync to instead be a sync. > > Of course, if I am not missing something, then this applies also to the > value-returning RMW atomic operations that you pulled this pattern from. > If so, it would seem that I didn't think through all the possibilities > back when PPC_ATOMIC_EXIT_BARRIER moved to sync... In fact, I believe > that I worried about the RMW atomic operation acting as a barrier, > but not as the load/store itself. :-/ > Paul, I know this may be difficult, but could you recall why the __futex_atomic_op() and futex_atomic_cmpxchg_inatomic() also got involved into the movement of PPC_ATOMIC_EXIT_BARRIER to "sync"? I did some search, but couldn't find the discussion of that patch. I ask this because I recall Peter once bought up a discussion: https://lkml.org/lkml/2015/8/26/596 Peter's conclusion seems to be that we could(though didn't want to) live with futex atomics not being full barriers. Peter, just be clear, I'm not in favor of relaxing futex atomics. But if I make PPC_ATOMIC_ENTRY_BARRIER being "sync", it will also strengthen the futex atomics, just wonder whether such strengthen is a -fix- or not, considering that I want this patch to go to -stable tree. Of course, in the meanwhile of waiting for your answer, I will try to figure out this by myself ;-) Regards, Boqun
[toc] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-10-20 11:30 +0200 |
| Message-ID | <qlBp2-7Wo-41@gated-at.bofh.it> |
| In reply to | #1251324 |
On Tue, Oct 20, 2015 at 03:15:32PM +0800, Boqun Feng wrote: > On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > > > > Am I missing something here? If not, it seems to me that you need > > the leading lwsync to instead be a sync. > > > > Of course, if I am not missing something, then this applies also to the > > value-returning RMW atomic operations that you pulled this pattern from. > > If so, it would seem that I didn't think through all the possibilities > > back when PPC_ATOMIC_EXIT_BARRIER moved to sync... In fact, I believe > > that I worried about the RMW atomic operation acting as a barrier, > > but not as the load/store itself. :-/ > > > > Paul, I know this may be difficult, but could you recall why the > __futex_atomic_op() and futex_atomic_cmpxchg_inatomic() also got > involved into the movement of PPC_ATOMIC_EXIT_BARRIER to "sync"? > > I did some search, but couldn't find the discussion of that patch. > > I ask this because I recall Peter once bought up a discussion: > > https://lkml.org/lkml/2015/8/26/596 > > Peter's conclusion seems to be that we could(though didn't want to) live > with futex atomics not being full barriers. > > > Peter, just be clear, I'm not in favor of relaxing futex atomics. But if > I make PPC_ATOMIC_ENTRY_BARRIER being "sync", it will also strengthen > the futex atomics, just wonder whether such strengthen is a -fix- or > not, considering that I want this patch to go to -stable tree. So Linus' argued that since we only need to order against user accesses (true) and priv changes typically imply strong barriers (open) we might want to allow archs to rely on those instead of mandating they have explicit barriers in the futex primitives. And I indeed forgot to follow up on that discussion. So; does PPC imply full barriers on user<->kernel boundaries? If so, its not critical to the futex atomic implementations what extra barriers are added. If not; then strengthening the futex ops is indeed (probably) a good thing :-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-20 23:30 +0200 |
| Message-ID | <qlMDM-7sL-33@gated-at.bofh.it> |
| In reply to | #1251515 |
On Tue, Oct 20, 2015 at 11:21:47AM +0200, Peter Zijlstra wrote: > On Tue, Oct 20, 2015 at 03:15:32PM +0800, Boqun Feng wrote: > > On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > > > > > > Am I missing something here? If not, it seems to me that you need > > > the leading lwsync to instead be a sync. > > > > > > Of course, if I am not missing something, then this applies also to the > > > value-returning RMW atomic operations that you pulled this pattern from. > > > If so, it would seem that I didn't think through all the possibilities > > > back when PPC_ATOMIC_EXIT_BARRIER moved to sync... In fact, I believe > > > that I worried about the RMW atomic operation acting as a barrier, > > > but not as the load/store itself. :-/ > > > > > > > Paul, I know this may be difficult, but could you recall why the > > __futex_atomic_op() and futex_atomic_cmpxchg_inatomic() also got > > involved into the movement of PPC_ATOMIC_EXIT_BARRIER to "sync"? > > > > I did some search, but couldn't find the discussion of that patch. > > > > I ask this because I recall Peter once bought up a discussion: > > > > https://lkml.org/lkml/2015/8/26/596 > > > > Peter's conclusion seems to be that we could(though didn't want to) live > > with futex atomics not being full barriers. I have heard of user-level applications relying on unlock-lock being a full barrier. So paranoia would argue for the full barrier. > > Peter, just be clear, I'm not in favor of relaxing futex atomics. But if > > I make PPC_ATOMIC_ENTRY_BARRIER being "sync", it will also strengthen > > the futex atomics, just wonder whether such strengthen is a -fix- or > > not, considering that I want this patch to go to -stable tree. > > So Linus' argued that since we only need to order against user accesses > (true) and priv changes typically imply strong barriers (open) we might > want to allow archs to rely on those instead of mandating they have > explicit barriers in the futex primitives. > > And I indeed forgot to follow up on that discussion. > > So; does PPC imply full barriers on user<->kernel boundaries? If so, its > not critical to the futex atomic implementations what extra barriers are > added. > > If not; then strengthening the futex ops is indeed (probably) a good > thing :-) I am not seeing a sync there, but I really have to defer to the maintainers on this one. I could easily have missed one. Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-10-21 10:20 +0200 |
| Message-ID | <qlWMO-5Dz-3@gated-at.bofh.it> |
| In reply to | #1252051 |
On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > I am not seeing a sync there, but I really have to defer to the > maintainers on this one. I could easily have missed one. So x86 implies a full barrier for everything that changes the CPL; and some form of implied ordering seems a must if you change the privilege level unless you tag every single load/store with the priv level at that time, which seems the more expensive option. So I suspect the typical implementation will flush all load/stores, change the effective priv level and continue. This can of course be implemented at a pure per CPU ordering (RCpc), which would be in line with the rest of Power, in which case you do indeed need an explicit sync to make it visible to other CPUs. But yes, if Michael or Ben could clarify this it would be good. Back then I talked to Ralf about what MIPS says on this, and MIPS arch spec is entirely quiet on this, it allows implementations full freedom IIRC. </ramble> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-21 21:40 +0200 |
| Message-ID | <qm7oT-4gV-25@gated-at.bofh.it> |
| In reply to | #1252535 |
On Wed, Oct 21, 2015 at 10:18:33AM +0200, Peter Zijlstra wrote: > On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > > I am not seeing a sync there, but I really have to defer to the > > maintainers on this one. I could easily have missed one. > > So x86 implies a full barrier for everything that changes the CPL; and > some form of implied ordering seems a must if you change the privilege > level unless you tag every single load/store with the priv level at that > time, which seems the more expensive option. And it is entirely possible that there is some similar operation somewhere in the powerpc entry/exit code. I would not trust myself to recognize it, though. > So I suspect the typical implementation will flush all load/stores, > change the effective priv level and continue. > > This can of course be implemented at a pure per CPU ordering (RCpc), > which would be in line with the rest of Power, in which case you do > indeed need an explicit sync to make it visible to other CPUs. > > But yes, if Michael or Ben could clarify this it would be good. > > Back then I talked to Ralf about what MIPS says on this, and MIPS arch > spec is entirely quiet on this, it allows implementations full freedom > IIRC. :-) ;-) ;-) > </ramble> Thanx, Paul -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2015-10-26 03:10 +0100 |
| Message-ID | <qnFot-2k7-3@gated-at.bofh.it> |
| In reply to | #1253157 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Oct 21, 2015 at 12:36:38PM -0700, Paul E. McKenney wrote: > On Wed, Oct 21, 2015 at 10:18:33AM +0200, Peter Zijlstra wrote: > > On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > > > I am not seeing a sync there, but I really have to defer to the > > > maintainers on this one. I could easily have missed one. > > > > So x86 implies a full barrier for everything that changes the CPL; and > > some form of implied ordering seems a must if you change the privilege > > level unless you tag every single load/store with the priv level at that > > time, which seems the more expensive option. > > And it is entirely possible that there is some similar operation > somewhere in the powerpc entry/exit code. I would not trust myself > to recognize it, though. > > > So I suspect the typical implementation will flush all load/stores, > > change the effective priv level and continue. > > > > This can of course be implemented at a pure per CPU ordering (RCpc), > > which would be in line with the rest of Power, in which case you do > > indeed need an explicit sync to make it visible to other CPUs. > > > > But yes, if Michael or Ben could clarify this it would be good. > > Michael and Ben, ping for this, thank you ;-) Regards, Boqun > > Back then I talked to Ralf about what MIPS says on this, and MIPS arch > > spec is entirely quiet on this, it allows implementations full freedom > > IIRC. > > :-) ;-) ;-) > > > </ramble> > > Thanx, Paul >
[toc] | [prev] | [next] | [standalone]
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Date | 2015-10-26 03:30 +0100 |
| Message-ID | <qnFHP-2qp-5@gated-at.bofh.it> |
| In reply to | #1253157 |
On Wed, 2015-10-21 at 12:36 -0700, Paul E. McKenney wrote: > On Wed, Oct 21, 2015 at 10:18:33AM +0200, Peter Zijlstra wrote: > > On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > > > I am not seeing a sync there, but I really have to defer to the > > > maintainers on this one. I could easily have missed one. > > > > So x86 implies a full barrier for everything that changes the CPL; and > > some form of implied ordering seems a must if you change the privilege > > level unless you tag every single load/store with the priv level at that > > time, which seems the more expensive option. > > And it is entirely possible that there is some similar operation > somewhere in the powerpc entry/exit code. I would not trust myself > to recognize it, though. > > So I suspect the typical implementation will flush all load/stores, > > change the effective priv level and continue. > > > > This can of course be implemented at a pure per CPU ordering (RCpc), > > which would be in line with the rest of Power, in which case you do > > indeed need an explicit sync to make it visible to other CPUs. > > > > But yes, if Michael or Ben could clarify this it would be good. > > :-) ;-) ;-) Sorry guys, these threads are so long I tend not to read them very actively :} Looking at the system call path, the straight line path does not include any barriers. I can't see any hidden in macros either. We also have an explicit sync in the switch_to() path, which suggests that we know system call is not a full barrier. Also looking at the architecture, section 1.5 which talks about the synchronisation that occurs on system calls, defines nothing in terms of memory ordering, and includes a programming note which says "Unlike the Synchronize instruction, a context synchronizing operation does not affect the order in which storage accesses are performed.". Whether that's actually how it's implemented I don't know, I'll see if I can find out. cheers -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2015-10-26 10:00 +0100 |
| Message-ID | <qnLNg-63Y-17@gated-at.bofh.it> |
| In reply to | #1255623 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Oct 26, 2015 at 11:20:01AM +0900, Michael Ellerman wrote: > > Sorry guys, these threads are so long I tend not to read them very actively :} > > Looking at the system call path, the straight line path does not include any > barriers. I can't see any hidden in macros either. > > We also have an explicit sync in the switch_to() path, which suggests that we > know system call is not a full barrier. > > Also looking at the architecture, section 1.5 which talks about the > synchronisation that occurs on system calls, defines nothing in terms of > memory ordering, and includes a programming note which says "Unlike the > Synchronize instruction, a context synchronizing operation does not affect the > order in which storage accesses are performed.". > Thank you, Michael. So IIUC, "sc" and "rfid" just imply an execution barrier like "isync" rather than a memory barrier. So memory barriers are needed if a system call need a memory ordering guarantee. Regards, Boqun > Whether that's actually how it's implemented I don't know, I'll see if I can > find out. > > cheers >
[toc] | [prev] | [next] | [standalone]
| From | Paul Mackerras <paulus@ozlabs.org> |
|---|---|
| Date | 2015-10-26 04:30 +0100 |
| Message-ID | <qnGDV-351-39@gated-at.bofh.it> |
| In reply to | #1252535 |
On Wed, Oct 21, 2015 at 10:18:33AM +0200, Peter Zijlstra wrote: > On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > > I am not seeing a sync there, but I really have to defer to the > > maintainers on this one. I could easily have missed one. > > So x86 implies a full barrier for everything that changes the CPL; and > some form of implied ordering seems a must if you change the privilege > level unless you tag every single load/store with the priv level at that > time, which seems the more expensive option. > > So I suspect the typical implementation will flush all load/stores, > change the effective priv level and continue. > > This can of course be implemented at a pure per CPU ordering (RCpc), > which would be in line with the rest of Power, in which case you do > indeed need an explicit sync to make it visible to other CPUs. Right - interrupts and returns from interrupt are context synchronizing operations, which means they wait until all outstanding instructions have got to the point where they have reported any exceptions they're going to report, which means in turn that loads and stores have completed address translation. But all of that doesn't imply anything about the visibility of the loads and stores. There is a full barrier in the context switch path, but not in the system call entry/exit path. Paul. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2015-10-26 10:00 +0100 |
| Message-ID | <qnLNg-63Y-13@gated-at.bofh.it> |
| In reply to | #1255638 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Oct 26, 2015 at 02:20:21PM +1100, Paul Mackerras wrote: > On Wed, Oct 21, 2015 at 10:18:33AM +0200, Peter Zijlstra wrote: > > On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > > > I am not seeing a sync there, but I really have to defer to the > > > maintainers on this one. I could easily have missed one. > > > > So x86 implies a full barrier for everything that changes the CPL; and > > some form of implied ordering seems a must if you change the privilege > > level unless you tag every single load/store with the priv level at that > > time, which seems the more expensive option. > > > > So I suspect the typical implementation will flush all load/stores, > > change the effective priv level and continue. > > > > This can of course be implemented at a pure per CPU ordering (RCpc), > > which would be in line with the rest of Power, in which case you do > > indeed need an explicit sync to make it visible to other CPUs. > > Right - interrupts and returns from interrupt are context > synchronizing operations, which means they wait until all outstanding > instructions have got to the point where they have reported any > exceptions they're going to report, which means in turn that loads and > stores have completed address translation. But all of that doesn't > imply anything about the visibility of the loads and stores. > > There is a full barrier in the context switch path, but not in the > system call entry/exit path. > Thank you, Paul. That's much clear now ;-) Regards, Boqun
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2015-10-21 10:50 +0200 |
| Message-ID | <qlXfR-6bq-27@gated-at.bofh.it> |
| In reply to | #1252051 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > On Tue, Oct 20, 2015 at 11:21:47AM +0200, Peter Zijlstra wrote: > > On Tue, Oct 20, 2015 at 03:15:32PM +0800, Boqun Feng wrote: > > > On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > > > > > > > > Am I missing something here? If not, it seems to me that you need > > > > the leading lwsync to instead be a sync. > > > > > > > > Of course, if I am not missing something, then this applies also to the > > > > value-returning RMW atomic operations that you pulled this pattern from. > > > > If so, it would seem that I didn't think through all the possibilities > > > > back when PPC_ATOMIC_EXIT_BARRIER moved to sync... In fact, I believe > > > > that I worried about the RMW atomic operation acting as a barrier, > > > > but not as the load/store itself. :-/ > > > > > > > > > > Paul, I know this may be difficult, but could you recall why the > > > __futex_atomic_op() and futex_atomic_cmpxchg_inatomic() also got > > > involved into the movement of PPC_ATOMIC_EXIT_BARRIER to "sync"? > > > > > > I did some search, but couldn't find the discussion of that patch. > > > > > > I ask this because I recall Peter once bought up a discussion: > > > > > > https://lkml.org/lkml/2015/8/26/596 > > > > > > Peter's conclusion seems to be that we could(though didn't want to) live > > > with futex atomics not being full barriers. > > I have heard of user-level applications relying on unlock-lock being a > full barrier. So paranoia would argue for the full barrier. > Understood. So a full barrier on one side of these operations is enough, I think. IOW, there is no need to strengthen these operations. > > > Peter, just be clear, I'm not in favor of relaxing futex atomics. But if > > > I make PPC_ATOMIC_ENTRY_BARRIER being "sync", it will also strengthen > > > the futex atomics, just wonder whether such strengthen is a -fix- or > > > not, considering that I want this patch to go to -stable tree. > > > > So Linus' argued that since we only need to order against user accesses > > (true) and priv changes typically imply strong barriers (open) we might > > want to allow archs to rely on those instead of mandating they have > > explicit barriers in the futex primitives. > > > > And I indeed forgot to follow up on that discussion. > > > > So; does PPC imply full barriers on user<->kernel boundaries? If so, its > > not critical to the futex atomic implementations what extra barriers are > > added. > > > > If not; then strengthening the futex ops is indeed (probably) a good > > thing :-) Peter, that's probably a good thing, but I'm not that familiar with futex right now, so I won't touch that part if unnecessary in this series. Regards, Boqun > > I am not seeing a sync there, but I really have to defer to the > maintainers on this one. I could easily have missed one. > > Thanx, Paul >
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2015-10-21 21:40 +0200 |
| Message-ID | <qm7oS-4gV-11@gated-at.bofh.it> |
| In reply to | #1252575 |
On Wed, Oct 21, 2015 at 04:45:03PM +0800, Boqun Feng wrote: > On Tue, Oct 20, 2015 at 02:28:35PM -0700, Paul E. McKenney wrote: > > On Tue, Oct 20, 2015 at 11:21:47AM +0200, Peter Zijlstra wrote: > > > On Tue, Oct 20, 2015 at 03:15:32PM +0800, Boqun Feng wrote: > > > > On Wed, Oct 14, 2015 at 01:19:17PM -0700, Paul E. McKenney wrote: > > > > > > > > > > Am I missing something here? If not, it seems to me that you need > > > > > the leading lwsync to instead be a sync. > > > > > > > > > > Of course, if I am not missing something, then this applies also to the > > > > > value-returning RMW atomic operations that you pulled this pattern from. > > > > > If so, it would seem that I didn't think through all the possibilities > > > > > back when PPC_ATOMIC_EXIT_BARRIER moved to sync... In fact, I believe > > > > > that I worried about the RMW atomic operation acting as a barrier, > > > > > but not as the load/store itself. :-/ > > > > > > > > > > > > > Paul, I know this may be difficult, but could you recall why the > > > > __futex_atomic_op() and futex_atomic_cmpxchg_inatomic() also got > > > > involved into the movement of PPC_ATOMIC_EXIT_BARRIER to "sync"? > > > > > > > > I did some search, but couldn't find the discussion of that patch. > > > > > > > > I ask this because I recall Peter once bought up a discussion: > > > > > > > > https://lkml.org/lkml/2015/8/26/596 > > > > > > > > Peter's conclusion seems to be that we could(though didn't want to) live > > > > with futex atomics not being full barriers. > > > > I have heard of user-level applications relying on unlock-lock being a > > full barrier. So paranoia would argue for the full barrier. > > Understood. > > So a full barrier on one side of these operations is enough, I think. > IOW, there is no need to strengthen these operations. Do we need to also worry about other futex use cases? Thanx, Paul > > > > Peter, just be clear, I'm not in favor of relaxing futex atomics. But if > > > > I make PPC_ATOMIC_ENTRY_BARRIER being "sync", it will also strengthen > > > > the futex atomics, just wonder whether such strengthen is a -fix- or > > > > not, considering that I want this patch to go to -stable tree. > > > > > > So Linus' argued that since we only need to order against user accesses > > > (true) and priv changes typically imply strong barriers (open) we might > > > want to allow archs to rely on those instead of mandating they have > > > explicit barriers in the futex primitives. > > > > > > And I indeed forgot to follow up on that discussion. > > > > > > So; does PPC imply full barriers on user<->kernel boundaries? If so, its > > > not critical to the futex atomic implementations what extra barriers are > > > added. > > > > > > If not; then strengthening the futex ops is indeed (probably) a good > > > thing :-) > > Peter, that's probably a good thing, but I'm not that familiar with > futex right now, so I won't touch that part if unnecessary in this > series. > > Regards, > Boqun > > > > > I am not seeing a sync there, but I really have to defer to the > > maintainers on this one. I could easily have missed one. > > > > Thanx, Paul > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-10-21 21:50 +0200 |
| Message-ID | <qm7yy-4s1-9@gated-at.bofh.it> |
| In reply to | #1253152 |
On Wed, Oct 21, 2015 at 12:35:23PM -0700, Paul E. McKenney wrote: > > > > > I ask this because I recall Peter once bought up a discussion: > > > > > > > > > > https://lkml.org/lkml/2015/8/26/596 > > So a full barrier on one side of these operations is enough, I think. > > IOW, there is no need to strengthen these operations. > > Do we need to also worry about other futex use cases? Worry, always! But yes, there is one more specific usecase, which is that of a condition variable. When we go sleep on a futex, we might want to assume visibility of the stores done by the thread that woke us by the time we wake up. And.. aside from the thoughts I outlined in the email referenced above, there is always the chance people accidentally rely on the strong ordering on their x86 CPU and find things come apart when ran on their ARM/MIPS/etc.. There are a fair number of people who use the raw futex call and we have 0 visibility into many of them. The assumed and accidental ordering guarantees will forever remain a mystery. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2015-10-22 14:10 +0200 |
| Message-ID | <qmmQV-1Wt-9@gated-at.bofh.it> |
| In reply to | #1253158 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Oct 21, 2015 at 09:48:25PM +0200, Peter Zijlstra wrote: > On Wed, Oct 21, 2015 at 12:35:23PM -0700, Paul E. McKenney wrote: > > > > > > I ask this because I recall Peter once bought up a discussion: > > > > > > > > > > > > https://lkml.org/lkml/2015/8/26/596 > > > > So a full barrier on one side of these operations is enough, I think. > > > IOW, there is no need to strengthen these operations. > > > > Do we need to also worry about other futex use cases? > > Worry, always! > > But yes, there is one more specific usecase, which is that of a > condition variable. > > When we go sleep on a futex, we might want to assume visibility of the > stores done by the thread that woke us by the time we wake up. > But the thing is futex atomics in PPC are already RELEASE(pc)+ACQUIRE and imply a full barrier, is an RELEASE(sc) semantics really needed here? Further more, is this condition variable visibility guaranteed by other part of futex? Because in futex_wake_op: futex_wake_op() ... double_unlock_hb(hb1, hb2); <- RELEASE(pc) barrier here. wake_up_q(&wake_q); and in futex_wait(): futex_wait() ... futex_wait_queue_me(hb, &q, to); <- schedule() here ... unqueue_me(&q) drop_futex_key_refs(&q->key); iput()/mmdrop(); <- a full barrier The RELEASE(pc) barrier pairs with the full barrier, therefore the userspace wakee can observe the condition variable modification. > > > And.. aside from the thoughts I outlined in the email referenced above, > there is always the chance people accidentally rely on the strong > ordering on their x86 CPU and find things come apart when ran on their > ARM/MIPS/etc.. > > There are a fair number of people who use the raw futex call and we have > 0 visibility into many of them. The assumed and accidental ordering > guarantees will forever remain a mystery. > Understood. That's truely a potential problem. Considering not all the architectures imply a full barrier at user<->kernel boundries, maybe we can use one bit in the opcode of the futex system call to indicate whether userspace treats futex as fully ordered. Like: #define FUTEX_ORDER_SEQ_CST 0 #define FUTEX_ORDER_RELAXED 64 (bit 7 and bit 8 are already used) Therefore all existing code will run with a strong ordering version of futex(of course, we need to check and modify kernel code first to guarantee that), and if userspace code uses FUTEX_ORDER_RELAXED, it must not rely on futex() for the strong ordering, and should add memory barriers itself if necessary. Regards, Boqun
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-10-24 12:30 +0200 |
| Message-ID | <qn4ff-5UT-1@gated-at.bofh.it> |
| In reply to | #1253736 |
On Thu, Oct 22, 2015 at 08:07:16PM +0800, Boqun Feng wrote: > On Wed, Oct 21, 2015 at 09:48:25PM +0200, Peter Zijlstra wrote: > > On Wed, Oct 21, 2015 at 12:35:23PM -0700, Paul E. McKenney wrote: > > > > > > > I ask this because I recall Peter once bought up a discussion: > > > > > > > > > > > > > > https://lkml.org/lkml/2015/8/26/596 > > > > > > So a full barrier on one side of these operations is enough, I think. > > > > IOW, there is no need to strengthen these operations. > > > > > > Do we need to also worry about other futex use cases? > > > > Worry, always! > > > > But yes, there is one more specific usecase, which is that of a > > condition variable. > > > > When we go sleep on a futex, we might want to assume visibility of the > > stores done by the thread that woke us by the time we wake up. > > > > But the thing is futex atomics in PPC are already RELEASE(pc)+ACQUIRE > and imply a full barrier, is an RELEASE(sc) semantics really needed > here? For this, no, the current code should be fine I think. > Further more, is this condition variable visibility guaranteed by other > part of futex? Because in futex_wake_op: > > futex_wake_op() > ... > double_unlock_hb(hb1, hb2); <- RELEASE(pc) barrier here. > wake_up_q(&wake_q); > > and in futex_wait(): > > futex_wait() > ... > futex_wait_queue_me(hb, &q, to); <- schedule() here > ... > unqueue_me(&q) > drop_futex_key_refs(&q->key); > iput()/mmdrop(); <- a full barrier > > > The RELEASE(pc) barrier pairs with the full barrier, therefore the > userspace wakee can observe the condition variable modification. Right, futexes are a pain; and I think we all agreed we didn't want to go rely on implementation details unless we absolutely _have_ to. > > And.. aside from the thoughts I outlined in the email referenced above, > > there is always the chance people accidentally rely on the strong > > ordering on their x86 CPU and find things come apart when ran on their > > ARM/MIPS/etc.. > > > > There are a fair number of people who use the raw futex call and we have > > 0 visibility into many of them. The assumed and accidental ordering > > guarantees will forever remain a mystery. > > > > Understood. That's truely a potential problem. Considering not all the > architectures imply a full barrier at user<->kernel boundries, maybe we > can use one bit in the opcode of the futex system call to indicate > whether userspace treats futex as fully ordered. Like: > > #define FUTEX_ORDER_SEQ_CST 0 > #define FUTEX_ORDER_RELAXED 64 (bit 7 and bit 8 are already used) Not unless there's an actual performance problem with any of this. Futexes are painful enough as is. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2015-10-24 14:00 +0200 |
| Message-ID | <qn5El-7Qy-7@gated-at.bofh.it> |
| In reply to | #1255155 |
[Multipart message — attachments visible in raw view] — view raw
On Sat, Oct 24, 2015 at 12:26:27PM +0200, Peter Zijlstra wrote: > On Thu, Oct 22, 2015 at 08:07:16PM +0800, Boqun Feng wrote: > > On Wed, Oct 21, 2015 at 09:48:25PM +0200, Peter Zijlstra wrote: > > > On Wed, Oct 21, 2015 at 12:35:23PM -0700, Paul E. McKenney wrote: > > > > > > > > I ask this because I recall Peter once bought up a discussion: > > > > > > > > > > > > > > > > https://lkml.org/lkml/2015/8/26/596 > > > > > > > > So a full barrier on one side of these operations is enough, I think. > > > > > IOW, there is no need to strengthen these operations. > > > > > > > > Do we need to also worry about other futex use cases? > > > > > > Worry, always! > > > > > > But yes, there is one more specific usecase, which is that of a > > > condition variable. > > > > > > When we go sleep on a futex, we might want to assume visibility of the > > > stores done by the thread that woke us by the time we wake up. > > > > > > > But the thing is futex atomics in PPC are already RELEASE(pc)+ACQUIRE > > and imply a full barrier, is an RELEASE(sc) semantics really needed > > here? > > For this, no, the current code should be fine I think. > > > Further more, is this condition variable visibility guaranteed by other > > part of futex? Because in futex_wake_op: > > > > futex_wake_op() > > ... > > double_unlock_hb(hb1, hb2); <- RELEASE(pc) barrier here. > > wake_up_q(&wake_q); > > > > and in futex_wait(): > > > > futex_wait() > > ... > > futex_wait_queue_me(hb, &q, to); <- schedule() here > > ... > > unqueue_me(&q) > > drop_futex_key_refs(&q->key); > > iput()/mmdrop(); <- a full barrier > > > > > > The RELEASE(pc) barrier pairs with the full barrier, therefore the > > userspace wakee can observe the condition variable modification. > > Right, futexes are a pain; and I think we all agreed we didn't want to > go rely on implementation details unless we absolutely _have_ to. > Agreed. Besides, after I have read why futex_wake_op(the caller of futex_atomic_op_inuser()) is introduced, I think your worries are quite reasonable. I thought the futex_atomic_op_inuser() only operated on futex related variables, but it turns out it can actually operate any userspace variable if userspace code likes, therefore we don't have control of all memory ordering guarantee of the variable. So if PPC doesn't provide a full barrier at user<->kernel boundries, we should make futex_atomic_op_inuser() fully ordered. Still looking into futex_atomic_cmpxchg_inatomic() ... > > > And.. aside from the thoughts I outlined in the email referenced above, > > > there is always the chance people accidentally rely on the strong > > > ordering on their x86 CPU and find things come apart when ran on their > > > ARM/MIPS/etc.. > > > > > > There are a fair number of people who use the raw futex call and we have > > > 0 visibility into many of them. The assumed and accidental ordering > > > guarantees will forever remain a mystery. > > > > > > > Understood. That's truely a potential problem. Considering not all the > > architectures imply a full barrier at user<->kernel boundries, maybe we > > can use one bit in the opcode of the futex system call to indicate > > whether userspace treats futex as fully ordered. Like: > > > > #define FUTEX_ORDER_SEQ_CST 0 > > #define FUTEX_ORDER_RELAXED 64 (bit 7 and bit 8 are already used) > > Not unless there's an actual performance problem with any of this. > Futexes are painful enough as is. Make sense, and we still have choices like modifying the userspace code if there is actually a performance problem ;-) Regards, Boqun
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2015-10-25 14:20 +0100 |
| Message-ID | <qntnj-3sA-11@gated-at.bofh.it> |
| In reply to | #1255170 |
[Multipart message — attachments visible in raw view] — view raw
On Sat, Oct 24, 2015 at 07:53:56PM +0800, Boqun Feng wrote: > On Sat, Oct 24, 2015 at 12:26:27PM +0200, Peter Zijlstra wrote: > > > > Right, futexes are a pain; and I think we all agreed we didn't want to > > go rely on implementation details unless we absolutely _have_ to. > > > > Agreed. > > Besides, after I have read why futex_wake_op(the caller of > futex_atomic_op_inuser()) is introduced, I think your worries are quite > reasonable. I thought the futex_atomic_op_inuser() only operated on > futex related variables, but it turns out it can actually operate any > userspace variable if userspace code likes, therefore we don't have > control of all memory ordering guarantee of the variable. So if PPC > doesn't provide a full barrier at user<->kernel boundries, we should > make futex_atomic_op_inuser() fully ordered. > > > Still looking into futex_atomic_cmpxchg_inatomic() ... > I thought that the futex related variables (userspace variables that the first parameter of futex system call points to) are only accessed by futex system call in userspace, but it turns out not the fact. So memordy ordering guarantees of these variables are also out of the control of kernel. Therefore we should make futex_atomic_cmpxchg_inatomic() fully ordered, of course, if PPC doesn't provide a full barrier at user<->kernel boundries.. Regards Boqun
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web