Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-08-16 Thread Mathieu Desnoyers via Gcc
On 7/10/23 10:32, Jonas Oberhauser wrote: Am 7/7/2023 um 7:25 PM schrieb Olivier Dion: On Fri, 07 Jul 2023, Jonas Oberhauser wrote: [...] This is a request for comments on extending the atomic builtins API to help avoiding redundant memory barriers.  Indeed, there are discrepancies between

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-10 Thread Jonas Oberhauser
Am 7/7/2023 um 7:25 PM schrieb Olivier Dion: On Fri, 07 Jul 2023, Jonas Oberhauser wrote: [...] This is a request for comments on extending the atomic builtins API to help avoiding redundant memory barriers. Indeed, there are discrepancies between the Linux kernel consistency memory model

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-07 Thread Olivier Dion via Gcc
On Fri, 07 Jul 2023, Jonas Oberhauser wrote: [...] >> This is a request for comments on extending the atomic builtins API to >> help avoiding redundant memory barriers. Indeed, there are >> discrepancies between the Linux kernel consistency memory model (LKMM) >> and the C11/C++11 memory

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-07 Thread Peter Zijlstra
On Fri, Jul 07, 2023 at 10:04:06AM -0400, Olivier Dion wrote: > On Tue, 04 Jul 2023, Peter Zijlstra wrote: > > On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: > [...] > >> On x86-64 (gcc 13.1 -O2) we get: > >> > >> t0(): > >> movl$1, x(%rip) > >> movl

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-07 Thread Mathieu Desnoyers via Gcc
On 7/4/23 06:23, Jonathan Wakely wrote: On Tue, 4 Jul 2023 at 10:47, Peter Zijlstra wrote: On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: int x = 0; int y = 0; int r0, r1; int dummy; void t0(void) { __atomic_store_n(, 1, __ATOMIC_RELAXED);

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-07 Thread Olivier Dion via Gcc
On Tue, 04 Jul 2023, Peter Zijlstra wrote: > On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: [...] >> On x86-64 (gcc 13.1 -O2) we get: >> >> t0(): >> movl$1, x(%rip) >> movl$1, %eax >> xchgl dummy(%rip), %eax >> lock orq $0,

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-07 Thread Jonas Oberhauser
Hi all, Am 7/3/2023 um 9:20 PM schrieb Olivier Dion: Hi all, This is a request for comments on extending the atomic builtins API to help avoiding redundant memory barriers. Indeed, there are discrepancies between the Linux kernel consistency memory model (LKMM) and the C11/C++11 memory

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-06 Thread Olivier Dion via Gcc
On Tue, 04 Jul 2023, Alan Stern wrote: > On Tue, Jul 04, 2023 at 01:19:23PM -0400, Olivier Dion wrote: >> On Mon, 03 Jul 2023, Alan Stern wrote: >> > On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: [...] > Oh, is that it? Then I misunderstood entirely; I thought you were >

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-05 Thread Mathieu Desnoyers via Gcc
On 7/5/23 03:05, Boqun Feng wrote: On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: [...] NOTE: On x86-64, we found at least one corner case [7] with Clang where a RELEASE exchange is optimized to a RELEASE store, when the returned value of the exchange is unused, breaking the

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-05 Thread Boqun Feng via Gcc
On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: [...] > NOTE: On x86-64, we found at least one corner case [7] with Clang where > a RELEASE exchange is optimized to a RELEASE store, when the returned > value of the exchange is unused, breaking the above expectations. > Although this

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-04 Thread Paul E. McKenney via Gcc
On Tue, Jul 04, 2023 at 04:25:45PM -0400, Alan Stern wrote: > On Tue, Jul 04, 2023 at 01:19:23PM -0400, Olivier Dion wrote: [ . . . ] > > I am puzzled by this. Initialization of a shared variable does not need > > to be atomic until its publication. Could you expand on this? > > In the

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-04 Thread Alan Stern
On Tue, Jul 04, 2023 at 01:19:23PM -0400, Olivier Dion wrote: > On Mon, 03 Jul 2023, Alan Stern wrote: > > On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: > >> This is a request for comments on extending the atomic builtins API to > >> help avoiding redundant memory barriers.

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-04 Thread Olivier Dion via Gcc
On Mon, 03 Jul 2023, Alan Stern wrote: > On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: >> This is a request for comments on extending the atomic builtins API to >> help avoiding redundant memory barriers. Indeed, there are > > What atomic builtins API are you talking about? The

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-04 Thread Jonathan Wakely via Gcc
On Tue, 4 Jul 2023 at 10:47, Peter Zijlstra wrote: > > On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: > > > int x = 0; > > int y = 0; > > int r0, r1; > > > > int dummy; > > > > void t0(void) > > { > > __atomic_store_n(, 1, __ATOMIC_RELAXED); > > > >

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-04 Thread Peter Zijlstra
On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: > int x = 0; > int y = 0; > int r0, r1; > > int dummy; > > void t0(void) > { > __atomic_store_n(, 1, __ATOMIC_RELAXED); > > __atomic_exchange_n(, 1, __ATOMIC_SEQ_CST); >

Re: [RFC] Bridging the gap between the Linux Kernel Memory Consistency Model (LKMM) and C11/C++11 atomics

2023-07-03 Thread Alan Stern
On Mon, Jul 03, 2023 at 03:20:31PM -0400, Olivier Dion wrote: > Hi all, > > This is a request for comments on extending the atomic builtins API to > help avoiding redundant memory barriers. Indeed, there are What atomic builtins API are you talking about? The kernel's? That's what it sounded