Bug 208943

Summary: epoll_wait() does not return events when running in multiple threads
Product: IO/Storage Reporter: Sergey Nikitin (Sergey.Nikitin)
Component: OtherAssignee: io_other
Status: NEW ---    
Severity: normal CC: dave, Sergey.Nikitin
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.7 Subsystem:
Regression: No Bisected commit-id:
Attachments: Reproducer

Description Sergey Nikitin 2020-08-17 17:01:50 UTC
Created attachment 291997 [details]
Reproducer

epoll does not report an event to all the threads running epoll_wait() on the same epoll descriptor.
The behavior appeared in recent kernel versions starting with 5.6

How to reproduce:
- create a pair of sockets
- create epoll instance
- register the socket on the epoll instance, listen for EPOLLIN events
- start 2 threads running epoll_wait()
- send some data to the socket
- see that epoll_wait() within one of the threads reported an event, unlike another.

I attached a python script reproducing the issue.
Here's the output on my environment:
1. Fail case
  $ cat /proc/version
  Linux version 5.7.9-200.fc32.x86_64 (mockbuild@bkernel01.iad2.fedoraproject.org) (gcc version 10.1.1 20200507 (Red Hat 10.1.1-1) (GCC), GNU ld version 2.34-3.fc32) #1 SMP Fri Jul 17 16:23:37 UTC 2020
  $ ./multiple_same_epfd.py
  MainThread: created epfd5
  Thread-1 epfd5: start polling
  Thread-2 epfd5: start polling
  MainThread: Send some data
  Thread-2 epfd5: got events: 1
  Thread-1 epfd5: got events: 0
2. Pass case
  $ cat /proc/version
  Linux version 5.4.17-200.fc31.x86_64 (mockbuild@bkernel04.phx2.fedoraproject.org) (gcc version 9.2.1 20190827 (Red Hat 9.2.1-1) (GCC)) #1 SMP Sat Feb 1 19:00:13 UTC 2020
  $ ./multiple_same_epfd.py
  MainThread: created epfd5
  Thread-1 epfd5: start polling
  Thread-2 epfd5: start polling
  MainThread: Send some data
  Thread-2 epfd5: got events: 1
  Thread-1 epfd5: got events: 1
Comment 1 Davidlohr Bueso 2021-04-10 18:31:09 UTC
Thank you for the report. Please refer to:

https://lore.kernel.org/lkml/20210405231025.33829-1-dave@stgolabs.net/