How do you properly set kernel configuration parameter (MGLRU)

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
postcd
Posts: 163
Joined: 2022-01-08 18:33
Has thanked: 61 times
Been thanked: 3 times

How do you properly set kernel configuration parameter (MGLRU)

#1 Post by postcd »

I would like to set(enable) kernel configuration parameter MGLRU:

https://dev.to/archerallstars/enable-th ... -today-ji6
https://docs.kernel.org/admin-guide/mm/ ... n_lru.html
https://github.com/hakavlad/mg-lru-help ... /README.md

It seems to be included in Kernel but not enabled (and its "stats"):
grep -Ria CONFIG_LRU_GEN /boot
Off Topic
/boot/config-6.1.0-27-amd64:CONFIG_LRU_GEN=y
/boot/config-6.1.0-27-amd64:# CONFIG_LRU_GEN_ENABLED is not set
/boot/config-6.1.0-27-amd64:# CONFIG_LRU_GEN_STATS is not set
/boot/config-6.1.0-26-amd64:CONFIG_LRU_GEN=y
/boot/config-6.1.0-26-amd64:# CONFIG_LRU_GEN_ENABLED is not set
/boot/config-6.1.0-26-amd64:# CONFIG_LRU_GEN_STATS is not set
I have read that to enable it, best way is not to edit /boot/default/grub, but create new file in a /etc/grub.d/

So I did it (possibly wrong) like this:

echo 'GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} mglru.enabled=1"'|sudo tee /etc/default/grub.d/mglru.cfg && sudo update-grub
Off Topic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.1.0-27-amd64
Found initrd image: /boot/initrd.img-6.1.0-27-amd64
Found linux image: /boot/vmlinuz-6.1.0-26-amd64
Found initrd image: /boot/initrd.img-6.1.0-26-amd64
Found linux image: /boot/vmlinuz-6.1.0-27-amd64
Found initrd image: /boot/initrd.img-6.1.0-27-amd64
Found linux image: /boot/vmlinuz-6.1.0-26-amd64
Found initrd image: /boot/initrd.img-6.1.0-26-amd64
Adding boot menu entry for UEFI Firmware Settings ...
done
Yet it is enabled only in one older kernel: grep vmlinu /boot/grub/grub.cfg
Off Topic
linux /vmlinuz-6.1.0-27-amd64 root=/dev/mapper/hn--vg-root ro quiet
linux /vmlinuz-6.1.0-27-amd64 root=/dev/mapper/hn--vg-root ro single
linux /vmlinuz-6.1.0-26-amd64 root=/dev/mapper/hn--vg-root ro quiet mglru.enabled=1
linux /vmlinuz-6.1.0-26-amd64 root=/dev/mapper/hn--vg-root ro single
linux /vmlinuz-5.10.0-20-amd64 root=/dev/mapper/hn--vg-root ro quiet
I have tried to add varieties:
Off Topic
${GRUB_CMDLINE_LINUX_DEFAULT} mglru.enabled=1
$GRUB_CMDLINE_LINUX_DEFAULT mglru.enabled=1
mglru.enabled=1
so what to try to enable it at boot? It is possible that mglru.enabled does not exist since it is supplied by AI and I am doing it wrong.

This seems to enable it at least for the session during runtime:
echo y|sudo tee /sys/kernel/mm/lru_gen/enabled
y
cat /sys/kernel/mm/lru_gen/enabled
0x0007

User avatar
wizard10000
Global Moderator
Global Moderator
Posts: 1084
Joined: 2019-04-16 23:15
Location: southeastern us
Has thanked: 117 times
Been thanked: 189 times

Re: How do you properly set kernel configuration parameter (MGLRU)

#2 Post by wizard10000 »

Not sure if grub is the issue but I personally use the second option, editing /etc/default/grub and just editing GRUB_CMDLINE_LINUX_DEFAULT. All you'd need to do is

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mglru.enabled=1"
and then update grub.

No idea if the second option would work any better than the first but might be worth a shot. If you decide to give it a try I'd remove that file you put in /etc/grub.d before I updated grub.

If you can set it at runtime maybe a quick and dirty systemd unit to ensure it's set?

Good luck -
we see things not as they are, but as we are.
-- anais nin

CwF
Global Moderator
Global Moderator
Posts: 3073
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 63 times
Been thanked: 254 times

Re: How do you properly set kernel configuration parameter (MGLRU)

#3 Post by CwF »

Grub configuration is really to enable selectable parameters from a list, for that boot. Try to put it in a modprobe conf file and then update-initramfs, I'm not sure of the syntax, but...check the journal for any objection.
create file /etc/modprobe.d/mglru.conf
mglru.enabled=1
Mottainai

