|
|
Subscribe / Log in / New account

Making kernel pages movable

Making kernel pages movable

Posted Jul 27, 2015 12:29 UTC (Mon) by vbabka (subscriber, #91706)
In reply to: Making kernel pages movable by ksandstr
Parent article: Making kernel pages movable

What you are suggesting does exist, and is called "grouping pages by mobility". Hugepage-large blocks of memory are marked with a "migratetype" as movable, unmovable, or reclaimable (for slab caches where freeing can be requested). All allocations declare their migratetype and the allocator tries to find free page in the matching block first.

But it's not a silver bullet. It works perfectly until free memory is exhausted and then you eventually find out that e.g. an unmovable allocation doesn't fit in any of the pageblocks marked as unmovable, and the allocation has to "fallback" to one of the partially free movable blocks. There are heuristic to select the fallback blocks that will result in lowest possible permanent damage - i.e. select a movable block that has the most free pages, and mark it as unmovable, so if there are more unmovable allocation requests, they can be satisfied from the same block, and not pollute another one.

Still it's just heuristics and can't be perfect without being able to predict the future. Consider an extreme case of your "gaps appear at deallocation only" scenario. There might be a surge of unmovable allocations that will occupy nearly the whole memory for a while, and then every odd page will be freed. The remaining even pages will now occupy half memory, but spread evenly in all pageblocks. If we knew at the allocation time that the even pages would be long-lived and the odd ones not, we could group them together. But we can't know that...


to post comments


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