Commit a31eb4a2 authored by Jiufei Xue's avatar Jiufei Xue Committed by Jens Axboe

io_uring: use EPOLLEXCLUSIVE flag to aoid thundering herd type behavior

Applications can pass this flag in to avoid accept thundering herd.
Signed-off-by: default avatarJiufei Xue <jiufei.xue@linux.alibaba.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 5769a351
...@@ -4245,6 +4245,10 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt, ...@@ -4245,6 +4245,10 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt,
pt->error = 0; pt->error = 0;
poll->head = head; poll->head = head;
if (poll->events & EPOLLEXCLUSIVE)
add_wait_queue_exclusive(head, &poll->wait);
else
add_wait_queue(head, &poll->wait); add_wait_queue(head, &poll->wait);
} }
...@@ -4602,7 +4606,8 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe ...@@ -4602,7 +4606,8 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
events = swahw32(events); events = swahw32(events);
#endif #endif
poll->events = demangle_poll(events) | EPOLLERR | EPOLLHUP; poll->events = demangle_poll(events) | EPOLLERR | EPOLLHUP |
(events & EPOLLEXCLUSIVE);
io_get_req_task(req); io_get_req_task(req);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment