Latest

Technology

Linux 7.4 improves its boot speed in cloud environments

Linux 7.4's early memory allocator goes from 268 seconds to 50 ms in the KHO tests, and workqueues speed up by up to 100 times.

Linux 7.4 improves its boot speed in cloud environments
Linux 7.4 improves its boot speed in cloud environments

There are kernel operations that only become noticeable when the machine is enormous. One of them, the search for physical memory regions that the system performs during boot, was eating up around 268 seconds when memory arrived heavily fragmented. The memblock patch series submitted for Linux 7.4 on October 24, 2026 leaves that same task at around 50 milliseconds and the patch message signed by Tarun Sahu, an engineer at Google.

The cause was simple to describe and somewhat embarrassing to explain. memblock is the allocator that reserves and frees physical memory before the normal page allocator exists, and for years it had been walking its list of candidate regions one by one instead of splitting it in half. The linear search only becomes unbearable with a lot of memory and a lot of gaps, so the problem lived hidden in a path that almost no one timed.

That path stopped being a marginal one. Memory handover between kernels, known as Kernel Handover or KHO, leaves thousands of scattered folios that memblock must find after a live handover, and the same merge cycle has loosened a second bottleneck with workqueues. The figures come from tests published by the development ecosystem, not from a home laptop, and that difference matters for reading them with judgment.

From linear search to binary search

The change lives in two functions in `mm/memblock.c`, memblock_add_range and memblock_isolate_range, which until now searched for the right gap by walking the list of regions from the start. Sahu found that this linear walk was enough to sink the worst case.

The patch replaces it with a binary search over a list that is already sorted. Complexity drops to O(N log N) in the worst case and stays at O(N) when insertions arrive in order, which is the usual path in an uneventful boot.

The patch message sums it up in one dry sentence: the binary search cuts KHO memory recovery from about 268 seconds to about 50 milliseconds, and the worst case now grows with N log N instead of dragging a full walk through on every insertion.

Where does a booting kernel get stuck?

The scenario that uncovered the figure is not just any boot. KHO transfers the memory of a running kernel to another without rebooting the machine, and that operation is used by the Live Update Orchestrator and similar tools to apply updates without interrupting service. With memory chopped into thousands of loose folios, memblock has to locate each valid region amid a forest of gaps, one for each folio left scattered.

A laptop with 16 GB is not going to notice this change, because its memory map is small and the linear search finishes before the user sees the boot logo.

The benefit shows up on servers with a lot of RAM, in the boot of chained virtual machines and in any operation that forces a walk of the entire physical map with fragmented memory. The figure of 268 seconds describes that extreme, not the average desktop.

Memory is, moreover, the resource that has opened the most discussions this autumn in the kernel. The DRAM shortage has brought back to the table the debate over smaller stacks per task, where every kilobyte counts in fleets with millions of threads. Handling the physical map better fits that same logic of saving.

Workqueues, the other bottleneck that loosens

The other half of the speedup arrived a day earlier, with workqueues as the protagonists, in the pull that changed how queues are walked. A workqueue is the queue with which the kernel defers work to be executed later in a separate thread, and draining it required visiting one queue per possible CPU, even if only a few had received work since the last drain.

Tejun Heo signed the change that limits the walk to the queues used since the previous flush. On a machine with 192 CPUs spread across two nodes, draining an inactive CPU-bound workqueue went from 40,000 to 4.2 million operations per second, and the non-CPU-bound one jumped from 450,000 to 4.3 million, according to the figures the author himself included in the commit message.

The case that motivated the work was more specific. Yao Kai, an engineer at Huawei, reported in September that XFS's CIL workqueue, drained on every log force of the file system, was spending up to 64 microseconds per flush on a machine with 128 CPUs.

There is fine print. With all workqueues active, dense drains are unchanged on per-CPU queues and lose between 15% and 20% on non-bound ones, a price the maintainers accepted so that the frequent case stops dragging a walk through hundreds of idle CPUs.

The measurements of the cycle

The figures that sum up the cycle read better together, because each one measures a different extreme of the same problem and none promises an overall improvement to the system. It is worth noting the context column before comparing numbers, since they come from separate test benches.

Change in Linux 7.4 Before After Test context
KHO memory recovery in memblock about 268 s about 50 ms Extreme fragmentation, scattered folios
Draining of inactive per-CPU workqueue 40,000 per second 4.2 million per second 192-CPU machine across two nodes
Draining of inactive non-bound workqueue 450,000 per second 4.3 million per second 192-CPU machine across two nodes
Sixteen threads enqueuing and draining 30,000 per second 110,000 per second CPU-bound workqueue

Why does boot weigh more in the cloud?

No one thinks anymore about that moment of black screen before working. In a fleet of virtual machines, the time until a process starts working is paid in money, and platforms that create instances on demand watch that stretch more closely than sustained performance. Every minute the kernel spends ordering its physical map before handing over control is a minute that produces nothing.

Live updating adds a second reason. A kernel handover without a reboot requires moving the memory state from one kernel to another, and that procedure is only viable if the transfer is measured in milliseconds. A four-minute pause in the middle of maintenance turns an availability improvement into a service outage.

A window open since October 19

Linux 7.4 is still under construction and none of these patches is within reach of a user. The merge window opened on October 19 had accumulated 6,753 changes not counting merges as of the close on Friday the 23rd, a third of the usual calendar. Torvalds warned that the extra week of margin will not serve him to accept work that was not ready before the door opened.

The first version that can be seriously tested is rc1, expected for November 1 or 8, and that date drags along the stabilization phase and the moment when a distribution can plan its jump.

Until then, the memblock and workqueue pulls are pieces of a main tree that moves daily and is not packaged for production, so none of these improvements has yet passed the filter of a stable candidate.

José Maldonado

Author

José Maldonado

Activist and blogger on technology, free software and blockchain.

The latest
From Huang to Botín, from Zara to Byron: corporate responsibility in global capitalism

Keep reading