Search

A technology, a device or an article

Free RAM that Linux cannot take offline

Why Linux can fail to offline RAM despite enough free capacity: physical ranges, page migration, and advance placement in ZONE_MOVABLE.

Removable metal piece joined to surrounding blocks by a copper staple
ITNWS AI-generated conceptual illustration. A staple evokes an obstacle to emptying a particular RAM range.ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

There is enough space, but the operation is not completed. In our fictitious situation, Linux must stop using a specific region of physical RAM. The free memory on the machine significantly exceeds the size of this area, but the offline request returns a resource-busy error. A tempting diagnosis is that the free memory counter is incorrect. However, the counter may be telling the truth. The operation requirement applies to specific physical addresses, while the total amount of free space does not yet indicate whether everything that remains alive can be removed from there. Let’s start the analysis with this discrepancy, without declaring it a real incident on the editorial server.

Linux Memory Hot(Un)Plug documentation describes changing the available physical memory during operation. This is used both in virtual machines, where the provided capacity can be changed in software, and on suitable hardware platforms. Support varies by architecture, kernel configuration, and system itself. The familiar word hotplug does not make a typical desktop computer module suitable for removal under power. Here we are interested in the logical task of the kernel: to stop servicing the allocated physical range before it is subsequently removed.

Let’s go back a little. When memory was added, the necessary description was created for it in the kernel. It could then be passed to the page allocator, making it available for regular allocations. These are distinct actions. The existence of a memory block object in the system interface does not necessarily mean that all the pages it represents are already being used as online RAM. Therefore, the reverse operation begins with cessation of use, and not with physical shutdown. You cannot remove a support before the work that the system still considers active is removed from it.

In the hypothetical example, a block occupies 1 GiB, and outside of it there is 8 GiB of free memory. These are hypothetical values, not properties of any Linux machine. If there are movable user pages in the block, the kernel can find new locations for them, migrate the contents, and update the necessary mappings. The virtual addresses of the process may remain the same. The program continues to access its address, although the physical page behind it has changed. Freeing a specific range requires such a controlled change in physical backing, not just an arithmetic subtraction of a gigabyte.

But among the pages of our block there is a hypothetical unmovable kernel allocation. It does not have a suitable migration mechanism to safely replace the physical location as part of this operation. The remaining free gigabytes do not eliminate the obstacle. To complete offline, you need the selected range to be empty; you can’t declare it free based on the fact that there is enough other RAM somewhere. As in the relocation problem, the presence of free space does not create the opportunity to move any object. The analogy ends where the rules of links and hardware access to pages come into play.

The documentation names page tables and regular kmalloc allocations as important examples of unmovable allocations. It does not follow from this that each allocation of each subsystem type in all configurations has the same fate. The supported path of movement of a particular object is important. The kernel has internal addresses, references, and consumers for which physical locations cannot simply be substituted. Otherwise, the formally freed memory would remain the target of an active access. Failure here may mean maintaining the necessary correctness condition, rather than a lack of diligence in the procedure.

The page remains in place

Why did it even end up in a block that was planned to be removed someday? Conventional memory allocation is not required to pre-serve the administrator’s future plan. If the range is available for unmovable allocations, they may appear there long before the offline request. The pause between adding RAM and trying to remove it becomes part of the story. Two identical blocks are capable of receiving different contents after different loads. The same size and online condition cannot predict the same result of a future withdrawal from work. You need to know which allocations are allowed to use the range.

ZONE_MOVABLE is essential for this. Movable allocations are directed to this zone, limiting the placement of unmovable objects to other zones. A distribution prepared in this way increases the reliability of subsequent offlining. This is a preliminary decision about acceptable content, not a magic command that will eventually turn any busy page into a movable one. A later intention to remove a block does not automatically rewrite the nature of the objects already placed inside. In our fictitious case, the thought of future extraction came later than the obstructing allocation.

Regular user anonymous pages and file cache pages are candidates for migration in most cases. But “user-space” does not mean “always immediately movable.” Temporary occupancy, retention of pages by external consumers and the characteristics of large pages change specific conditions. The term movable specifies a capability within the mechanism, rather than a promise to complete any request in a fixed number of milliseconds. If the system continues to run during the attempt, the procedure’s environment also changes. It is important for the investigation to separate a permanent obstacle from a circumstance that may disappear.

Linux Page Migration Description helps to understand the hidden work. It is not enough to copy the bytes into a new buffer: the mappings and accesses must be consistent so that participants accessing the page continue to see the correct data. During migration, there are locks, checks, and possible failures. Allowing migration for a page class does not override the requirements of a particular state. Therefore, the simple idea of “rewriting the entire gigabyte into a free eight” misses precisely the part of the procedure that makes the move safe for programs that continue to run.

A virtually contiguous process array does not have to occupy one contiguous physical region. Mappings can link adjacent virtual pages to distant physical pages. Therefore, the kernel is able to move part of the array while maintaining the usual program addresses. Offlining specifies the reverse geometry: we are interested in the entire defined physical range, regardless of how many processes and objects own the pages located there. Stopping one process does not automatically free the entire block, and a large virtual region does not mean that it entirely interferes with one selected range.

