public inbox for [email protected]
 help / color / mirror / Atom feed
From: Bart Van Assche <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected], Bart Van Assche <[email protected]>
Subject: [PATCH liburing 3/3] Convert __io_uring_get_sqe() from a macro into an inline function
Date: Sun, 21 Jun 2020 13:36:46 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

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 <[email protected]>
---
 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()

  parent reply	other threads:[~2020-06-21 20:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-21 20:36 [PATCH liburing 0/3] Three small liburing patches Bart Van Assche
2020-06-21 20:36 ` [PATCH liburing 1/3] Makefiles: Enable -Wextra Bart Van Assche
2020-06-21 20:36 ` [PATCH liburing 2/3] src/include/liburing/barrier.h: Use C11 atomics Bart Van Assche
2020-06-21 20:36 ` Bart Van Assche [this message]
2020-06-22  2:50 ` [PATCH liburing 0/3] Three small liburing patches Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox