This patch makes gcc 10 insert one additional assembly instruction in io_uring_get_sqe(), namely xor %r8d,%r8d. That shouldn't cause any slowdown since that instruction does not access memory: 0x0000000000000360 <+0>: mov (%rdi),%rax 0x0000000000000363 <+3>: xor %r8d,%r8d 0x0000000000000366 <+6>: mov (%rax),%ecx 0x0000000000000368 <+8>: mov 0x44(%rdi),%eax 0x000000000000036b <+11>: lea 0x1(%rax),%edx 0x000000000000036e <+14>: mov %edx,%esi 0x0000000000000370 <+16>: sub %ecx,%esi 0x0000000000000372 <+18>: mov 0x18(%rdi),%rcx 0x0000000000000376 <+22>: cmp (%rcx),%esi 0x0000000000000378 <+24>: ja 0x38e <io_uring_get_sqe+46> 0x000000000000037a <+26>: mov 0x10(%rdi),%rcx 0x000000000000037e <+30>: and (%rcx),%eax 0x0000000000000380 <+32>: mov %edx,0x44(%rdi) 0x0000000000000383 <+35>: shl $0x6,%rax 0x0000000000000387 <+39>: add 0x38(%rdi),%rax 0x000000000000038b <+43>: mov %rax,%r8 0x000000000000038e <+46>: mov %r8,%rax 0x0000000000000391 <+49>: retq Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- src/queue.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/queue.c b/src/queue.c index 3db52bd17b86..88e0294c19fb 100644 --- a/src/queue.c +++ b/src/queue.c @@ -273,16 +273,18 @@ int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr) return __io_uring_submit_and_wait(ring, wait_nr); } -#define __io_uring_get_sqe(sq, __head) ({ \ - unsigned __next = (sq)->sqe_tail + 1; \ - struct io_uring_sqe *__sqe = NULL; \ - \ - if (__next - __head <= *(sq)->kring_entries) { \ - __sqe = &(sq)->sqes[(sq)->sqe_tail & *(sq)->kring_mask];\ - (sq)->sqe_tail = __next; \ - } \ - __sqe; \ -}) +static inline struct io_uring_sqe * +__io_uring_get_sqe(struct io_uring_sq *sq, unsigned int __head) +{ + unsigned int __next = (sq)->sqe_tail + 1; + struct io_uring_sqe *__sqe = NULL; + + if (__next - __head <= *(sq)->kring_entries) { + __sqe = &(sq)->sqes[(sq)->sqe_tail & *(sq)->kring_mask]; + (sq)->sqe_tail = __next; + } + return __sqe; +} /* * Return an sqe to fill. Application must later call io_uring_submit()