This article is more than 1 year old

Google offers first part of its in-house M:N thread code as open source to Linux kernel

If this fine-grained thread control tech can run The Chocolate Factory, imagine it unleashed in Android

Google has confirmed it plans to contribute some of its in-house threading code to the Linux kernel, but hasn’t disclosed its motivations beyond a desire to share.

As described by Googler Peter Oskolkov on the Linux kernel mailing list, the tech is “an M:N userspace threading subsystem backed by Google-private SwitchTo Linux Kernel API. This subsystem provides latency-sensitive services at Google with fine-grained user-space control/scheduling over what is running when, and this subsystem is used widely internally (called schedulers or fibers).”

Scheduling and managing threads matters when you want to make sure your CPU cores don’t lie idle if there’s work they could usefully be doing. M:N threading is one approach, and it's typically more efficient than the 1:1 approach most kernels tend to use.

The Register asked Google to explain what it’s up to with this contribution to the kernel and was told simply: "Threading technology is widely used across Google."

Which makes a lot of sense given Google tries to wring the most out of its colossal server fleet.

Happy penguin, image via Shutterstock

Rust code in Linux kernel looks more likely as language team lead promises support


We were also told the web goliath “generally wants to open source helpful production APIs" and is releasing this code in the spirit that saw it share the Abseil scheduling code and tcmalloc memory allocation routines.

While the post to the kernel mailing list targets version 5.9 of the Linux kernel, Google told us it has: "No firm timeframe to share at this time" regarding when Linux users might be able to play with its SwitchTo API. According to Oskolkov, the latest patches are "the first step to open-source this work."

Google first discussed this work in 2013 in a talk, and the lengthy time elapsed since that event could mean that Google now runs more advanced scheduling code in-house and is therefore comfortable open-sourcing old work.

Android’s reliance on the Linux kernel could be another factor here, as with many smartphones now boasting multi-core processors better threading could be desirable.

A few posts to the mailing list discussed the API in recent weeks, and Oskolkov said he’d submitted the last of the code. With the Linux 5.9 merge window currently open, we’ll soon know if it will hit the kernel sooner or later. ®

More about


Send us news

Other stories you might like