* [PATCH liburing] src/queue: refactor io_uring_get_sqe()
@ 2021-01-07 23:00 Pavel Begunkov
2021-01-07 23:13 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-01-07 23:00 UTC (permalink / raw)
To: Jens Axboe, io-uring
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH liburing] src/queue: refactor io_uring_get_sqe()
2021-01-07 23:00 [PATCH liburing] src/queue: refactor io_uring_get_sqe() Pavel Begunkov
@ 2021-01-07 23:13 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-01-07 23:13 UTC (permalink / raw)
To: Pavel Begunkov, io-uring
On 1/7/21 4:00 PM, Pavel Begunkov wrote:
> Inline __io_uring_get_sqe() and clean up ugly naming left from it being
> a macro at some point.
Looks good, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-07 23:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-07 23:00 [PATCH liburing] src/queue: refactor io_uring_get_sqe() Pavel Begunkov
2021-01-07 23:13 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox