Hasty Briefsbeta

Bringing restartable sequences out of the niche

4 hours ago
  • #concurrency
  • #kernel
  • #performance
  • Restartable sequences (rseq) help user-space applications execute lockless algorithms efficiently by allowing critical sections to be restarted if interrupted.
  • The kernel uses a shared memory area set up via the rseq() system call to communicate CPU and NUMA node information to user space, improving functions like sched_getcpu().
  • Recent interest in time-slice extension, which allows threads in critical sections to request extended CPU time, has brought more attention to restartable sequences.
  • Thomas Gleixner identified performance issues in the restartable sequences implementation, such as unnecessary bit manipulation and deprecated features, leading to optimizations.
  • Gleixner's changes include replacing complex event tracking with a simpler boolean flag and removing redundant user-space memory accesses, improving performance.
  • The kernel now handles system calls differently from interrupts in restartable sequences, potentially breaking applications that misuse the feature.
  • Debug kernels enforce strict rules, such as terminating processes that make system calls within critical sections, to ensure correct usage of restartable sequences.
  • Further optimizations and fixes are expected as Gleixner continues to review and improve the restartable sequences code.