io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior
PATCH 1/1 io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior
Applications can use this flag to avoid accept thundering herd.
--- fs/io_uring.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/io_uring.c +5 -2
@@ -4109,7 +4109,10 @@ 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,
@@ -4530,7 +4533,7 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqereturn -EBADF ; events =READ_ONCE (sqe->poll_events); - poll->events =demangle_poll (events) |EPOLLERR |EPOLLHUP ; + poll->events =demangle_poll (events) |EPOLLERR |EPOLLHUP |EPOLLEXCLUSIVE ;get_task_struct (current); req->task = current;
Signature · 1 line
1.8.3.1
Jens Axboe
maintainerQuoted 1 line · Jiufei Xue
Applications can use this flag to avoid accept thundering herd.
So with this, any IORING_OP_POLL_ADD will be exclusive. Seems to me that the other poll path we have could use it too by default, and at that point, we could clean this up (and improve) it further by including that?
Signature · 1 line
Jens Axboe
Quoted 8 lines · Jens Axboe
Quoted 1 line · Jiufei Xue
Applications can use this flag to avoid accept thundering herd.
So with this, any
IORING_OP_POLL_ADDwill be exclusive. Seems to me that the other poll path we have could use it too by default, and at that point, we could clean this up (and improve) it further by including that?
Sorry, I have sent the wrong patch. I think the flag should be determined by user, I will send the new version soon.
Thanks,
JIufei.
Jens Axboe
maintainerQuoted 6 lines · Jiufei Xue
Quoted 3 lines · Jens Axboe
Quoted 1 line · Jiufei Xue
Applications can use this flag to avoid accept thundering herd.
Quoted 7 lines
Quoted 5 lines
So with this, any
IORING_OP_POLL_ADDwill be exclusive. Seems to me that the other poll path we have could use it too by default, and at that point, we could clean this up (and improve) it further by including that?Sorry, I have sent the wrong patch. I think the flag should be determined by user, I will send the new version soon.
That's sort of what I assumed as well.
Signature · 1 line
Jens Axboe