Ubuntu 24.04 doesn't respect vm.swappiness

Bug #2064483 reported by Archer Allstars
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
New
Undecided
Unassigned
Noble
New
Undecided
Unassigned

Bug Description

My sysctl vm.swappiness returns vm.swappiness = 180.

Swap kicked in when RAM is filled around 95%. I’m using zRAM as the swap.

When this happened, my laptop is barely usable, as the system would have to do both the swap and compression at the same time. If `vm.swappiness = 180` worked as intended, the issue wouldn't have happened, as the swap would kick in early, which is good for zRAM system like mine, see kernel docs: https://docs.kernel.org/admin-guide/sysctl/vm.html#swappiness

This is my main workstation (laptop). I used to run openSUSE Tumbleweed on it (~2 years). The experience with `vm.swappiness` is totally different.

---

Here's my zRAM script:

```
#!/bin/bash

mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')
mem_total=$((mem_total_kb * 1536))

modprobe zram

echo zstd > /sys/block/zram0/comp_algorithm;
echo $mem_total > /sys/block/zram0/disksize

mkswap /dev/zram0

swapon -p 100 /dev/zram0

```

Here's the content of my /etc/sysctl.conf

```
vm.swappiness=180
vm.page-cluster=0
vm.watermark_scaling_factor=125
vm.watermark_boost_factor=0
```

I make a fresh install, not upgrading from the previous release.

I also upload the screen recording of this issue on my personal Proton drive here:

https://drive.proton.me/urls/5KTCS1DF58#qZTscuv5XE0M

I mount ~/ramtest in the RAM, then copy the system's usr folder to ~/ramtest. Since most contents in usr are compressible, it should be perfect to show this issue.
---
ProblemType: Bug
ApportVersion: 2.28.1-0ubuntu2
Architecture: amd64
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/seq: archerallstars 4444 F.... pipewire
 /dev/snd/controlC0: archerallstars 4448 F.... wireplumber
CRDA: N/A
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
DistroRelease: Ubuntu 24.04
InstallationDate: Installed on 2024-04-27 (5 days ago)
InstallationMedia: Ubuntu 24.04 LTS "Noble Numbat" - Release amd64 (20240424)
MachineType: Acer Swift SF514-52T
NonfreeKernelModules: zfs
Package: linux (not installed)
ProcFB: 0 i915drmfb
ProcKernelCmdLine: BOOT_IMAGE=/BOOT/ubuntu_o799y4@/vmlinuz-6.8.0-31-generic root=ZFS=rpool/ROOT/ubuntu_o799y4 ro quiet splash vt.handoff=1
ProcVersionSignature: Ubuntu 6.8.0-31.31-generic 6.8.1
PulseList: Error: command ['pacmd', 'list'] failed with exit code 1: No PulseAudio daemon running, or not running as session daemon.
RelatedPackageVersions:
 linux-restricted-modules-6.8.0-31-generic N/A
 linux-backports-modules-6.8.0-31-generic N/A
 linux-firmware 20240318.git3b128b60-0ubuntu2
Tags: noble wayland-session
Uname: Linux 6.8.0-31-generic x86_64
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm cdrom dip libvirt lpadmin plugdev sudo users
_MarkForUpload: True
dmi.bios.date: 11/26/2018
dmi.bios.release: 1.11
dmi.bios.vendor: Insyde Corp.
dmi.bios.version: V1.11
dmi.board.name: Carlsberg_KL
dmi.board.vendor: KBL
dmi.board.version: V1.11
dmi.chassis.type: 10
dmi.chassis.vendor: Acer
dmi.chassis.version: V1.11
dmi.ec.firmware.release: 1.5
dmi.modalias: dmi:bvnInsydeCorp.:bvrV1.11:bd11/26/2018:br1.11:efr1.5:svnAcer:pnSwiftSF514-52T:pvrV1.11:rvnKBL:rnCarlsberg_KL:rvrV1.11:cvnAcer:ct10:cvrV1.11:sku0000000000000000:
dmi.product.family: Swift 5
dmi.product.name: Swift SF514-52T
dmi.product.sku: 0000000000000000
dmi.product.version: V1.11
dmi.sys.vendor: Acer
modified.conffile..etc.default.apport:
 # set this to 0 to disable apport, or to 1 to enable it
 # you can temporarily override this with
 # sudo service apport start force_start=1
 enabled=0
mtime.conffile..etc.default.apport: 2024-04-27T05:52:33.862578

Revision history for this message
Archer Allstars (archerallstars) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Libera.chat.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/2064483/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Revision history for this message
Archer Allstars (archerallstars) wrote :

I add a test on Tumbleweed in KVM with vm.swappiness=180.

The result is as expected, it's not broken in Tumbleweed. With vm.swappiness=180 the swap kicked in at around 55% of RAM filled, not 95%. And it will maintain this free space percentage, depending on the compression ratio of the data that's being swapped.

Revision history for this message
Archer Allstars (archerallstars) wrote :

To make sure that vm.swappiness is really contribute to the tendency to swap of the kernel as documented, I also did a test on Tumbleweed with vm.swappiness=60, which is the default value.

The test result is as expected, the swap kicked in late compared to vm.swappiness=180. And not only that, the system doesn't try to maintain the free space in RAM.

Revision history for this message
Archer Allstars (archerallstars) wrote :

I have done the test with free -m outputs with vm.swappiness=180 on Ubuntu 24.04.

Revision history for this message
Archer Allstars (archerallstars) wrote :

I have done the test with free -m outputs with vm.swappiness=180 on Tumbleweed.

no longer affects: ubuntu
no longer affects: Ubuntu Noble
Revision history for this message
Archer Allstars (archerallstars) wrote : AlsaInfo.txt

apport information

tags: added: apport-collected noble wayland-session
description: updated
Revision history for this message
Archer Allstars (archerallstars) wrote : CurrentDmesg.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : IwConfig.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : Lspci.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : Lspci-vt.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : Lsusb.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : Lsusb-t.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : Lsusb-v.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : PaInfo.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : ProcCpuinfo.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : ProcCpuinfoMinimal.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : ProcEnviron.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : ProcInterrupts.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : ProcModules.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : RfKill.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : UdevDb.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : WifiSyslog.txt

apport information

Revision history for this message
Archer Allstars (archerallstars) wrote : acpidump.txt

apport information

To post a comment you must log in.