Lightweight Guard Pages For Linux Showing 5x Speed-Up For Memory Mapping Invocations

Written by Michael Larabel in Linux Kernel on 20 October 2024 at 06:38 AM EDT. 5 Comments
LINUX KERNEL
Patches posted this week by Oracle's Lorenzo Stoakes are the latest attempt at lightweight guard pages for the Linux kernel.

These patches build upon a "request for comments" patch series from last month for iterating on lightweight guard pages. Stoakes explains of this effort in the patch cover letter:
"Userland library functions such as allocators and threading implementations often require regions of memory to act as 'guard pages' - mappings which, when accessed, result in a fatal signal being sent to the accessing process.

The current means by which these are implemented is via a PROT_NONE mmap() mapping, which provides the required semantics however incur an overhead of a VMA for each such region.

With a great many processes and threads, this can rapidly add up and incur a significant memory penalty. It also has the added problem of preventing merges that might otherwise be permitted.

This series takes a different approach - an idea suggested by Vlasimil Babka (and before him David Hildenbrand and Jann Horn - perhaps more - the provenance becomes a little tricky to ascertain after this - please forgive any omissions!) - rather than locating the guard pages at the VMA layer,instead placing them in page tables mapping the required ranges.

Early testing of the prototype version of this code suggests a 5 times speed up in memory mapping invocations (in conjunction with use of process_madvise()) and a 13% reduction in VMAs on an entirely idle android system and unoptimised code.

We expect with optimisation and a loaded system with a larger number of guard pages this could significantly increase, but in any case these numbers are encouraging."

The potential benefits are very enticing. Those wishing to dig deeper into this lightweight guard pages work for Linux can see this patch series for all the details.
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