Skip to content

superuseryu/mglru-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MGLRU Switch

A simple Android kernel module that enables MGLRU and ensures it is properly configured on devices or ROMs that do not handle it correctly by default.

This module works by writing to standard Linux kernel MGLRU sysfs nodes:

/sys/kernel/mm/lru_gen/enabled
/sys/kernel/mm/lru_gen/min_ttl_ms

Primarily designed for modern Android kernels with MGLRU support.


Features

  • Enable MGLRU if it is disabled
  • Fix min_ttl_ms when exposed but set to 0
  • Persistent across reboots
  • Minimal, safe, and non-aggressive behavior

Requirements

  • KernelSU / KernelSU Next / SukiSU / Wild KSU
  • (Also compatible with Magisk)
  • Kernel with MGLRU support (Linux 5.15+)
  • Kernel exposes the following node:

/sys/kernel/mm/lru_gen/enabled

If the node does not exist or is locked by the kernel, the module will exit safely.


How It Works

The module follows a simple and safe logic:

  • If MGLRU is not supported, installation aborts
  • If MGLRU is disabled, the module enables it
  • If MGLRU is enabled but min_ttl_ms is 0, the module fixes it
  • If MGLRU is already properly configured, the module does nothing and only verifies at boot

The module does not add new kernel features or override vendor memory policies.


Usage

  1. Install the module via a KernelSU-compatible manager
  2. Reboot the device
  3. MGLRU will be enabled or verified automatically at boot

No user interaction is required.


Versioning

This module uses date-based versioning:

version=user-YYYY.MM.DD
versionCode=YYYYMMDD

Test builds use the test-YYYY.MM.DD format.


Notes

  • Some ROMs already enable MGLRU by default; in this case, no performance change is expected
  • Many Android kernels do not expose MGLRU stat nodes — this is normal
  • This module is intentionally minimal and avoids aggressive tuning

License

Do whatever you want.
This is just a simple, honest switch.

About

Simple module to enable MGLRU on supported kernels

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages