src/include/liburing/barrier.h: Use C11 atomics
Instead of using a combination of open-coding atomic primitives and using
gcc builtins, use C11 atomics for all CPU architectures. Note: despite their
name, atomic_*() operations do not necessarily translate into an atomic
instruction. This patch changes the order of the instructions in e.g.
io_uring_get_sqe() but not the number of instructions generated by gcc 10
on x86_64:
Without this patch:
0x0000000000000360 <+0>: mov 0x44(%rdi),%eax
0x0000000000000363 <+3>: lea 0x1(%rax),%edx
0x0000000000000366 <+6>: mov (%rdi),%rax
0x0000000000000369 <+9>: mov (%rax),%eax
0x000000000000036b <+11>: mov 0x18(%rdi),%rcx
0x000000000000036f <+15>: mov %edx,%esi
0x0000000000000371 <+17>: sub %eax,%esi
0x0000000000000373 <+19>: xor %eax,%eax
0x0000000000000375 <+21>: cmp (%rcx),%esi
0x0000000000000377 <+23>: ja 0x38d <io_uring_get_sqe+45>
0x0000000000000379 <+25>: mov 0x10(%rdi),%rax
0x000000000000037d <+29>: mov (%rax),%eax
0x000000000000037f <+31>: and 0x44(%rdi),%eax
0x0000000000000382 <+34>: mov %edx,0x44(%rdi)
0x0000000000000385 <+37>: shl $0x6,%rax
0x0000000000000389 <+41>: add 0x38(%rdi),%rax
0x000000000000038d <+45>: retq
With this patch applied:
0x0000000000000360 <+0>: mov 0x44(%rdi),%eax
0x0000000000000363 <+3>: lea 0x1(%rax),%edx
0x0000000000000366 <+6>: mov (%rdi),%rax
0x0000000000000369 <+9>: mov %edx,%esi
0x000000000000036b <+11>: mov (%rax),%eax
0x000000000000036d <+13>: sub %eax,%esi
0x000000000000036f <+15>: xor %eax,%eax
0x0000000000000371 <+17>: mov 0x18(%rdi),%rcx
0x0000000000000375 <+21>: cmp (%rcx),%esi
0x0000000000000377 <+23>: ja 0x38d <io_uring_get_sqe+45>
0x0000000000000379 <+25>: mov 0x10(%rdi),%rax
0x000000000000037d <+29>: mov (%rax),%eax
0x000000000000037f <+31>: and 0x44(%rdi),%eax
0x0000000000000382 <+34>: mov %edx,0x44(%rdi)
0x0000000000000385 <+37>: shl $0x6,%rax
0x0000000000000389 <+41>: add 0x38(%rdi),%rax
0x000000000000038d <+45>: retq
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 file changed