C Carlo Wood #
Message details and related content
Hello everyone, this is a follow up to a discussion from 2012 about EPOLL_CTL_DISABLE, which ended up NOT being accepted in the kernel. I believe however that this issue wasn't addressed. Michael Kerrisk did an excellent job writing a summary of the problem: https://lkml.org/lkml/2012/10/16/302 (the first four listed points). In the past two years I've been working on "yet another" event driven I/O library, exclusively for linux however, with the general aim to be highly scalable for many cores. The I/O part (around epoll) is only part of that library - but it is what I spent the last two years on. I ran independently into the same problem as described by Paton Lewis and only afterwards, when I couldn't think of a working solution and started to do heavy research, found related articles about the problem. Reading through the thread on lkml.org that given above, it still isn't clear to me that this would be a non-issue that can be solved in user space (without severe (unnecessary) performance penalties). Let me summarize the problem in my own way (probably less general, but more related to my personal case): 1. The epoll interest list stores a pointer in epoll_event::data.ptr that points to a specific file descriptor related object, which indeed can be seen as a user-space cache of data related to that file descriptor. In my case this includes one mutex that protects an unsigned int whose bits keep track of things like whether or not that object (pointer) is in the epoll interest list (was added with epoll_ctl) and which events are being watched specifically, as well as whether or not the fd was closed (after removing it from the interest list with EPOLL_CTL_DEL) etc. 2. At least one thread (only one, in my case) calls epoll_wait (epoll_pwait) in a loop. I use no timeout because that seems too inaccurate, my timers are signal based. When epoll_wait returns, the pointer epoll_event::data.ptr is used to call a member function on the dereferenced FileDescriptor class. For non-C++ coders, that