Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: deduplicate wakeup handling

Both io_poll_wq_wake() and io_cqring_wake() contain the exact same code,
and most of the comment in the latter applies equally to both.

Move the test and wakeup handling into a basic helper that they can both
use, and move part of the comment that applies generically to this new
helper.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

Jens Axboe 8723c146 b1915b18

+16 -11
+16 -11
io_uring/io_uring.h
··· 294 294 smp_store_release(&ctx->rings->cq.tail, ctx->cached_cq_tail); 295 295 } 296 296 297 + static inline void __io_wq_wake(struct wait_queue_head *wq) 298 + { 299 + /* 300 + * 301 + * Pass in EPOLLIN|EPOLL_URING_WAKE as the poll wakeup key. The latter 302 + * set in the mask so that if we recurse back into our own poll 303 + * waitqueue handlers, we know we have a dependency between eventfd or 304 + * epoll and should terminate multishot poll at that point. 305 + */ 306 + if (wq_has_sleeper(wq)) 307 + __wake_up(wq, TASK_NORMAL, 0, poll_to_key(EPOLL_URING_WAKE | EPOLLIN)); 308 + } 309 + 297 310 static inline void io_poll_wq_wake(struct io_ring_ctx *ctx) 298 311 { 299 - if (wq_has_sleeper(&ctx->poll_wq)) 300 - __wake_up(&ctx->poll_wq, TASK_NORMAL, 0, 301 - poll_to_key(EPOLL_URING_WAKE | EPOLLIN)); 312 + __io_wq_wake(&ctx->poll_wq); 302 313 } 303 314 304 315 static inline void io_cqring_wake(struct io_ring_ctx *ctx) ··· 318 307 * Trigger waitqueue handler on all waiters on our waitqueue. This 319 308 * won't necessarily wake up all the tasks, io_should_wake() will make 320 309 * that decision. 321 - * 322 - * Pass in EPOLLIN|EPOLL_URING_WAKE as the poll wakeup key. The latter 323 - * set in the mask so that if we recurse back into our own poll 324 - * waitqueue handlers, we know we have a dependency between eventfd or 325 - * epoll and should terminate multishot poll at that point. 326 310 */ 327 - if (wq_has_sleeper(&ctx->cq_wait)) 328 - __wake_up(&ctx->cq_wait, TASK_NORMAL, 0, 329 - poll_to_key(EPOLL_URING_WAKE | EPOLLIN)); 311 + 312 + __io_wq_wake(&ctx->cq_wait); 330 313 } 331 314 332 315 static inline bool io_sqring_full(struct io_ring_ctx *ctx)