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>
Thu, 21 Jul 2022 14:44:29 +0000 (08:44 -0600)
commit3805a7e49eea4d24fb3ff11756dc09767fa441af
treee6ecd516cebb9c2a8a200eb5c4f01bbc6df1f4d7
parent93996d971371443fe2d69b3ce84fe10b5e9052bd
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