LWN: Comments on "The edge-triggered misunderstanding" https://lwn.net/Articles/864947/ This is a special feed containing comments posted to the individual LWN article titled "The edge-triggered misunderstanding". en-us Sun, 19 Oct 2025 11:26:13 +0000 Sun, 19 Oct 2025 11:26:13 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net The edge-triggered misunderstanding https://lwn.net/Articles/866784/ https://lwn.net/Articles/866784/ mrugiero <div class="FormattedComment"> <font class="QuotedText">&gt; Fix them? Why is that so hard to understand for some? Regressions are regressions. They have to be fixed if there are real programs used by real users (as in: anything that existed before introduction of regression and not made specifically to show-off that you can write superfragile code which may be broken by any unrelated change in the kernel).</font><br> <p> Except when two contradictory behaviors have been in the wild for a while, fixing the regression may be a regression itself. Only time will tell, but if/when it happens, which one will you pick? In that scenario someone will be broken in userspace, inevitably. The wording in what you quoted wasn&#x27;t necessarily the best, but this is the real issue. In fact, the current regression is a bugfix, if we believe the docs, regardless of the &quot;not breaking userspace rule&quot;, an implementation contradicting the documented promise is a bug.<br> </div> Thu, 19 Aug 2021 14:45:55 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/866720/ https://lwn.net/Articles/866720/ njs <div class="FormattedComment"> <font class="QuotedText">&gt; FWIW, EPOLLONESHOT is not really relevant for most applications [...] I believe the original use-case was a socket where you only wanted to connect() and see whether there was anything at all on the given port (some P2P server needed it).</font><br> <p> It&#x27;s also useful for working around epoll&#x27;s weird ambiguities between file descriptors/file descriptions -- if you get into the situation where your fd table and epoll&#x27;s fd table don&#x27;t match up, then EPOLLONESHOT is the only way to escape infinite wakeup loops:<br> <p> <a rel="nofollow" href="https://github.com/python-trio/trio/blob/cb48b33a42b09dde955617f93923ed8f5fa02426/trio/_core/_io_epoll.py#L106">https://github.com/python-trio/trio/blob/cb48b33a42b09dde...</a><br> <p> Of course correct code should never hit this case in the first place, but for generic library code that wants to degrade gracefully it&#x27;s very useful.<br> <p> It also reduces syscalls if you&#x27;re using epoll to implement a higher-level API that&#x27;s built around issuing read/write operations (like you see with Go/io_uring/IOCP), rather than &quot;register an fd for repeated usage&quot;.<br> </div> Thu, 19 Aug 2021 07:31:00 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865881/ https://lwn.net/Articles/865881/ HenrikH <div class="FormattedComment"> Yes, that goes exactly into what I was saying. Re-arming it resets the disabled flag in the internal watchlist. That you have to do this with EPOLL_CTL_MOD and not EPOLL_CTL_ADD should already there tell you that EPOLLONESHOT does not call EPOLL_CTL_DEL automatically.<br> <p> So if you use this flag as a way to not have to call EPOLL_CTL_DEL then you have a memory leak (as well as an inefficient watchlist in epoll).<br> <p> Not really sure where you are going with this since non of this contradicts what I have written now several times.<br> </div> Tue, 10 Aug 2021 16:50:16 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865800/ https://lwn.net/Articles/865800/ wtarreau <div class="FormattedComment"> <font class="QuotedText">&gt; EPOLLONESHOT does not call EPOLL_CTL_DEL automatically for you, it simply marks the fd on the watch list as temporarily disabled after it wakes up.</font><br> <p> From the epoll(7) man page: &quot;When the EPOLLONESHOT flag is specified, it is the caller&#x27;s responsibility to rearm the file descriptor using epoll_ctl(2) with EPOLL_CTL_MOD&quot;.<br> <p> You can use it for example to wait for a connect() to complete without having to disable polling on the FD when you don&#x27;t intend to use the connection immediately (e.g. when preparing connection pools).<br> <p> </div> Tue, 10 Aug 2021 04:08:48 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865793/ https://lwn.net/Articles/865793/ HenrikH <div class="FormattedComment"> If you use it that way they you are leaving behind a larger and larger watch list for epoll. EPOLLONESHOT does not call EPOLL_CTL_DEL automatically for you, it simply marks the fd on the watch list as temporarily disabled after it wakes up.<br> <p> It can be used for the scenario that you described but you have to do a manual call to EPOLL_CTL_DEL to really remove the fd from the internal watchlist and remove a potential memory leak.<br> <p> </div> Tue, 10 Aug 2021 02:13:31 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865750/ https://lwn.net/Articles/865750/ itsmycpu <div class="FormattedComment"> <font class="QuotedText">&gt; I do remember some old docs back in the 2.5.x days where it was clearly stated that you *had* to maintain your own event cache so that if you can&#x27;t read till EAGAIN you need to know by yourself that you have to try again once possible.</font><br> <p> With edge-triggered, that is still true, since there won&#x27;t necessarily be another write (or not for a long time). So you&#x27;d need a timeout or something (in a single-threaded scenario) and maintain the info that you haven&#x27;t encountered EAGAIN yet (unless you will try to read anyway, for example in certain intervals).<br> <p> This makes sense if the fact that data did arrive, and the data itself, are handled at different times; for example if data is usually buffered for some time, but some other action is taken immediately.<br> </div> Mon, 09 Aug 2021 20:12:32 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865714/ https://lwn.net/Articles/865714/ wtarreau <div class="FormattedComment"> Not exactly, EPOLLONESHOT is different, it&#x27;s for when you&#x27;re waiting for a single event and do not want to remain subscribed after that. It performs the EPOLL_CTL_DEL automatically for you. A typical example is that you read a request from a client, you get all of it and are not interested in reading whatever happens after until you&#x27;re done processing it, because, maybe you&#x27;ve released the buffer and cannot allocate a new one in this case. Normally you would have to unregister the event. With EPOLLONESHOT you don&#x27;t need, you&#x27;ll get notified exactly once and you will have to subscribe again if needed.<br> <p> The problem with pollers is that many users tend to consider them as providing exact guarantees, but they should not, instead a poller must be used as a hint that something happend on an FD, and the reported flags provide more or less accurate indications of the details. For example:<br> - the poller returns EPOLLIN but when you try to read you get EAGAIN. Why ? Because you&#x27;re on UDP, the checksum was calculated on the fly during recvmsg(), which figured it was incorrect and destroyed the result.<br> - the poller returns the same event multiple times regardless of EPOLLET: there might be different conditions whose precedence cause it to be reported.<br> - you&#x27;ve read all the response from an FD, not reached EAGAIN, but you&#x27;re certain based on the sockets you&#x27;re using that you&#x27;ve reached the end. Usually you can consider that you&#x27;ll be called again but there&#x27;s no such guarantee<br> - EPOLLHUP and EPOLLRDHUP used to be wrong several times in the past<br> - epoll + splice() have done funny things at a time where splice() was quite bogus (before 2.6.25). For example splice() could report EAGAIN if the target was full, thus was not reading the input at all, yet this EAGAIN was irrelevant to the recv condition that was supposed to re-arm the poller.<br> <p> The sole purpose of a poller is &quot;only sleep if you&#x27;re absolutely certain you can sleep; in doubt, wake up and notify me&quot;. It&#x27;s not the poller&#x27;s job to be exact about all conditions, it&#x27;s the application&#x27;s. In doubt the poller must wake up. In some cases I&#x27;m pretty sure that even EPOLLET will wake up more often than needed and that must not be a problem for the application.<br> <p> </div> Mon, 09 Aug 2021 16:43:32 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865710/ https://lwn.net/Articles/865710/ wtarreau <div class="FormattedComment"> It&#x27;s &quot;suggested&quot; in that it&#x27;s an illustration of one way to do it. The crux of this is that you&#x27;re not guaranteed to be notified again until you reach EAGAIN which rearms the event. And that&#x27;s the normal way to deal with edge-triggered signals, it&#x27;s not specific to epoll. Simply see it as a test-and-set on whether or not this requires to be reported. That&#x27;s particularly efficient and does not guarantee that you will not get multiple notifications from other situations but it&#x27;s the right way to make sure events are not reported more often than needed.<br> <p> I do remember some old docs back in the 2.5.x days where it was clearly stated that you *had* to maintain your own event cache so that if you can&#x27;t read till EAGAIN you need to know by yourself that you have to try again once possible. And that&#x27;s how highly efficient I/Os are achieved anyway.<br> </div> Mon, 09 Aug 2021 16:31:47 +0000 TLS for private subdomains https://lwn.net/Articles/865653/ https://lwn.net/Articles/865653/ motiejus <div class="FormattedComment"> I thought you literally meant internal.example.com :)<br> </div> Mon, 09 Aug 2021 12:54:16 +0000 TLS for private subdomains https://lwn.net/Articles/865648/ https://lwn.net/Articles/865648/ james Assuming you own the parent domain, you use DNS verification. You would have to (temporarily) create a public TXT record in the parent domain's DNS, as specified by the certificate authority: for example, you could put a record for _acme-challenge.test.internal.example.com in the public example.com DNS. <p> This would (tend to) confirm that the subdomain exists, but if you want a "real" TLS certificate, the subdomain will be included in public Certificate Transparency logs. <p> You would not have to publish any A or AAAA records for the subdomain, nor would you have to make any computers on the subdomain available to the outside world. Mon, 09 Aug 2021 09:40:50 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865583/ https://lwn.net/Articles/865583/ motiejus <div class="FormattedComment"> How can I get a real tls cert for a subdomain.exame.com? I did a bit of searching, to no avail.<br> </div> Sun, 08 Aug 2021 04:13:58 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865542/ https://lwn.net/Articles/865542/ jonas.bonn <div class="FormattedComment"> The true benefit of edge notifications is for _writeability_ notifications. It allows to forego the enable/disable EPOLLWR dance every time a message is enqueued and thus saves a large number of syscalls.<br> </div> Sat, 07 Aug 2021 06:31:51 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865535/ https://lwn.net/Articles/865535/ NYKevin <div class="FormattedComment"> As mentioned upthread, it is completely safe to use fake subdomains of home.arpa, because it was explicitly reserved for this purpose (RFC 8375). Of course, they can still leak, but if you&#x27;re running a local recursive resolver, you can at least configure it to avoid routing home.arpa queries outside of your homenet (because they will never be valid in the global DNS). So in principle, you can prevent fake DNS queries from reaching the external world, if you really want to. It&#x27;s just a lot of work for questionable benefit, IMHO.<br> <p> Technically, RFC 8375 positions itself as a &quot;correction&quot; to RFC 7788, but it also acknowledges that you don&#x27;t have to be doing HNCP to use home.arpa. Which is a Good Thing, because I still can&#x27;t figure out if HNCP is even a real protocol, or just a stack of &quot;wouldn&#x27;t it be nice if consumer products did [X]&quot; ideas wearing a trenchcoat.<br> </div> Sat, 07 Aug 2021 04:55:23 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865533/ https://lwn.net/Articles/865533/ HenrikH <div class="FormattedComment"> Well the manpage should perhaps made a bit clear because the behaviour is specifically like the one I&#x27;ve described. I just made a test of this using pipes on a 5.11 kernel, strace: (* lines from a different pid)<br> <p> * write(4, &quot;6\334\177&quot;, 3) = 3<br> epoll_create1(EPOLL_CLOEXEC) = 5<br> epoll_ctl(5, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLONESHOT|EPOLLET, {u32=3, u64=2581266273925070851}}) = 0<br> epoll_wait(5, [{EPOLLIN, {u32=3, u64=2581266273925070851}}], 1, -1) = 1<br> read(3, &quot;6\334\177&quot;, 3) = 3<br> * write(4, &quot;6\334\177&quot;, 3) = 3<br> clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=10, tv_nsec=0}, 0x7fff71722d70) = 0<br> epoll_ctl(5, EPOLL_CTL_MOD, 3, {EPOLLIN|EPOLLONESHOT|EPOLLET, {u32=3, u64=2581266273925070851}}) = 0<br> epoll_wait(5, [{EPOLLIN, {u32=3, u64=2581266273925070851}}], 1, -1) = 1<br> read(3, &quot;6\334\177&quot;, 3) = 3<br> <p> </div> Sat, 07 Aug 2021 03:23:09 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865529/ https://lwn.net/Articles/865529/ HenrikH <div class="FormattedComment"> Ok so I&#x27;m trying to find the actual discussion on LKML that led to the flag but atleast the comment that Davide Libenzi have on the code is this:<br> <p> + * EPOLLONESHOT bit that disables the descriptor when an event is received,<br> + * until the next EPOLL_CTL_MOD will be issued.<br> <p> Note the &quot;when an even it received _until_&quot; so the event is put on hold until the fd is re-armed by a EPOLL_CTL_MOD.<br> </div> Sat, 07 Aug 2021 02:18:37 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865527/ https://lwn.net/Articles/865527/ HenrikH <div class="FormattedComment"> Yes it seems like Wikipedia mixed them up, he does speak about epoll in that video as if EPOLLONESHOT didn&#x27;t exist though which is why I was fooled, come to think of it I should have reacted to the date of 2015 since I&#x27;ve used the flag for many years before that :)<br> </div> Sat, 07 Aug 2021 02:07:36 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865522/ https://lwn.net/Articles/865522/ NYKevin <div class="FormattedComment"> Maybe the documentation is incomplete or misleading, but as it stands, the man page says you get a race condition. If this race condition does not in fact exist, then the man page should explicitly call that out, rather than tacitly assuming that we all watch random YouTube videos of BSD developers criticizing Linux.<br> </div> Fri, 06 Aug 2021 22:21:31 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865521/ https://lwn.net/Articles/865521/ mkerrisk <div class="FormattedComment"> <font class="QuotedText">&gt; It was introduced after Bryan Cantrill&#x27;s epoll-rant in 2015</font><br> <p> EPOLLONESHOT appeared in Linux 2.6.2, in 2004. I think you perhaps are thinking of EPOLLEXCLUSIVE.<br> </div> Fri, 06 Aug 2021 21:34:55 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865518/ https://lwn.net/Articles/865518/ HenrikH <div class="FormattedComment"> EPOLLONESHOT was introduced so that you could load balance reads over multiple threads, if this race that you talk about would exist then it would make the whole idea of the flag moot (and a lot of software out there completely broken). It was introduced after Bryan Cantrill&#x27;s epoll-rant in 2015 <a href="https://www.youtube.com/watch?v=l6XQUciI-Sc&amp;t=3420s">https://www.youtube.com/watch?v=l6XQUciI-Sc&amp;t=3420s</a> where he critiques that epoll cannot be used to load balance reads in multiple threads (among other things).<br> </div> Fri, 06 Aug 2021 21:17:43 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865508/ https://lwn.net/Articles/865508/ khim <font class="QuotedText">&gt; except that undocumented or explicitly internal bits are more of a "why are you fiddling around there?" than Linux</font> <p>Linux have <b>insane</b> number of unstable interfaces. And if changes to <b>these</b> break apps then no one would even think twice.</p> <p>But syscalls are sacred. <b>These</b> are fixed in case of regressions religiously. And that's certainly a good thing.</p> Fri, 06 Aug 2021 19:11:15 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865506/ https://lwn.net/Articles/865506/ khim <p>You are <b>almost</b> correct but devil is in details. Let me show you with a change in the quote:</p> <font class="QuotedText">&gt; In my current understanding of the kernel workflow, if the Android project uses kernel code from 1.5 years ago and releases it only now it should manage any <s>regressions</s> backporting by itself.</font> <p>And yes, sure. They will.</p> <font class="QuotedText">&gt; What can upstream do about bugs that are filed years after they are produced?</font> <p>Fix them? Why is that so hard to understand for some? Regressions are regressions. They have to be fixed if there are real programs used by real users (as in: anything that existed before introduction of regression and not made specifically to show-off that you can write superfragile code which may be broken by any unrelated change in the kernel).</p> <p>Remember <a href="https://lwn.net/Articles/494993/">that story with autofs</a>? Please pay close attention to that line: <i>automount program from the autofs-tools package, which is still in use on a great many systems, had run into this problem a number of years ago</i>.</p> <p>Yet it was fixed, because, you know, regressions are regressions.</p> <font class="QuotedText">&gt; For a downstream that is lagging behind, it is thus their responsibility to deal with this whole situation.</font> <p>Oh, sure. Of course. After regression is fixed in all supported kernels the job of Linus and kernel developers is done. Backporting these changes to older, already usupported, kernels is not their job.</p> <p>But it have to be fixed in Linus tree even if it was introduced 10 years ago.</p> <p>That's the rule and <b>that</b> is why linux is the most popular OS kernel (maybe by now more popular than all others combined on an MMU-equipped devices).</p> <p>And yes, sometimes it requires quite a dozy solutions to satisfy both apps and libraries developed before regression happened and after. I guess at some point it would just be impossible to support them all. But AFAIK this never happened till now (or, more likely, it happened, but nobody noticed: that old <a href="https://lkml.org/lkml/2010/11/19/359">if nobody notices, it's not broken</a> rule).</p> <font class="QuotedText">&gt; I am just a bystander dreamer, though, understanding that such a thing would be difficult to impose and the benefits might be questionable...</font> <p>Depends on who would you ask, obviously. Apple, Google, Microsoft would be delighted by such a decision. Maybe even <a href="https://en.wikipedia.org/wiki/Google_Fuchsia">Fuchsia</a> get a chance. But it's hard to see what this adoption of <a href="https://www.jwz.org/doc/cadt.html">CADT model</a> would bring to Linux.</p> Fri, 06 Aug 2021 19:07:40 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865504/ https://lwn.net/Articles/865504/ HenrikH <div class="FormattedComment"> And more importantly I think that it also means that there is no race condition between read returning EAGAIN and you re-arming the fd since epoll can mark the fd since it remains in the list.<br> </div> Fri, 06 Aug 2021 18:20:49 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865498/ https://lwn.net/Articles/865498/ comex <div class="FormattedComment"> At the time you call epoll_ctl to add or re-enable a fd, the kernel will always check whether the fd is already ready and queue an event for it if so. [1] To this extent, it acts &#x27;level-triggered&#x27; regardless of whether you request level-triggered or edge-triggered mode. So it should be safe to use epoll with EPOLLET plus EPOLLONESHOT, and always start by adding/enabling the FD, not calling read/write. Then once you receive an event, you call read/write, then re-arm with EPOLL_CTL_MOD. If another event comes between the read/write and the re-arm, you will still get notified.<br> <p> However, this does directly contradict the man page&#x27;s &quot;suggested way&quot; of using EPOLLET [2] which is to only use epoll after read/write return EAGAIN. And the behavior of checking for readiness at add/enable time doesn&#x27;t seem to be documented, so it&#x27;s hard to say if this is meant to be guaranteed.<br> <p> [1] <a href="https://stackoverflow.com/questions/12920243/if-a-file-is-readable-before-epoll-ctl-is-called-in-edge-triggered-mode-will-a">https://stackoverflow.com/questions/12920243/if-a-file-is...</a><br> <p> [2] <a href="https://man7.org/linux/man-pages/man7/epoll.7.html">https://man7.org/linux/man-pages/man7/epoll.7.html</a><br> </div> Fri, 06 Aug 2021 17:37:27 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865497/ https://lwn.net/Articles/865497/ NYKevin <div class="FormattedComment"> <font class="QuotedText">&gt; Well that depends on how EPOLLONESHOT is implemented in epoll when you rearm it, if epoll checks the state of the fd (aka if there is a buffer on EPOLLIN or if it can write on EPOLLOUT) then it can avoid a race condition here.</font><br> <p> That&#x27;s how EPOLLLT behaves. If you&#x27;re using EPOLLET, then you have explicitly asked for the opposite behavior (i.e. to only notify when the fd *changes states*). There is nothing in epoll(7) (or any of the other pages I looked at) which suggests that a &quot;disabled&quot; EPOLLONESHOT fd can still receive events, which are saved until the fd is re-armed. The implication is that the events are simply dropped.<br> </div> Fri, 06 Aug 2021 17:30:35 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865494/ https://lwn.net/Articles/865494/ comex <div class="FormattedComment"> That still takes the lock and walks the tree, but at least it doesn&#x27;t have to allocate a new `struct epitem` like EPOLL_CTL_ADD does.<br> </div> Fri, 06 Aug 2021 17:19:13 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865495/ https://lwn.net/Articles/865495/ mathstuf <div class="FormattedComment"> I should say that I&#x27;m not worried about leakage so much as squatting, so I wasn&#x27;t clear there. If someone knows I have a local DNS name of `git` or can guess my naming scheme for hosts…so be it.<br> <p> We just used to use a `foobar.com` for internal routing (related to our actual domain name, but not publicly registered) at $DAYJOB. &quot;Hilarity&quot; ensued when someone *did* register that name and we started getting hosts external to our network responding to our SSH queries. I presume they were watching dead DNS queries pile up and snatched it in the hopes to get something juicy.<br> </div> Fri, 06 Aug 2021 17:18:27 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865493/ https://lwn.net/Articles/865493/ HenrikH <div class="FormattedComment"> Checking the man page shows that re-arming the fd on EPOLLONESHOT is done via EPOLL_CTL_MOD and not EPOLL_CTL_ADD so the fd remains in the epoll internal list of descriptors.<br> </div> Fri, 06 Aug 2021 17:12:23 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865491/ https://lwn.net/Articles/865491/ HenrikH <div class="FormattedComment"> <font class="QuotedText">&gt;Regardless, the rules for EPOLLET are pretty clear: only EAGAIN will re-arm the notification</font><br> <p> Not really, and this is why EPOLLONESHOT was introduced. EPOLLET will re-arm when there is a new write (unless it was done on a pipe on v5-v15) so if you use the same epoll fd in multiple threads with EPOLLET then once thread A have called read and there is a new write, epoll will notify thread B about EPOLLIN on the same fd. EPOLLINESHOT is the only solution to solve this.<br> </div> Fri, 06 Aug 2021 17:05:17 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865489/ https://lwn.net/Articles/865489/ HenrikH <div class="FormattedComment"> Well that depends on how EPOLLONESHOT is implemented in epoll when you rearm it, if epoll checks the state of the fd (aka if there is a buffer on EPOLLIN or if it can write on EPOLLOUT) then it can avoid a race condition here. Also epoll could guess that if EPOLLONESHOT is used then the fd will be rearmed again so it could retain the fd in it&#x27;s internal list but only mark it as being temporarily disabled.<br> <p> I have not checked any of the kernel sources though so I don&#x27;t know if any of this is actually implemented, but it could be.<br> </div> Fri, 06 Aug 2021 16:55:11 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865481/ https://lwn.net/Articles/865481/ tialaramex <div class="FormattedComment"> <font class="QuotedText">&gt; IIRC, that is one of the reserved names as well that doesn&#x27;t route over the global DNS network.</font><br> <p> Somebody else already explained that in fact .internal is not reserved although there was effort in that direction. But I want to particularly respond to &quot;doesn&#x27;t route over the global DNS network&quot; because this is a grave misunderstanding of what&#x27;s going on.<br> <p> Your bogus names _will_ leak. If you&#x27;ve just made up bogus names for some service you would cheerfully have given a name in the public DNS that&#x27;s delegated to you then it&#x27;s no worse than before. But a LOT of people have this idea that their bogus names are &quot;not routed&quot; and so magically this is safer, the exact same mistake that happens for RFC 1918 addressing and with the same consequences.<br> <p> These bogus names aren&#x27;t special, nothing magically says &quot;Oh this name is a double-secret internal name, protect it&quot;, it just goes in the big pile of bogus names like all the others. Unsurprisingly bad guys are much more interested in what&#x27;s in that pile, although infrastructure researchers pick through it too.<br> <p> <font class="QuotedText">&gt; it just got too messy trying to sync up public DNS routing and internal routing with the same names</font><br> <p> But your eventual solution doesn&#x27;t sync up to public DNS either. So, just don&#x27;t do that. It makes plenty of sense that I have some.internal.tlrmx.org without there being any public DNS records for that name. But unlike hijacking a TLD I *can* add public DNS records later if I want to, because it&#x27;s in a namespace I actually control.<br> </div> Fri, 06 Aug 2021 16:14:00 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865477/ https://lwn.net/Articles/865477/ NYKevin <div class="FormattedComment"> <font class="QuotedText">&gt; Locking overhead and system call overhead, on the other hand, make this pattern probably best to avoid.</font><br> <p> But that applies just as well to EPOLLONESHOT! So what&#x27;s the point of it?<br> <p> The way I see it, either you can tolerate duplicate events, or you can&#x27;t. If you can&#x27;t, then you *must* do some sort of explicit syscall to tell the kernel when you&#x27;re done with a given event and that it is now safe to dispatch another event. But as I explained above, if you want to use EPOLLONESHOT and epoll_ctl(..., EPOLL_CTL_MOD, ...) for that purpose, then you have to call epoll_ctl either before or after the read/write, and both ways result in a race condition. So you just can&#x27;t use EPOLLONESHOT for that purpose, and must instead use single-threaded EPOLLLT with explicit add/remove. There&#x27;s no other safe, duplicate-free way to use this API.<br> <p> OTOH, if you can tolerate duplicate notifications, then I don&#x27;t see the point of EPOLLONESHOT at all. Just use EPOLLLT (single-threaded) or EPOLLET (multi-threaded, but you somehow don&#x27;t care about the threads walking all over each other when the same fd gets signalled multiple times).<br> </div> Fri, 06 Aug 2021 15:37:32 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865475/ https://lwn.net/Articles/865475/ abatters <div class="FormattedComment"> Thanks for pointing that out; I hadn&#x27;t seen eventfd before.<br> </div> Fri, 06 Aug 2021 15:30:46 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865474/ https://lwn.net/Articles/865474/ itsmycpu <div class="FormattedComment"> <font class="QuotedText">&gt; It&#x27;s documented that way in the current version of the man page at least</font><br> <p> Yes, I just realized that and corrected myself in the post just (2 minutes) before yours. :)<br> </div> Fri, 06 Aug 2021 14:49:42 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865472/ https://lwn.net/Articles/865472/ intgr <div class="FormattedComment"> <font class="QuotedText">&gt; Are you suggesting that edge-triggered will not wake more than one thread?</font><br> <font class="QuotedText">&gt; it doesn&#x27;t seem documented in that way</font><br> <p> It&#x27;s documented that way in the current version of the man page at least<br> <a href="https://manpages.debian.org/testing/manpages/epoll.7.en.html">https://manpages.debian.org/testing/manpages/epoll.7.en.html</a><br> <p> <font class="QuotedText">&gt; If multiple threads (or processes, if child processes have</font><br> <font class="QuotedText">&gt; inherited the epoll file descriptor across fork(2)) are blocked</font><br> <font class="QuotedText">&gt; in epoll_wait(2) waiting on the same epoll file descriptor and a</font><br> <font class="QuotedText">&gt; file descriptor in the interest list that is marked for edge-</font><br> <font class="QuotedText">&gt; triggered (EPOLLET) notification becomes ready, just one of the</font><br> <font class="QuotedText">&gt; threads (or processes) is awoken from epoll_wait(2). This</font><br> <font class="QuotedText">&gt; provides a useful optimization for avoiding &quot;thundering herd&quot;</font><br> <font class="QuotedText">&gt; wake-ups in some scenarios.</font><br> <p> </div> Fri, 06 Aug 2021 14:42:55 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865471/ https://lwn.net/Articles/865471/ itsmycpu <div class="FormattedComment"> <font class="QuotedText">&gt; Are you suggesting that edge-triggered will not wake more than one thread? I can see why you might interpret the comment further above in that way,</font><br> <font class="QuotedText">&gt; but it doesn&#x27;t seem documented in that way, [...]</font><br> <p> Sorry once more, I was too quick. This is actually described by the epoll man page as a special case, at the end:<br> <p> <font class="QuotedText">&gt; If multiple threads (or processes, if child processes have</font><br> <font class="QuotedText">&gt; inherited the epoll file descriptor across fork(2)) are blocked</font><br> <font class="QuotedText">&gt; in epoll_wait(2) waiting on the same epoll file descriptor and a</font><br> <font class="QuotedText">&gt; file descriptor in the interest list that is marked for edge-</font><br> <font class="QuotedText">&gt; triggered (EPOLLET) notification becomes ready, just one of the</font><br> <font class="QuotedText">&gt; threads (or processes) is awoken from epoll_wait(2).</font><br> <p> This behavior seems to apply only in that special case, like an additional option. It is not the general meaning of &quot;edge-triggered&quot;. However certainly an interesting feature. I would hope that it generally applies when multiple threads use the same epoll file descriptor from the same epoll_create, so that it is not limited to forks.<br> </div> Fri, 06 Aug 2021 14:40:05 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865473/ https://lwn.net/Articles/865473/ Sesse <div class="FormattedComment"> Isn&#x27;t that what eventfd is for? It sounds more idiomatic than modifying the epoll set from another thread (which is what you&#x27;re doing, right?).<br> </div> Fri, 06 Aug 2021 14:37:08 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865468/ https://lwn.net/Articles/865468/ itsmycpu <div class="FormattedComment"> <font class="QuotedText">&gt; With level-triggered behavior, all events would be dispatched to all threads. Edge-triggered instead behaves as if the event is &quot;consumed&quot; after dispatching.</font><br> <p> I missed that this is still part of the reply to my post, so I&#x27;m sorry for splitting my response and not responding to the intended meaning at first.<br> <p> Are you suggesting that edge-triggered will not wake more than one thread? I can see why you might interpret the comment further above in that way,<br> but it doesn&#x27;t seem documented in that way, and I also haven&#x27;t noticed any indication in that direction anywhere else. I am not convinced it is actually so, as I would expect that to be a separate option, if it really were an option. (Though perhaps a useful one.)<br> <p> </div> Fri, 06 Aug 2021 14:18:18 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865469/ https://lwn.net/Articles/865469/ abatters <div class="FormattedComment"> <font class="QuotedText">&gt; FWIW, EPOLLONESHOT is not really relevant for most applications, and doesn&#x27;t have a lot to do with edge-triggering. I believe the original use-case was a socket where you only wanted to connect() and see whether there was anything at all on the given port (some P2P server needed it).</font><br> <p> I use EPOLLOUT | EPOLLONESHOT on a dummy fd that is always ready as a generic way for another thread to wakeup epoll_wait without using signals. Another way would be to write data to a pipe and then read it out after it woke up the epoll_wait, but that would require more syscalls.<br> </div> Fri, 06 Aug 2021 14:05:45 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865466/ https://lwn.net/Articles/865466/ itsmycpu <div class="FormattedComment"> <font class="QuotedText">&gt; Regardless, the rules for EPOLLET are pretty clear: only EAGAIN will re-arm the notification, ...</font><br> <p> How would that be clear as a &quot;rule&quot;? In the man page linked in the article, which is also referenced up thread, it is just a &quot;suggested way of use&quot;:<br> <p> <font class="QuotedText">&gt; The suggested way to use epoll as an edge-triggered (EPOLLET) interface is as follows:</font><br> <font class="QuotedText">&gt;</font><br> <font class="QuotedText">&gt; a) with nonblocking file descriptors; and</font><br> <font class="QuotedText">&gt;</font><br> <font class="QuotedText">&gt; b) by waiting for an event only after read(2) or write(2) return EAGAIN.</font><br> <p> However, the best I can tell, if used in this way, &#x27;level-triggered&#x27; would accomplish the same thing, and using &#x27;edge-triggered&#x27; in this scenario seems redundant and pointless.<br> <p> It does not say there that EAGAIN is necessary to &quot;re-arm&quot; the notification. Later on, it just says that reading until EAGAIN is necessary to make sure that all the data is read, however that is quite obvious anyway. And nothing else is implied by the example above.<br> <p> </div> Fri, 06 Aug 2021 13:45:19 +0000 The edge-triggered misunderstanding https://lwn.net/Articles/865467/ https://lwn.net/Articles/865467/ mathstuf <div class="FormattedComment"> Ah I missed that the `.internal` RFC was never adopted. I guess I&#x27;ll put migration to…something else on my list. Thanks.<br> </div> Fri, 06 Aug 2021 13:29:42 +0000