|
|
Subscribe / Log in / New account

Clarifying memory management with page folios

Clarifying memory management with page folios

Posted Mar 19, 2021 4:10 UTC (Fri) by willy (subscriber, #9762)
Parent article: Clarifying memory management with page folios

New version of patch series:

https://git.infradead.org/users/willy/pagecache.git/short...

I'll do the changelog / cover letter / ... in the morning.

BTW, I do want to emphasize that real workloads see a performance improvement. With the previous work, based on using Transparent Huge Pages, we saw a 7% performance improvement on kernel compiles, and that was with a very naive untuned algorithm for scaling up the THP size.


to post comments

Clarifying memory management with page folios

Posted Mar 19, 2021 9:12 UTC (Fri) by wahern (subscriber, #37304) [Link] (1 responses)

Rather than doing everything in one go, couldn't a transparent union argument type and _Generic be used, variously, for certain critical functions and highly-trafficked interfaces? I image much of the performance improvements come from a relatively small subset of the changes. Those could be nailed down in a smaller patch series, and the remainder fixed over time.

Clarifying memory management with page folios

Posted Mar 19, 2021 11:29 UTC (Fri) by willy (subscriber, #9762) [Link]

Have you looked at the patch series? I don't do everything in one go. Essentially I'm going one function at a time. It's pretty straightforward to convert between pages and folios. If you have a page and want the folio that contains it, that's spelled page_folio(page). If you have a folio and want the head page, that's &folio->page. If you have a folio and want the page that corresponds to a particular file index, that's folio_file_page(folio, index).

If you have a folio and want the n'th page, that's nth_page(&folio->page, n). Nobody's needed that one yet (and only people with really weird physical memory layouts need to do that ... alloc_folio() won't return a folio that you need to do that to. Others are working on maybe disallowing those from existing entirely, in which case (&folio->page + n) will do fine.

The performance improvements do not come from a small subset of the changes. You have to make the entire filesystem safe to handle memory in folios (no more references to, eg, PAGE_SIZE, unless you can prove they're safe, calls to kmap() have to be scrutinised. copy_(to|from)_iter() calls need care and attention, etc, etc). Once the filesystem declares itself safe by setting a bit in the fs_flags then the page cache can start handing it folios instead of pages.

I think what you're suggesting is essentially what I did here:
https://git.infradead.org/users/willy/pagecache.git/short...

I've given up on that approach because it's hard to find all the bugs. "Oh this interface takes a struct page. Does it take any struct page, or do I need to call it once for each tail page in the compound page?" I invite you to consider the various implementations of flush_dcache_page() ... and if you can figure out the answer, please let me know.

Clarifying memory management with page folios

Posted Mar 25, 2021 23:00 UTC (Thu) by flussence (guest, #85566) [Link]

7% is pretty impressive, considering that getting any performance improvement out of the mm code in this day and age is like drawing blood from a stone!

I vaguely remember getting excited over the original THP patchset because I'd measured a consistent 3-4% improvement in memory-heavy workloads…


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds