Ubuntu 24.04 doesn't respect vm.swappiness

Asked by Archer Allstars

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

There’s a ton of unused swap, but my RAM is almost 100% full. I’m using zRAM. This is my main workstation (laptop).

I am running 2 Ubuntu 22.04 LTS servers with this exact setup. The experience regarding 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 is 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.

Is it only me or everyone experiencing this?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

What output do you receive for the command

cat /proc/sys/vm/swappiness

Does the output of that command change when you set different values with a command like

sudo sysctl vm.swappiness=80

According to https://help.ubuntu.com/community/SwapFaq#What_is_swappiness_and_how_do_I_change_it.3F
"swappiness can have a value of between 0 and 100"

Other web pages tell about different valid values for vm.swappiness, I do not know what the real limits are.

Revision history for this message
Archer Allstars (archerallstars) said :
#2

> What output do you receive for the command
>
> cat /proc/sys/vm/swappiness

180

> Does the output of that command change when you set different values with a command like
>
> sudo sysctl vm.swappiness=80

Yes, `cat /proc/sys/vm/swappiness` changes to the provided value.

> According to https://help.ubuntu.com/community/SwapFaq#What_is_swappiness_and_how_do_I_change_it.3F
"swappiness can have a value of between 0 and 100"

This is incorrect. According to the official kernel doc: https://docs.kernel.org/admin-guide/sysctl/vm.html#swappiness , the value is between 0 and 200.

The value I am using is the default value for zRAM on Pop!_OS: https://github.com/pop-os/default-settings/pull/163

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

My next idea for trying to find the root cause is testing, whether this is dependent on the Ubuntu release, or on the kernel version.

Can you help with this problem?

Provide an answer of your own, or ask Archer Allstars for more information if necessary.

To post a message you must log in.