Home

Awesome

Enable or disable multigenerational LRU

There are simple shell scripts and oneshot systemd services to enable or disable multigenerational LRU at boot time or on the fly, and to get the current state of mg-LRU.

MGLRU Patches Merged To "mm-stable" Ahead Of Linux 6.1

Usage

Run mglru (get the current state), set_mglru N (enable/disable mg-LRU), and set_min_ttl_ms M. You can add the oneshot service to startup.

Get the current state:

$ mglru
#!/bin/sh -ev
cat /sys/kernel/mm/lru_gen/enabled
0x0007
cat /sys/kernel/mm/lru_gen/min_ttl_ms
1000

Disable multigenerational LRU:

$ set_mglru 0
#!/bin/sh -ev
echo $1 | sudo tee /sys/kernel/mm/lru_gen/enabled
0

Enable multigenerational LRU:

$ set_mglru 1
#!/bin/sh -ev
echo $1 | sudo tee /sys/kernel/mm/lru_gen/enabled
1

Apply all the multigenerational LRU features:

$ set_mglru y
#!/bin/sh -ev
echo $1 | sudo tee /sys/kernel/mm/lru_gen/enabled
y

set_mglru takes values from 0 to 7 and [yYnN] (since MGLRU v7). Most users should enable or disable all the features unless some of them have unforeseen side effects.

Set min_ttl_ms:

$ set_min_ttl_ms 2000
#!/bin/sh -v
echo $1 | sudo tee /sys/kernel/mm/lru_gen/min_ttl_ms
2000

Enable/disable multigenerational LRU during system boot:

$ sudo systemctl enable mglru.service

By default it sets /sys/kernel/mm/lru_gen/enabled to Y and /sys/kernel/mm/lru_gen/min_ttl_ms to 1000.

Edit the unit file using systemctl (to change enabled and min_ttl_ms values):

$ sudo systemctl edit mglru.service --full

Installation

Install

$ git clone https://github.com/hakavlad/mg-lru-helper.git
$ cd mg-lru-helper
$ sudo make install

Uninstall

$ sudo make uninstall

Kernels with mg-LRU

Resources

Multigenerational LRU Framework at LKML:

Multigenerational LRU Framework at LWN.net:

Multigenerational LRU Framework at phoronix:

Multigenerational LRU Framework at linux.org.ru: