From: Eric Wong <sleepy-penguin@bogomips.org>
To: sleepy-penguin@bogomips.org
Subject: [PATCH] epoll: add EPOLLEXCLUSIVE constant and documentation
Date: Sat, 18 Mar 2017 00:56:37 +0000 [thread overview]
Message-ID: <20170318005637.10191-1-sleepy-penguin@bogomips.org> (raw)
I'm still not convinced this is necessary, but it's in Linux, now,
and maybe some folks will want it.
My position remains: Never put listen sockets in epoll if
you're using threads; instead, dedicate a thread to doing
nothing but _blocking_ accept4 + epoll_ctl(.. EPOLL_CTL_ADD).
Of course, if you're using something which does not have
native thread support but using multiple processes, then
yes, EPOLLEXCLUSIVE will prevent multiple processes from
turning into a thundering herd.
In other words: I would use this with Perl5, but not with Ruby 1.9+ :P
---
ext/sleepy_penguin/epoll.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c
index 8155c4a..09c4bf7 100644
--- a/ext/sleepy_penguin/epoll.c
+++ b/ext/sleepy_penguin/epoll.c
@@ -306,6 +306,17 @@ void sleepy_penguin_init_epoll(void)
rb_define_const(cEpoll, "WAKEUP", UINT2NUM(EPOLLWAKEUP));
#endif
+#ifdef EPOLLEXCLUSIVE
+ /*
+ * Sets an exclusive wakeup mode for the epoll object
+ * that is being attached to the target IO. This
+ * avoids thundering herd scenarios when the same
+ * target IO is shared among multiple epoll objects.
+ * Available since Linux 4.5
+ */
+ rb_define_const(cEpoll, "EXCLUSIVE", UINT2NUM(EPOLLEXCLUSIVE));
+#endif
+
/* watch for urgent read(2) data */
rb_define_const(cEpoll, "PRI", UINT2NUM(EPOLLPRI));
--
EW
reply other threads:[~2017-03-18 0:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/sleepy_penguin/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170318005637.10191-1-sleepy-penguin@bogomips.org \
--to=sleepy-penguin@bogomips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/sleepy_penguin.git/
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 read-only IMAP folder(s) and NNTP newsgroup(s).