Skip to content

[6.18] Memory Management & Responsiveness Patches#45

Draft
kakra wants to merge 2 commits intobase-6.18from
rebase-6.18/memory
Draft

[6.18] Memory Management & Responsiveness Patches#45
kakra wants to merge 2 commits intobase-6.18from
rebase-6.18/memory

Conversation

@kakra
Copy link
Copy Markdown
Owner

@kakra kakra commented May 7, 2026

Memory Management & Responsiveness Patches

This patch set focuses on improving system responsiveness under high memory pressure by implementing "Working Set Protection". These patches are based on the le9uo patch set, adapted for the modern mgLRU framework.

Patches Included

Description

  • Motivation: This patch set is particularly useful for desktop workloads like gaming and software development, where heavy background tasks (e.g., backups, compilations like Gentoo emerges) can run alongside the primary application. The stock Linux kernel sometimes tries too hard to keep all processes alive in these high-memory-pressure situations. This can lead to long system stalls (thrashing or live-locking) where the entire desktop becomes unresponsive, making it impossible to even switch tasks or kill the offending process.

  • Function: This patch set introduces "Working Set Protection" (le9uo), which protects the memory of actively used applications (the "working set") from being swapped out. This is achieved by preserving a certain amount of the page cache even during physical memory exhaustion.

    As a consequence, the Out-of-Memory (OOM) killer intervenes earlier and more decisively when memory pressure becomes critical. Instead of trying to swap endlessly and causing stalls, the kernel immediately invokes the OOM Killer to terminate a process and recover from the critical situation.

  • Benefits: The feature significantly mitigates performance and stability issues caused by severe memory pressure in key scenarios:

    • During Memory Exhaustion: By preserving a portion of the page cache, the system avoids excessive page faults, leading to massive improvements in I/O performance under memory pressure and maintaining system responsiveness.
    • Near OOM-Conditions: The immediate OOM Killer invocation prevents the system from thrashing or stalling. Recovery can be almost instantaneous, often before a user even notices an issue. This is a stark contrast to the vanilla kernel, which can become extremely slow or unresponsive.
    • After OOM-Conditions: The system remains smooth and responsive immediately after an OOM event, because the protected page cache doesn't need to be reloaded from slow storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants