diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-06-14 23:37:23 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-06-15 15:38:39 -0600 |
commit | 17d3aeb33cdae8c87a8ad97c4358a623a630e19a (patch) | |
tree | a3a6442d90792fbf17ec5f408b29e477387a55f4 /fs/io_uring.c | |
parent | 7f1129d227ea54526380d0f37eb7b33ab9f200c1 (diff) | |
download | lwn-17d3aeb33cdae8c87a8ad97c4358a623a630e19a.tar.gz lwn-17d3aeb33cdae8c87a8ad97c4358a623a630e19a.zip |
io_uring: refactor io_get_sqe()
The line of io_get_sqe() evaluating @head consists of too many
operations including READ_ONCE(), it's not convenient for probing.
Refactor it also improving readability.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/866ad6e4ef4851c7c61f6b0e08dbd0a8d1abce84.1623709150.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index a0720fb2565c..c74a84a2532b 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6685,8 +6685,8 @@ static void io_commit_sqring(struct io_ring_ctx *ctx) */ static const struct io_uring_sqe *io_get_sqe(struct io_ring_ctx *ctx) { - u32 *sq_array = ctx->sq_array; unsigned head, mask = ctx->sq_entries - 1; + unsigned sq_idx = ctx->cached_sq_head++ & mask; /* * The cached sq head (or cq tail) serves two purposes: @@ -6696,7 +6696,7 @@ static const struct io_uring_sqe *io_get_sqe(struct io_ring_ctx *ctx) * 2) allows the kernel side to track the head on its own, even * though the application is the one updating it. */ - head = READ_ONCE(sq_array[ctx->cached_sq_head++ & mask]); + head = READ_ONCE(ctx->sq_array[sq_idx]); if (likely(head < ctx->sq_entries)) return &ctx->sq_sqes[head]; |