{"slug": "the-guaranteed-contiguous-memory-allocator-2025", "title": "The guaranteed contiguous memory allocator (2025)", "summary": "Suren Baghdasaryan has proposed a guaranteed contiguous memory allocator patch set for the Linux kernel, building on the cleancache concept to reserve physically contiguous memory at boot for reliable, low-latency allocations. The subsystem integrates with the existing CMA API and ensures allocation success as long as total requests stay within the reserved area, though it increases memory pressure by restricting reserved memory to evictable data.", "body_md": "# The guaranteed contiguous memory allocator\n\nAs a system runs and its memory becomes fragmented, allocating large, physically contiguous regions of memory becomes increasingly difficult. Much effort over the years has gone into avoiding the need to make such allocations whenever possible, but there are times when they simply cannot be avoided. The kernel'sLWN.net needs you!Without subscribers, LWN would simply not exist. Please consider\n\n[signing up for a subscription]and helping to keep LWN publishing.\n\n[contiguous memory allocator](/Articles/486301/)(CMA) subsystem attempts to make such allocations possible, but it has never been a perfect solution. Suren Baghdasaryan is is trying to improve that situation with the\n\n[guaranteed contiguous memory allocator patch set](/ml/all/20250320173931.1583800-1-surenb@google.com), which includes work from Minchan Kim as well.\n\nIn the distant past, Dan Magenheimer introduced the concept of [transcendent memory](/Articles/340080/) — memory that is not\ndirectly addressable, but which can be used opportunistically by the kernel\nfor caching or other purposes. Most of the transcendent-memory work has\nsince gone unused and been removed from the kernel, but the idea persists,\nand this patch series makes use of it to provide guaranteed CMA.\n\nSpecifically, the patch set includes a subsystem called \"cleancache\", which\nis a concept that was [proposed](/Articles/545244/) by\nMagenheimer in 2012. If the kernel has to dump a page of data, but would\nlike to keep that data around if possible, it can put it into the\ncleancache, which will stash it aside somewhere. Should the need for that\ndata arise, the kernel can copy it back out of the cleancache — if it is\nstill there. Meanwhile, the page that initially contained that data can be\nreclaimed for other uses.\n\nGuaranteed CMA then builds on cleancache by allocating a region of physically contiguous memory at boot, when such allocations are relatively easy. That memory is then turned into a cleancache and made available to the kernel. Whenever the memory-management system reclaims pages of file-backed memory, it can choose to place the data from those pages into the cleancache. Should that data be needed, an attempt will be made to retrieve it from the cleancache before rereading it from disk. The memory reserved for CMA is thus available to the kernel when not allocated to a CMA user, but in a restricted way.\n\nAt some point, some kernel subsystem will need a large, physically\ncontiguous buffer. Requesting that buffer from the guaranteed CMA\nsubsystem will result in an allocation from the reserved memory, after\ndropping any cached data that happens to be in the allocated region. This\nallocation can happen quickly, since that data has been cached with the\nexplicit stipulation that it can be dropped at any time. This\napproach was [proposed](/Articles/619865/) by Seongjae Park and\nKim in 2014.\n\nThis new subsystem is integrated with the existing CMA API, so CMA users need not change to make use of it. The reserved region is set up by way of a devicetree property explicitly requesting the \"guaranteed\" behavior.\n\nThe end result is a version of CMA that is guaranteed to succeed as long as the total allocations do not exceed the size of the reserved area; existing CMA has a higher likelihood of failure. Since CMA usage is often restricted to a problematic device or two with known needs, sizing the reserved area for a specific system should be straightforward.\n\nThe other advantage of guaranteed CMA is latency; if the memory is available, it can be allocated quickly. CMA in current kernels may have to migrate data out of the allocated region first, which takes time. The downside is that the memory reserved for guaranteed CMA can only be used for data that can be dropped at will; that will increase the pressure on the rest of the memory in the system.\n\nThis patch series was posted just ahead of the [2025 Linux Storage,\nFilesystem, Memory-Management, and BPF Summit](https://events.linuxfoundation.org/lsfmmbpf/), where it is currently\nscheduled for a discussion in the memory-management track. There will\nprobably not be a lot of comments on it ahead of that discussion. The\npatches are relatively small, though, and do not intrude into the\nmemory-management subsystem on systems where CMA is not in use, so we might\njust see a transcendent-memory application actually go forward, some\n15 years after the idea was first proposed.\n\n| Index entries for this article | |\n|---|---|\n|\n\n[Contiguous memory allocator](/Kernel/Index#Contiguous_memory_allocator)[Kernel](/Kernel/Index)[Memory management/Large allocations](/Kernel/Index#Memory_management-Large_allocations)The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:\n\n**Note**: you can avoid this step in the future by logging\ninto your LWN account.", "url": "https://wpnews.pro/news/the-guaranteed-contiguous-memory-allocator-2025", "canonical_source": "https://lwn.net/Articles/1015000/", "published_at": "2026-06-18 15:33:01+00:00", "updated_at": "2026-06-18 15:52:35.231446+00:00", "lang": "en", "topics": ["machine-learning"], "entities": ["Suren Baghdasaryan", "Minchan Kim", "Dan Magenheimer", "Seongjae Park", "Linux kernel", "CMA", "cleancache", "LWN.net"], "alternates": {"html": "https://wpnews.pro/news/the-guaranteed-contiguous-memory-allocator-2025", "markdown": "https://wpnews.pro/news/the-guaranteed-contiguous-memory-allocator-2025.md", "text": "https://wpnews.pro/news/the-guaranteed-contiguous-memory-allocator-2025.txt", "jsonld": "https://wpnews.pro/news/the-guaranteed-contiguous-memory-allocator-2025.jsonld"}}