]> git.ipfire.org Git - thirdparty/linux.git/commit - io_uring/io_uring.c
io_uring: introduce locking helpers for CQE posting
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 20 Jun 2022 00:25:56 +0000 (01:25 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 25 Jul 2022 00:39:14 +0000 (18:39 -0600)
commit253993210bd8aa3b39a392807c03c8ef1cd7dc3d
tree09276f23754ea44fd9e7e46e9921c86ea8fb2482
parent305bef98870816ae58357d647521891ec558a92e
io_uring: introduce locking helpers for CQE posting

spin_lock(&ctx->completion_lock);
/* post CQEs */
io_commit_cqring(ctx);
spin_unlock(&ctx->completion_lock);
io_cqring_ev_posted(ctx);

We have many places repeating this sequence, and the three function
unlock section is not perfect from the maintainance perspective and also
makes it harder to add new locking/sync trick.

Introduce two helpers. io_cq_lock(), which is simple and only grabs
->completion_lock, and io_cq_unlock_post() encapsulating the three call
section.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/fe0c682bf7f7b55d9be55b0d034be9c1949277dc.1655684496.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c
io_uring/io_uring.h
io_uring/timeout.c