Linux 7.3 to Feature Two Major Memory Management Optimizations; Zswap and KSM Long-standing Issues Addressed
The Linux 7.3 memory management patches tackle critical issues: lock contention in zsmalloc and long-held reverse mapping locks in KSM.
AFFILIATE_PRODUCTS:
The Linux 7.3 merge window is in full swing, with a major overhaul of the kernel’s memory management subsystem underway. The “MM” patch set, sent by maintainer Andrew Morton on August 19, processed a massive volume of 1,250 emails, exceeding the 920 from the previous cycle. According to a report by Phoronix’s Michael Larabel, two performance-critical optimizations stand out from this large batch of patches.
Reducing Lock Contention in zsmalloc
The first patch series aims to alleviate lock contention in the zs_free() function within Linux’s zsmalloc memory allocator. zsmalloc is used to free compressed RAM pages managed by Zswap or zRAM. In particular, under memory pressure—a common scenario on Android devices and server environments heavily utilizing Zswap—lock contention in zs_free() can become a severe bottleneck.
Given the current high memory prices and the growing use of Zswap/zRAM in large-scale servers, resolving this contention has a significant impact. Performance measurements by Wenchao Hao of Xiaomi showed improvements in a sequence where a process maps, writes, pages out via madvise, and concurrently unmaps 256MB of memory. Speedups were observed, with improvements up to 1.83x on a small Raspberry Pi 4B and up to 1.4x on a 20-core Intel system.
Solving Performance Issues in KSM Reverse
Mapping Walks
The second notable patch optimizes the rmap_walk_ksm() function, which performs reverse mapping (rmap) walks for pages managed by Kernel Same-page Merging (KSM). Engineers from ZTE discovered a “serious” performance problem with KSM’s rmap walks under memory pressure. The problem is most pronounced when many unrelated virtual memory areas (VMAs) share a single anon_vma.
The severity of this issue is evident in the numbers. The performance improvements have reduced the lock hold time from over 500 milliseconds to under 2 milliseconds. As detailed by Xu Xin of ZTE in an earlier patch series, in a worst-case benchmark where 20,000 VMAs shared a single anon_vma, the lock hold time was slashed from 705 milliseconds to an average of 1.44 milliseconds and a maximum of 1.67 milliseconds.
Impact on Real Users
This anon_vma lock is acquired not only during KSM rmap walks but also in numerous other kernel operations, including page faults, reclaim, migration, compaction, mlock, exit_mmap, and cgroup accounting. Prolonged lock holding due to inefficient rmap walks can stall application threads, leading to latency spikes, reduced throughput, and even container timeouts. Interestingly, the Phoronix article also notes that the problem occurs with VMA splits that do not involve a fork() (e.g., mremap).
Editorial Opinion
These optimizations are expected to directly improve the responsiveness of Android devices and the throughput of cloud servers relying on Zswap in the short term. With memory prices remaining high, improving swap memory efficiency is also significant from a cost perspective. In particular, solving the KSM issue can greatly reduce unpredictable latency spikes in container environments, contributing to the stability of Quality of Service (QoS). In the long term, a more efficient memory management foundation could influence the design guidelines for memory-intensive applications like in-memory databases and large-scale big data processing frameworks. The reduction of lock contention will provide a foundation to elevate the scalability of parallel processing to a higher level. Additionally, the report that Andrew Morton utilized Google’s Gemini AI for summarization during this patch cycle symbolizes how AI is beginning to be employed to ease the maintenance burden in massive OSS projects. This evolution of infrastructure, while certainly not a direct concern for application developers at the upper layers, underpins future possibilities.
References
- “Two Very Exciting Memory Management Optimizations Going Into Linux 7.3”, by Michael Larabel — Phoronix, 2026-08-19T20:31:26.000Z (ARR)
- Source URL: https://www.phoronix.com/news/Linux-7.3-MM
Comments