diff options
author | Jens Axboe <axboe@kernel.dk> | 2023-03-30 10:05:31 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-04-03 07:16:15 -0600 |
commit | e3ef728ff07b42668e7e12f49cd2f9055e064ec1 (patch) | |
tree | 4633f05db2a396a10a1d419af4fede57972f5a56 /io_uring/io_uring.h | |
parent | 2ad57931db641f3de627023afb8147a8ec0b41dc (diff) | |
download | lwn-e3ef728ff07b42668e7e12f49cd2f9055e064ec1.tar.gz lwn-e3ef728ff07b42668e7e12f49cd2f9055e064ec1.zip |
io_uring: cap io_sqring_entries() at SQ ring size
We already do this manually for the !SQPOLL case, do it in general and
we can also dump the ugly min3() in io_submit_sqes().
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/io_uring.h')
-rw-r--r-- | io_uring/io_uring.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index c33f719731ac..193b2db39fe8 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -262,9 +262,11 @@ static inline bool io_sqring_full(struct io_ring_ctx *ctx) static inline unsigned int io_sqring_entries(struct io_ring_ctx *ctx) { struct io_rings *rings = ctx->rings; + unsigned int entries; /* make sure SQ entry isn't read before tail */ - return smp_load_acquire(&rings->sq.tail) - ctx->cached_sq_head; + entries = smp_load_acquire(&rings->sq.tail) - ctx->cached_sq_head; + return min(entries, ctx->sq_entries); } static inline int io_run_task_work(void) |