From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing] src/queue: refactor io_uring_get_sqe()
Date: Thu, 7 Jan 2021 23:00:27 +0000 [thread overview]
Message-ID: <0d1447abc76a1664f663f019497dbcd8b92116e3.1610060400.git.asml.silence@gmail.com> (raw)
Inline __io_uring_get_sqe() and clean up ugly naming left from it being
a macro at some point.
Signed-off-by: Pavel Begunkov <[email protected]>
---
src/queue.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/src/queue.c b/src/queue.c
index 16bd86b..768e34f 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -371,19 +371,6 @@ int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr)
return __io_uring_submit_and_wait(ring, wait_nr);
}
-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()
* when it's ready to tell the kernel about it. The caller may call this
@@ -394,8 +381,15 @@ __io_uring_get_sqe(struct io_uring_sq *sq, unsigned int __head)
struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
{
struct io_uring_sq *sq = &ring->sq;
+ unsigned int head = io_uring_smp_load_acquire(sq->khead);
+ unsigned int next = sq->sqe_tail + 1;
+ struct io_uring_sqe *sqe = NULL;
- return __io_uring_get_sqe(sq, io_uring_smp_load_acquire(sq->khead));
+ if (next - head <= *sq->kring_entries) {
+ sqe = &sq->sqes[sq->sqe_tail & *sq->kring_mask];
+ sq->sqe_tail = next;
+ }
+ return sqe;
}
int __io_uring_sqring_wait(struct io_uring *ring)
--
2.24.0
next reply other threads:[~2021-01-07 23:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-07 23:00 Pavel Begunkov [this message]
2021-01-07 23:13 ` [PATCH liburing] src/queue: refactor io_uring_get_sqe() 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 \
--in-reply-to=0d1447abc76a1664f663f019497dbcd8b92116e3.1610060400.git.asml.silence@gmail.com \
[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