postcd
Posts: 163
Joined: 2022-01-08 18:33
Has thanked: 61 times
Been thanked: 3 times

Re: How do you properly set kernel configuration parameter (MGLRU)

#4 Post by postcd »

@wizard10000 removing mine created files from grub.d/ and adjusting /etc/default/grub file still updates only that older kernel *-26.

@CwF I have tried that:
Off Topic
$ echo 'options mglru enabled=1'|sudo tee /etc/modprobe.d/mglru.conf && sudo modprobe -r mglru
options mglru enabled=1
modprobe: FATAL: Module mglru not found.
Using "mglru.enabled=1" instead in that file causes modprobe to return: "ignoring bad line starting with 'mglru.enabled=1'"

But adding "mglru.enabled=1" into /etc/default/grub GRUB_CMDLINE_LINUX instead of GRUB_CMDLINE_LINUX_DEFAULT, resulted in:
Off Topic
$ grep vmlinu /boot/grub/grub.cfg
linux /vmlinuz-6.1.0-27-amd64 root=/dev/mapper/hn--vg-root ro quiet
linux /vmlinuz-6.1.0-27-amd64 root=/dev/mapper/hn--vg-root ro single mglru.enabled=1
linux /vmlinuz-6.1.0-26-amd64 root=/dev/mapper/hn--vg-root ro mglru.enabled=1 quiet
linux /vmlinuz-6.1.0-26-amd64 root=/dev/mapper/hn--vg-root ro single mglru.enabled=1
linux /vmlinuz-5.10.0-20-amd64 root=/dev/mapper/hn--vg-root ro quiet
when I check the context of that lines, then the first line, where mglru is missing, is the currently used latest kernel which i want to use mglru on. Maybe Grub-Customizer interfere, i am NOT running it, but when i run it, it shows first and last entry as "script: custom" and others as "script: linux"). Other option is to enable the MGLRU using systemd service:
Off Topic
$ sudo wget -q https://pastebin.com/raw/ADq1GETU -O /etc/systemd/system/mglru.service && sudo systemctl daemon-reload && sudo systemctl enable mglru && systemctl start mglru
Verify it is running:
Off Topic
$ cat /sys/kernel/mm/lru_gen/enabled; echo "This should have returned 0x0007. If it returned 0x0000, this means it's not enabled yet"`
$ cat /sys/kernel/mm/lru_gen/min_ttl_ms; echo "This should have returned 1000 for the optimal thrashing prevention."
$ sudo journalctl -kg lru && cat /proc/mglru # no output here :-|

User avatar
sunrat
Site admin
Site admin
Posts: 7365
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 133 times
Been thanked: 649 times

Re: How do you properly set kernel configuration parameter (MGLRU)

#5 Post by sunrat »

Why are you using Off Topic tags for code? We have code tags for that purpose.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1529
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 106 times
Been thanked: 255 times

Re: How do you properly set kernel configuration parameter (MGLRU)

#6 Post by steve_v »

postcd wrote: 2024-11-12 19:22 Maybe Grub-Customizer interfere, i am NOT running it, but when i run it, it shows first and last entry as "script: custom" and others as "script: linux").
Probably. Using grub-customizer at all is well known for lousing up grub configuration, because it redirects and/or replaces a bunch of standard generator scripts in /etc/grub.d/. I personally consider it both completely superfluous and far too broken to even be in the repos, but there it is.

Step-one, test that your kernel command-line works by adding it manually at the GRUB prompt ('e' to edit selected entry before boot, followed by F10 to confirm and boot).
Then make it permanent in your (assuming it's not already mangled by grub-custosodomizer) grub-mkconfig configuration file(s).

Anything in GRUB_CMDLINE_LINUX should be added to the kernel command-line for all entries.
Anything in GRUB_CMDLINE_LINUX_DEFAULT should be added to the kernel command-line for all entries except the autogenerated "recovery" options.
Anything in GRUB_CMDLINE_LINUX_RECOVERY should be added to the kernel command-line for only the "recovery" options.

Those variables are read by grub-mkconfig, which on Debian and co. is best called by update-grub. It doesn't matter whether you set them in /etc/default/grub or in separate files, but you will need to pay attention to evaluation order if you are using both and want them concatenated.

Alternatively, forget about GRUB and just set the desired options in /sys/kernel/mm/lru_gen/ using your preferred method (soystemd, rc.local, cron, etc.) for executing commands at boot.


More generally, I suggest you read the documentation rather than using "supplied by AI", copy-pasting commands from random websites, or executing scripts from random pastebins... especially as root.


As for /etc/modprobe.whatever, that's totally irrelevant because according to your kernel config mglru is not built as a loadable module.
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

Post Reply