5.15 small improvements
cover 5.15 small improvements
Just two small patches following past and potential problems
Pavel Begunkov (2):
io_uring: clarify io_req_task_cancel() locking
io_uring: add build check for buf_index overflows
fs/io_uring.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/2 io_uring: clarify io_req_task_cancel() locking
It's too easy to forget and misjudge about synchronisation in io_req_task_cancel(), add a comment clarifying it.
--- fs/io_uring.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/io_uring.c +1 -2
@@ -2138,7 +2138,7 @@ static void io_req_task_cancel(struct io_kiocb *req, bool *locked) {struct io_ring_ctx *ctx = req->ctx; -/* ctx is guaranteed to stay alive while we hold uring_lock */ +/* not needed for normal modes, but SQPOLL depends on it */ io_tw_lock (ctx, locked);io_req_complete_failed (req, req->result); }
@@ -2147,7 +2147,6 @@ static void io_req_task_submit(struct io_kiocb *req, bool *locked) {struct io_ring_ctx *ctx = req->ctx; -/* ctx stays valid until unlock, even if we drop all ours ctx->refs */ io_tw_lock (ctx, locked);/* req->task == current here, checking PF_EXITING is safe */ if (likely (!(req->task->flags &PF_EXITING )))
Signature · 1 line
2.32.0
PATCH 2/2 io_uring: add build check for buf_index overflows
In reply to Pavel Begunkovreq->buf_index is u16 and so we rely on registered buffers indexes fitting into it. Add a build check, so when the upper limit for the number of buffers is lifted we get a compliation fail but not lurking problems.
--- fs/io_uring.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/io_uring.c +4 -0
@@ -10450,6 +10450,10 @@ static int __init io_uring_init(void) sizeof(struct io_uring_rsrc_update));BUILD_BUG_ON (sizeof (struct io_uring_rsrc_update ) >sizeof (struct io_uring_rsrc_update2 )); + +/* ->buf_index is u16 */ +BUILD_BUG_ON (IORING_MAX_REG_BUFFERS >= (1u <<16 )); +/* should fit into one byte */ BUILD_BUG_ON (SQE_VALID_FLAGS >= (1 <<8 ));
Signature · 1 line
2.32.0
Quoted 8 lines · Pavel Begunkov
Just two small patches following past and potential problems
Pavel Begunkov (2):
io_uring: clarifyio_req_task_cancel()locking
io_uring: add build check forbuf_indexoverflowsfs/io_uring.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Applied, thanks.
Signature · 1 line
Jens Axboe