Linux RSEQ Patches Updated For Allowing Faster getcpu() In C Libraries

Written by Michael Larabel in Linux Kernel on 23 September 2022 at 05:33 AM EDT. 7 Comments
LINUX KERNEL
Restartable Sequences "RSEQ" has been one of the nice additions to the Linux kernel in recent years and can allow for faster user-space operations on per-CPU data by providing a shared data structure ABI between each user-space thread and the kernel. RSEQ has been in the process of being extended to provide even more performance benefits.

RSEQ integration was (re)integrated earlier this year on the user-space side with Glibc 2.35 for making use of the Restartable Sequences system call for faster user-space operations on per-CPU data. RSEQ lead developer Mathieu Desnoyers has been more recently working on extending the kernel support to expose a NUMA node ID and virtual CPU ID extensions.

The NUMA node ID to be exposed by the pending RSEQ kernel patches will allow for implementing a faster getcpu() function within Glibc and any other C libraries. The getcpu() function, of course, being for determining the CPU and NUMA node of where a given thread is running.

The virtual CPU ID extensions being worked on as part of this patch series is for better scaling up or down of user-space per-CPU data structures. Desnoyers explains of that work, "The virtual cpu id allows ideal scaling (down or up) of user-space per-cpu data structures. The virtual cpu ids allocated within a memory space are tracked by the scheduler, which takes into account the number of concurrently running threads, thus implicitly considering the number of threads, the cpu affinity, the cpusets applying to those threads, and the number of logical cores on the system."

These latest RSEQ patches can be found on the kernel mailing list.

Mathieu Desnoyers earlier this month at Linux Plumbers Conference (LPC 2022) presented on this latest RSEQ work. There is this PDF slide deck from his presentation for those interested. There is also this slide deck for his second RSEQ presentation focused on use within containers.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week