Memory Folios Updated A 14th Time For Improving Linux Memory Management
Written by Michael Larabel in Linux Kernel on 15 July 2021 at 06:00 AM EDT. 12 Comments
Matthew Wilcox of Oracle has sent out his 14th revision to the memory "folios" patch-set for this new struct that aims to improve Linux's memory management code and ultimately better performance.

Memory folios is the work that can allow for better system performance like ~7% faster kernel builds as one beneficial metric. For those missing out on the earlier articles on Linux's memory folios, Wilcox sums it up as:
Managing memory in 4KiB pages is a serious overhead. Many benchmarks benefit from a larger "page size". As an example, an earlier iteration of this idea which used compound pages (and wasn't particularly tuned) got a 7% performance boost when compiling the kernel.

Using compound pages or THPs exposes a weakness of our type system. Functions are often unprepared for compound pages to be passed to them, and may only act on PAGE_SIZE chunks. Even functions which are aware of compound pages may expect a head page, and do the wrong thing if passed a tail page.

We also waste a lot of instructions ensuring that we're not looking at a tail page. Almost every call to PageFoo() contains one or more hidden calls to compound_head(). This also happens for get_page(), put_page() and many more functions.

This patch series uses a new type, the struct folio, to manage memory. It converts enough of the page cache, iomap and XFS to use folios instead of pages, and then adds support for multi-page folios. It passes xfstests (running on XFS) with no regressions compared to v5.14-rc1.

With memory folios v14 the code is re-based against Linux 5.14-rc1 and there are a variety of low-level code fixes, renaming of various functions, and other mostly smaller changes at this stage to improve the code formatting and structure.

There is a call to see at least some of memory folios for Linux 5.15 so we'll see if that happens. Given the possible performance wins, I'll also be firing up some kernel benchmarks with memory folios shortly.
Related News
About The Author
Author picture

Michael Larabel is the principal author of 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 automated benchmarking software. He can be followed via Twitter or contacted via

Popular News This Week