With MGLRU and zRAM providing a safety net, enabling Large Page (2MB) support reduces TLB misses, allowing the CPU to prioritize emulation logic over memory address translation.
Key Features Enabled
File-System THP (CONFIG_READ_ONLY_THP_FOR_FS): Collapses read-only file mappings (game binaries/data) into huge pages to accelerate asset loading.
Contiguous Page Table Entries (CONFIG_ARM64_CONTPTE): Allows the MMU to treat groups of pages as a single entry, increasing TLB efficiency on high-performance targets.
Memory Compaction & Migration: Re-enabled infrastructure to shuffle physical RAM into contiguous blocks required for huge pages.
Architecture-Specific Write Support (CONFIG_ARCH_WANT_PMD_MKWRITE): Ensures efficient huge page handling during high-performance memory writes.
Tiered Userspace Management
The rocknix-memory-manager applies specific logic at boot based on the SoC and RAM capacity:
Flagship Mode (RK3588, SM8x, RK3399):
Sets defrag to defer+madvise for proactive huge page creation.
Sets vm.compaction_proactiveness to 40 to maintain a pool of contiguous blocks.
Budget Mode (H700, RK3326):
Sets defrag to defer only to prevent CPU "stalls" during gameplay.
Sets vm.compaction_proactiveness to 10 to prioritize raw CPU availability.
Texture Performance: Globally enables shmem_enabled=advise to benefit Vulkan and Wayland texture handling.
Swappiness: Sets vm.swappiness to 100 when ZRAM is active to keep physical RAM unfragmented for huge page allocations.
Safety Rationale
MGLRU: Prevents "reclaim storms" during huge page allocation on 1GB devices.
zRAM: Absorbs memory pressure via high-speed compressed swap.
Read-Only Focus: FS-Backed THP targets low-risk mappings while providing high-impact gains for asset streaming.
This commit enables Multi-Gen LRU (CONFIG_LRU_GEN) across supported target kernels. MGLRU replaces the kernel's traditional page reclamation logic with a more efficient multi-generational approach.
This is highly beneficial for memory-constrained ARM SoCs, as it provides better heuristics for identifying "hot" vs "cold" pages, significantly reducing unnecessary I/O and micro-stutters under memory pressure.
Technical Implementation:
Enables CONFIG_LRU_GEN and CONFIG_LRU_GEN_ENABLED.
Targeted at devices running Kernel 6.1 or newer.
Specifically excluded is SDM845 kernels (5.18 kernel).
Initialization and First-Boot Behavior:
Note: Users may observe transient "task wait" messages or increased CPU overhead during the initial boot of a fresh installation. This is a byproduct of MGLRU's generation-tracking heuristics during high-churn operations (such as filesystem expansion and initial cache generation). The scheduler overhead for generation updates stabilizes once the primary working set is established and the initial I/O burst subsides.
Note: CONFIG_LRU_GEN_WALKS_MMU=y is enabled but some targets (RK3588)
are still running with kernel symbols where this is Rolled up into the
CONFIG_LRU_GEN still - I haved aligned it here per request but it will
get silently dropped by next oldconfig run until such time the RK3588 is
updated to a version that unrolls the symbol.