Dynamic Kernel Stacks Proposed For Linux With Big Memory Savings

Written by Michael Larabel in Linux Kernel on 12 March 2024 at 12:00 AM EDT. 22 Comments
A "request for comments" patch series was posted on Monday for a new dynamic kernel stacks feature for Linux. Early testing has shown the potential for significant memory savings.

Following a proposal from last year's LSF/MM summit, Google has implemented support for dynamic kernel stacks. For the past decade the default stack size of the upstream Linux kernel has been 16K up from the prior 8K size. Google had been carrying kernel patches to keep 8K stacks but over time encountered the need for larger stack sizes to which they in turn hit increased memory use with their hyperscale deployments. For mitigating the increased memory use, Google has been working on dynamic kernel stacks since many kernel threads can fit within 4K or 8K stacks.

Lots of RAM

The work-in-progress RFC patches for dynamic kernel stacks has so far been lightly tested and allows scaling from 4K to THREAD_SIZE limits. Google engineers found that dynamic kernel stacks can save on average 70~75% of the kernel stack memory.

The early results posted by Pasha Tatashin have been very promising but can depend upon the workload, virtualization, and other factors:

dynamic kernel stack benefits

Tatashin further added, "Some workloads with that have millions of threads would can benefit significantly from this feature."

See the RFC patch series for those interested in this work for saving on the kernel stack memory.
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