Skip to contentSkip to conversation

io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior

PATCH Superseded Jiufei Xue 2 participants 4 messages Jun 10, 2020 – Jun 11, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jiufei Xue

author
#0 lore raw

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
index f668982..b8102b2 100644
@@ -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 *sqe
 		return -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
maintainer
#1 lore raw
Quoted 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
author
#2 lore raw
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_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?

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.

maintainer
#3 lore raw
Quoted 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_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?

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