Memorable Memory Management Improvements in Linux 6.18

Optimizing the Swapping Strategy in Linux 6.18

Memory management in Linux has seen a significant leap forward with kernel version 6.18. One of the major advances is the improvement of the cluster sweep strategy in the swapping code. This mechanism is crucial: it determines how memory pages are selected for transfer to disk when RAM reaches its limits. By refining this method, Linux is able to better manage large memory allocations in highly concurrency scenarios.

A concrete example illustrates this advancement well: a Tencent engineer evaluated the performance of a kernel compilation with 96 jobs in parallel, using 10 GB of zRAM (a memory compressed into RAM) and 64 KB transparent giant pages (mTHP). The results were spectacular, with a reduction in system overhead of nearly 50% and a significant drop in the swap failure rate. This performance gain reflects more efficient use of RAM and swap, contributing to kernel stability under intensive conditions.

Furthermore, this optimization is particularly welcome for multi-tasking and server environments where swap is used for long periods of time. Fine-grained swap management is linked not only to raw performance, but also to the process manager which depends on the availability of memory resources. A better swapping policy avoids prolonged blocking due to buffer saturation.

  • Improved cluster scanning to reduce operation time during large swaps
  • Better integration with zRAM and THP (Transparent Huge Pages) management
  • Reduced swap write failures, avoiding slowdowns and system crashes
  • Optimized performance during compilations and heavy loads

These improvements address issues often encountered on machines replacing Solaris with Linux, where increased workloads frequently cause slowdowns related to memory management. This development therefore marks an important step in system optimization for recent Linux distributions. To delve deeper into this technical aspect, it’s worth noting that the removal of the Zpool indirection layer, also implemented in this release, helps simplify and speed up the critical path of memory operations in the kernel.Discover how to efficiently manage memory in Linux 6.18: tips, tools, and best practices to optimize your system’s performance and stability. New features for memory pages in the Linux kernel

The Linux 6.18 kernel also introduces the concept of kernel file pages via file-mapped folios. This development takes a different approach to managing memory pages associated with files, facilitating more precise control and optimization of read/write memory access. Concretely, this mechanism is based on structuring memory pages into folios, a larger allocation unit better suited to the needs of modern processing. This allows the system to use RAM more efficiently during I/O operations. The page cache path, a cornerstone for avoiding repetitive disk accesses, has benefited from minor optimizations to accelerate large read operations.

This redesign improves Linux performance for typical servers and workstations, where intensive file access is the norm. For example, databases or file servers will see improved throughput thanks to reduced overhead associated with fine-grained memory page management.

Introduction of file-mapped folios to improve page management Optimization of the memory cache for large reads Reduction of disk calls through smarter cache management

Adaptation to multi-core architectures via better parallelization in memory management

These advances nevertheless weaken certain previous optimization practices and may encourage system administrators to review their tuning practices, particularly with the emergence of mechanisms such as transparent pages, which can now be partially disabled at the process level thanks to the PR_SET_THP_DISABLE extension. This feature gives application developers and server operators fine-grained control to disable the “always-on” THP in favor of on-demand behavior (madvise mode). Such granularity avoids the negative impacts of THP on certain specific loads while maintaining benefits for the system as a whole, increasing flexibility in dynamic memory management. This work is part of a global approach to continually improve the kernel, already discussed around Rust drivers in the kernel for greater code robustness ( details on the integration of Rust in Linux

  • ).
  • https://www.youtube.com/watch?v=aWQiLlk-dgU
  • Improved Swap Management and Impact on Hibernation and Stability
  • Swap, the disk space dedicated to compensating for saturated RAM, sees its role strengthened in Linux 6.18 with the preliminary introduction of

swap tablesas a swap cache. This new structure allows for better organization and optimization of swap access, crucial in a context where hibernation

depends directly on the quality of swap management to safeguard the state of RAM.The table-based organization improves responsiveness during swap read/write operations, reducing the risk of instability or long wait times when a machine wakes up. It also helps reduce the hits Linux systems face when multitasking on machines with slow or crowded disks. This is a key factor in the robustness of the Linux kernel, particularly in professional environments.At the same time, optimizing the memory hassle of ZRAM access is also important, as this type of compressed memory speeds up swap/system exchanges while limiting wear on SSDs or mechanical drives. This maintains smooth system performance even under heavy memory load. Introduction of swap tables for a smoother and more stable swap

Better support and performance for hibernation thanks to this structure

Reduced access time and improved system responsiveness

Improved use of compressed zRAM memory to optimize memory management These improvements come in a context of increasing Linux usage for mission-critical servers and mobile workstations, where the balance between memory access speed and kernel stability is essential. They are also part of the long list of optimizations aimed at reducing the impact of Spectre/Meltdown and similar security vulnerabilities, particularly on Zen architectures, which are still evolving according to the latest kernel updates (Meltdown Lite mitigation management). Discover how memory management works in Linux 6.18: optimization, allocation, RAM usage, and resource monitoring for increased performance.Improvements to the roles of the OOM killer and memory allocation in Rust Among the highlights of Kernel 6.18 are improvements to the

Out-Of-Memory Killer (OOM Killer), the automatic manager responsible for freeing memory when the system is in a critical situation. This essential stability component prevents the server or workstation from completely crashing due to memory exhaustion.

The developers have refined the victim process selection logic and responsiveness, thus limiting untimely terminations and improving dynamic RAM management during load peaks. The effectiveness of the OOM Killer directly impacts the kernel’s stability and service continuity under heavy load.

  • Furthermore, the rise of the Rust language in the Linux kernel is accompanied by better integration within the memory manager. Rust abstractions for Maple tree data structures have been developed to better meet the requirements of graphics drivers such as Nouveau or the Nova system. Refinements to the OOM Killer algorithms for better process selection
  • Reduction of interruptions due to unnecessary process terminations
  • Introduction of Rust abstractions in memory management and Maple trees
  • Improved support for hardware drivers via these new abstractions This contribution paves the way for more secure and robust Linux systems, facilitating the emergence of critical applications while making room for more reliable and efficient memory code. The community is closely following this major development, which is now considered a decisive step for the Linux kernel. Find a technical anecdote on this subject in this very comprehensive article on the

adoption of Rust in the kernel.https://www.youtube.com/watch?v=49hbaLuUsqcMicro-optimizations and Removal of Obsolete Layers for a Lighter Kernel

Finally, Linux 6.18 incorporates several targeted micro-optimizations that, when combined, improve the

process manager

and overall system performance. The most notable example is the removal of the Zpool indirection layer, now considered superfluous. Its removal simplifies the memory data access path, thus reducing latency and the kernel’s memory footprint. Similarly, minor tweaks have been applied to optimize page cache read operations, reducing the time required to perform large memory accesses. These optimizations, which may seem “invisible” on paper, nevertheless contribute to reducing CPU load and improving responsiveness on modern Linux systems, from embedded machines to high-performance servers. Removal of the Zpool indirection layer to streamline the kernelTargeted optimizations on critical cache read paths

Balancing of memory functions to reduce CPU footprint Consolidation of improvements for greater stability and efficiency These micro-adjustments are part of an ongoing kernel optimization process, increasingly necessary with the intensification of Linux usage in various architectures. They complement the major features mentioned above, promoting a powerful yet agile memory environment that can effectively respond to modern application workloads, particularly those requiring intensive and dynamic memory management.

This meticulous work, although less visible, is at the heart of the technical excellence expected of Linux. Learn more about the fast Linux distributions that fully benefit from these advances.

  • Learn how memory management is evolving in Linux 6.18: new features, performance optimizations, and practical tips for administrators and developers.