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

Policy about optimization of atomics

2023-07-07 Thread Olivier Dion via Gcc
Hi, I would like to know what is the official stand of GCC on optimization of atomic builtins? More precisely, optimization of redundant memory fences. I am aware that Clang does some peephole optimization on redundant fences, but this seem to be limited to a single basic block and does not

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-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-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

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

2023-07-03 Thread Olivier Dion via Gcc
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 consistency model [0]. For example, fully-ordered atomic