AlmaLinux vm.swappiness has almost no effect - does it support vm.force_cgroupv2_swappiness?

Since I installed AlmaLinux, many months ago, that I’ve been having trouble with swap being used when there is plenty of RAM available still (the available field in free -m).

I’ve always used vm.swappiness=1, and I’ve tested vm.swappiness=0 more recently. Changing to 0 didn’t seem to alter the tendency at all.

This goes against pretty much every Q&A I read every time I investigate about this issue, as the value of 1 or 0 really should be doing what I’m expecting it to do.

At last, I’ve finally found this RHEL support question: RHEL 8: Premature swapping with swappiness=0 while there is still plenty of pagecache to be reclaimed.

It mentions about Cgroups and how they get the default swappiness value of 60 if they start before sysctl tunes the system, which is the case for systemd.

I confirm most/all values of memory.swappiness are 60.

# find /sys/fs/cgroup/memory/ -name memory.swappiness -exec cat {} \; | uniq -c
      8 1
      1 0
    192 60

The resolution given there is either create some script at boot that changes all memory.swappiness files to the desired value, or to upgrade to CgroupV2, which likely requires a good amount of testing and I don’t have capacity right now to test that support against all the software I use.

However, I’ve also just found this RHEL support question: System’s swappiness value is not honored with cgroups v1

This suggests to simply add this value: vm.force_cgroupv2_swappiness=1

If you don’t use/need the per-cgroup swappiness value we have introduced a method of switching to the cgroupV2 behavior (which does not contain the per-cgroup swappiness).
echo 1 > /proc/sys/vm/force_cgroupv2_swappiness

But, Google gives me no results for that parameter, at all, and the question is from “October 10 2022”, so I’m wondering if AlmaLinux supports this parameter.

Actually, searching DuckDuckGo, it brings me to this page: RHEL 8.7 Release Notes, where they introduced this parameter.

Does that mean that AlmaLinux 8.7 will have included that parameter too?

Red Hat adds features to RHEL kernel source. Alma builds from those same sources. So: yes.

1 Like

already answered this on reddit 3 days ago

Yeah, but only today this post was approved :slight_smile:

1 Like