• Roman Penyaev's avatar
    epoll: use rwlock in order to reduce ep_poll_callback() contention · a218cc49
    Roman Penyaev authored
    The goal of this patch is to reduce contention of ep_poll_callback()
    which can be called concurrently from different CPUs in case of high
    events rates and many fds per epoll.  Problem can be very well
    reproduced by generating events (write to pipe or eventfd) from many
    threads, while consumer thread does polling.  In other words this patch
    increases the bandwidth of events which can be delivered from sources to
    the poller by adding poll items in a lockless way to the list.
    
    The main change is in replacement of the spinlock with a rwlock, which
    is taken on read in ep_poll_callback(), and then by adding poll items to
    the tail of the list using xchg atomic instruction.  Write lock is taken
    everywhere else in order to stop list modifications and guarantee that
    list updates are fully completed (I assume that write side of a rwlock
    does not starve, it seems qrwlock implementation has these guarantees).
    
    The following are some microbenchmark resu...
    a218cc49
eventpoll.c 64.8 KB