Pencil drawing of blocks with one bolted piece in the area being emptied
ITNWS AI-generated conceptual illustration. One remaining piece evokes an unmovable page, not a real memory map. — ITNWS · image_gen · Original ITNWS AI-generated conceptual editorial illustration

Then there is the less obvious cost of advance preparation. Non-transmovable allocations still need memory in other zones. If almost all RAM is given to ZONE_MOVABLE, free memory in general can coexist with insufficient kernel space. The documentation calls this zone imbalance. Thus, the “make everything movable” strategy can worsen performance. Planning must leave sufficient suitable memory for those consumers for whom the movable zone is not suitable. Total volume again appears to be a less accurate description than the distribution of suitable locations for different allocations.

What the error said

Let’s return to the failed operation with which we started. The block does not become offline after an unsuccessful operation; documentation indicates maintaining the previous state. This means that trying does not equal completion. If the shell reported a write error to the system interface, this is not permission to delete the physical resource. We need a confirmed result of the procedure. We are discussing the semantics of the interface; we do not provide commands for changing the reader’s memory here. The busy error is consistent with our history, but does not by itself establish which page was the cause.

Even the meaning of the name removable requires caution. According to the current documentation, this legacy interface now reports the presence of kernel memory offlining support, rather than a verified prediction of the success of each block. To read one and declare the entire range to be guaranteed to be deleted would be to give the field its former or a desired meaning. For a running block, there is separate information about the zone. Some ranges may have mixed zones or nodes that prevent offlining. The interface should be read by the applicable version of the document, not by one clear English word.

The memory block size is also not universal. Linux relates it to the architectural organization of memory sections; the size is available through the corresponding system attribute. One object of such a block can cover more than one hardware or software concept familiar to the user. Voids in the physical range and certain mixed configurations create separate limitations. Therefore, the hypothetical gigabyte of our story cannot be transferred to the address formula of any system. A successful investigation first establishes the actual granularity and then explains the contents of exactly the desired block.

ZONE_MOVABLE does not override the edge cases listed. The documentation discusses large pages, CMA areas, memory constraints for auxiliary structures, and other limitations. The list here is not a substitute for investigation. Its significance is that the preliminary policy increases the reliability of the operation while maintaining the technical conditions for its execution. It is especially unpleasant when, in order to free up memory, additional memory of a certain type is required: it is available in the general counter, but the required allocator cannot obtain a suitable location. Such a failure is not corrected by repeating the original arithmetic comparison.

There is also a duration. The procedure may retry for a very long time as it waits for the obstacle to disappear. The absence of an immediate error therefore does not prove that the block is already free. The going-offline state describes the work, not its result. During operation, a distinction is made between request, observed progress and confirmed completion. This is especially important for automation: the next operation should depend on the actual state, and not on an optimistic pause of a given length. Expiration of the timer does not, by itself, transfer the held page or complete the hardware shutdown.

Internal API memory hotplug describes notifications to subsystems about the start of offlining, its cancellation, and success. They show that the change affects kernel subsystems that must coordinate their own memory usage. The start message allows you to release objects known to the subsystem; canceling returns the range to the appropriate state of use. This is an additional reason not to reduce the procedure to editing the capacity counter. A proper system should maintain consistency in the event of failure, where an intent to reduce RAM has already been declared and failed to complete.

It is also necessary to distinguish between offlining an entire block and processing a damaged individual page. The documentation specifically separates the hard_offline_page and soft_offline_page interfaces associated with hardware errors from the normal offlining of memory blocks. Similar words denote different tasks and different reasons for action. Failure to remove a large range is not a message that its contents are damaged, and offlining a damaged page does not mean readiness to detach the entire module. Substitution of these procedures creates an incorrect diagnosis even before discussing free capacity.

In a virtual machine, this is supplemented by a host memory provisioning layer. Resource reduction on the host side must be consistent with the guest’s supported mode of operation. The presence of free RAM on the host does not indicate that the necessary physical pages of the guest have already been taken out of use. These are different address spaces and different accounting. Our hypothetical block belongs to the kernel in question; transferring its results to the entire host without understanding the virtualization mechanism would again mean replacing a specific task with a convenient general figure.

Our fictional error now has a subject: the selected physical range was not released under the current conditions. It does not prove faulty modules, incorrect total volume, or the impossibility of hotremove at all. Different content, a different prior placement policy, or the disappearance of a particular temporary hold might have changed the outcome, but each such assumption requires testing. Sources verified October 25, 2026. At the end of the story, what remains is not a lack of abstract gigabytes, but a page at a specific address and the question of whether there is a safe continuation of its life in another place.

Sources & documentation

  1. Linux memory hotplug administration ↗
  2. Linux memory hotplug core API ↗
  3. Linux page migration ↗