On 11/23, Linus Torvalds wrote: > > On Sun, 22 Nov 2026 at 16:35, Mani Tofigh via B4 Relay > wrote: > > > > A task blocked in read() on an eventfd or timerfd can sleep forever > > while the file is readable, if an epoll(EPOLLEXCLUSIVE) watcher of the > > same file was added before it. > > Honestly, I don't think this is the right approach. > > We need to fix the disaster area that is epoll, rather than work around > more epoll bugs elsewhere and make other places more fragile and > complex. I agree. But to me it would be better to apply this patch from Mani, then do something else. Not because it "fixes" the scenario described in the changelog. As for eventfd_read(), it probably makes sense to change it to use wait_event_interruptible_exclusive_locked_irq() at least if !EFD_SEMAPHORE, and then we will have the same problem with EPOLLEXCLUSIVE again. But simply because do_wait_intr*() are wrong regardless, and the change is trivial. And perhaps the changelog should not mention EPOLLEXCLUSIVE at all. > And I think we should always add new waiters to the end of the queue, > and stop any other games. Just walk the whole queue at wakeup time. > > Finally, I think we should make the return value from the wakeup > function be a bitmask, and count "exclusive" as only "we haven't seen > this bit returned yet". And then *real* exclusive users that actually > guarantee that they react to the wakeup return all bits set, but the > sh*t-for-brains garbage that is "epoll" only returns its own bit set - > so we only wake up *one* epoll user, but we wake up other users anyway, > because epoll clearl yis lying about its "exclusivity". Perhaps... But it is not clear how to do this gradually... And lets forget about epoll for the moment. Lets suppose we change __wake_up_common() to do list_for_each_entry_safe(curr, next, &wq_head->head, entry) { bool excl = curr->flags & WQ_FLAG_EXCLUSIVE; int ret; if (excl && !nr_exclusive) continue; ret = curr->func(curr, mode, wake_flags, key); if (ret < 0) break; if (ret && excl) --nr_exclusive; } This will change the current behaviour if ret < 0. Say wake_page_function() does if (flags & WQ_FLAG_EXCLUSIVE) { if (test_bit(key->bit_nr, &key->folio->flags.f)) return -1; ... so this logic depends on wait-queue ordering too. "ret < 0" can be encoded in the bitmask, but it is not clear what exactly __wake_up_common() needs to do in this case. Can't we at least cleanup __wake_up_common() ? See the patch below, I already sent it but it was ignored. Oleg.