Google Finally Begins Their Open-Source Dance Around Linux User-Space Threading

Written by Michael Larabel in Google on 23 July 2020 at 03:17 AM EDT. 20 Comments
GOOGLE
Way back in 2013 there was a presentation at the Linux Plumbers Conference around Google's work on user-level threads and how they were working on new kernel functionality for using regular threads in a cooperative fashion and building various features off that. Fast forward to today, that functionality has been in use internally at Google for a range of services for latency-sensitive services and greater control over user-space scheduling while now finally in 2020 they are working towards open-sourcing that work.

Following an early request for comments at the end of June, Google has sent out a request for the new "FUTEX_SWAP" functionality to be pulled into Linux 5.9. Google's Peter Oskolkov explained:
This patchset is the first step to open-source this work. As explained in the linked pdf and video, SwitchTo API has three core operations: wait, resume, and swap (=switch). So this patchset adds a FUTEX_SWAP operation that, in addition to FUTEX_WAIT and FUTEX_WAKE, will provide a foundation on top of which user-space threading libraries can be built.

Another common use case for FUTEX_SWAP is message passing a-la RPC between tasks: task/thread T1 prepares a message, wakes T2 to work on it, and waits for the results; when T2 is done, it wakes T1 and waits for more work to arrive. Currently the simplest way to implement this is

a. T1: futex-wake T2, futex-wait
b. T2: wakes, does what it has been woken to do
c. T2: futex-wake T1, futex-wait

With FUTEX_SWAP, steps a and c above can be reduced to one futex operation that runs 5-10 times faster.

A 5~10x speed improvement with FUTEX_SWAP certainly sounds compelling as does the information shared way back at LPC 2013 via the video below and the PDF slides.


While FUTEX_SWAP could be honored for the Linux 5.9 cycle, this is just the start and will likely be a few more cycles before all of this Google work is finally open-source and mainlined. More details via this patch series.
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