Reader Writer Semaphore design, atomic contention on cgroups/kernfs rwsem and potential reader optimizations

Reader Writer Semaphore (rwsem) is a synchronization mechanism in Linux which is used for read-heavy sleepable critical sections. Its design uses various techniques like optimistic spinning, lock handoff, non-spinnable to balance the performance and fairness for long duration waiters.

For read-heavy use cases, the atomics contention during reader lock acquisition impacts scalability of some of the container applications. While the scalable alternative of using percCPU reader-writer semaphore addresses reader side scalability, it heavily impacts writer performance. In this talk, we present current design of reader writer semaphore. We also discuss the scalability problem and describe approaches to address the writer heavy problem with perCPU rwsem.

Neeraj UPADHYAY