diff options
author | Jiufei Xue <jiufei.xue@linux.alibaba.com> | 2020-06-17 17:53:56 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-06-21 20:44:00 -0600 |
commit | a31eb4a2f1650fa578082ad9e9845487ecd90abe (patch) | |
tree | 511b0626c1ee3acaabdd9306b880852e618991b5 /fs/io_uring.c | |
parent | 5769a351b89cd4d82016f18fa5f6c4077403564d (diff) | |
download | lwn-a31eb4a2f1650fa578082ad9e9845487ecd90abe.tar.gz lwn-a31eb4a2f1650fa578082ad9e9845487ecd90abe.zip |
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: Jiufei Xue <jiufei.xue@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 0eb063daa9b5..311e8038ae58 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4245,7 +4245,11 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt, pt->error = 0; poll->head = head; - add_wait_queue(head, &poll->wait); + + if (poll->events & EPOLLEXCLUSIVE) + add_wait_queue_exclusive(head, &poll->wait); + else + add_wait_queue(head, &poll->wait); } static void io_async_queue_proc(struct file *file, struct wait_queue_head *head, @@ -4602,7 +4606,8 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe #ifdef __BIG_ENDIAN events = swahw32(events); #endif - poll->events = demangle_poll(events) | EPOLLERR | EPOLLHUP; + poll->events = demangle_poll(events) | EPOLLERR | EPOLLHUP | + (events & EPOLLEXCLUSIVE); io_get_req_task(req); return 0; |