io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior
@ 2020-06-10  6:15 Jiufei Xue
  2020-06-11  0:01 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Jiufei Xue @ 2020-06-10  6:15 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, joseph.qi

Applications can use this flag to avoid accept thundering herd.

Signed-off-by: Jiufei Xue <jiufei.xue@linux.alibaba.com>
---
 fs/io_uring.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index f668982..b8102b2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior
  2020-06-10  6:15 [PATCH] io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior Jiufei Xue
@ 2020-06-11  0:01 ` Jens Axboe
  2020-06-11  1:36   ` Jiufei Xue
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2020-06-11  0:01 UTC (permalink / raw)
  To: Jiufei Xue, io-uring; +Cc: joseph.qi

On 6/10/20 12:15 AM, Jiufei Xue wrote:
> 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?

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior
  2020-06-11  0:01 ` Jens Axboe
@ 2020-06-11  1:36   ` Jiufei Xue
  2020-06-11  1:40     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Jiufei Xue @ 2020-06-11  1:36 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: joseph.qi



On 2020/6/11 上午8:01, Jens Axboe wrote:
> On 6/10/20 12:15 AM, Jiufei Xue wrote:
>> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior
  2020-06-11  1:36   ` Jiufei Xue
@ 2020-06-11  1:40     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2020-06-11  1:40 UTC (permalink / raw)
  To: Jiufei Xue, io-uring; +Cc: joseph.qi

On 6/10/20 7:36 PM, Jiufei Xue wrote:
> 
> 
> On 2020/6/11 上午8:01, Jens Axboe wrote:
>> On 6/10/20 12:15 AM, Jiufei Xue wrote:
>>> 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.

That's sort of what I assumed as well.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-11  1:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10  6:15 [PATCH] io_uring: add EPOLLEXCLUSIVE flag to aoid thundering herd type behavior Jiufei Xue
2020-06-11  0:01 ` Jens Axboe
2020-06-11  1:36   ` Jiufei Xue
2020-06-11  1:40     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).