I can't switch to sysctl vm.swappiness=10

i set a kernel parameter : sysctl vm.swappiness=10 and followed the archwiki guide

System:
  Kernel: 6.6.8-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 13.2.1 clocksource: tsc
    available: acpi_pm parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=b6b92ddd-1165-4684-927f-b9ae66d45eff rw rootflags=subvol=@ quiet
    rd.udev.log_priority=3 vt.global_cursor_default=0 loglevel=3 mitigations=off
    sysrq_always_enabled=1 elevator=noop sysctl.vm.swappiness=10 ibt=off
  Desktop: GNOME v: 45.2 tk: GTK v: 3.24.39 wm: gnome-shell dm: GDM v: 45.0.1
    Distro: Garuda Linux base: Arch Linux
Machine:
  Type: Laptop System: ASUSTeK product: X540LA v: 1.0 serial: <superuser required>
  Mobo: ASUSTeK model: X540LA v: 1.0 serial: <superuser required> UEFI: American Megatrends
    v: X540LA.303 date: 08/31/2018
Battery:
  ID-1: BAT0 charge: 17.6 Wh (78.6%) condition: 22.4/33.2 Wh (67.6%) power: 12.3 W volts: 10.8
    min: 10.8 model: ASUSTeK ASUS Battery type: Li-ion serial: N/A status: discharging cycles: 747
CPU:
  Info: model: Intel Core i3-5005U bits: 64 type: MT MCP arch: Broadwell gen: core 5 level: v3
    note: check built: 2015-18 process: Intel 14nm family: 6 model-id: 0x3D (61) stepping: 4
    microcode: 0x2F
  Topology: cpus: 1x cores: 2 tpc: 2 threads: 4 smt: enabled cache: L1: 128 KiB
    desc: d-2x32 KiB; i-2x32 KiB L2: 512 KiB desc: 2x256 KiB L3: 3 MiB desc: 1x3 MiB
  Speed (MHz): avg: 1896 high: 1897 min/max: 500/1900 scaling: driver: intel_cpufreq
    governor: performance cores: 1: 1896 2: 1897 3: 1896 4: 1896 bogomips: 15962
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities: <filter>
Graphics:
  Device-1: Intel HD Graphics 5500 vendor: ASUSTeK driver: i915 v: kernel arch: Gen-8
    process: Intel 14nm built: 2014-15 ports: active: DP-1 off: eDP-1 empty: HDMI-A-1 bus-ID: 00:02.0
    chip-ID: 8086:1616 class-ID: 0300
  Device-2: IMC Networks USB2.0 VGA UVC WebCam driver: uvcvideo type: USB rev: 2.0
    speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-5:4 chip-ID: 13d3:5a11 class-ID: 0e02
  Display: wayland server: X.org v: 1.21.1.10 with: Xwayland v: 23.2.3 compositor: gnome-shell
    driver: X: loaded: intel unloaded: modesetting alternate: fbdev,vesa dri: i965 gpu: i915
    display-ID: 0
  Monitor-1: DP-1 model: Samsung SyncMaster serial: <filter> built: 2009 res: 1600x900 dpi: 92
    gamma: 1.2 size: 443x249mm (17.44x9.8") diag: 508mm (20") ratio: 16:9 modes: max: 1600x900
    min: 720x400
  Monitor-2: eDP-1 model: ChiMei InnoLux 0x15dc built: 2015 res: 1366x768 dpi: 101 gamma: 1.2
    size: 344x193mm (13.54x7.6") diag: 394mm (15.5") ratio: 16:9 modes: 1366x768
  API: EGL v: 1.5 hw: drv: intel iris platforms: device: 0 drv: iris device: 1 drv: swrast
    surfaceless: drv: iris wayland: drv: iris x11: drv: iris inactive: gbm
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 23.3.1-arch1.1 glx-v: 1.4
    direct-render: yes renderer: Mesa Intel HD Graphics 5500 (BDW GT2) device-ID: 8086:1616
    memory: 7.47 GiB unified: yes display-ID: :0.0
Audio:
  Device-1: Intel Broadwell-U Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel bus-ID: 00:03.0
    chip-ID: 8086:160c class-ID: 0403
  Device-2: Intel Wildcat Point-LP High Definition Audio vendor: ASUSTeK driver: snd_hda_intel
    v: kernel bus-ID: 00:1b.0 chip-ID: 8086:9ca0 class-ID: 0403
  API: ALSA v: k6.6.8-zen1-1-zen status: kernel-api tools: N/A
  Server-1: PipeWire v: 1.0.0 status: active with: 1: pipewire-pulse status: active
    2: wireplumber status: active 3: pipewire-alsa type: plugin 4: pw-jack type: plugin
    tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Realtek RTL810xE PCI Express Fast Ethernet vendor: ASUSTeK driver: r8169 v: kernel
    pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: 4000 bus-ID: 02:00.2 chip-ID: 10ec:8136
    class-ID: 0200
  IF: enp2s0f2 state: down mac: <filter>
  Device-2: Realtek RTL8723BE PCIe Wireless Network Adapter vendor: Lite-On driver: rtl8723be
    v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: 3000 bus-ID: 03:00.0 chip-ID: 10ec:b723
    class-ID: 0280
  IF: wlp3s0 state: up mac: <filter>
Bluetooth:
  Device-1: Realtek Bluetooth Radio d
river: btusb v: 0.8 type: USB rev: 2.1 speed: 12 Mb/s lanes: 1
    mode: 1.1 bus-ID: 1-4:3 chip-ID: 0bda:b721 class-ID: e001 serial: <filter>
  Report: btmgmt ID: hci0 rfk-id: 0 state: up address: <filter> bt-v: 4.0 lmp-v: 6 status:
    discoverable: no pairing: no class-ID: 1c010c
Drives:
  Local Storage: total: 704.24 GiB used: 585.11 GiB (83.1%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/sda maj-min: 8:0 vendor: TeamGroup model: T253256GB size: 238.47 GiB block-size:
    physical: 512 B logical: 512 B speed: 6.0 Gb/s tech: SSD serial: <filter> fw-rev: 227N
    scheme: GPT
  ID-2: /dev/sdb maj-min: 8:16 vendor: Western Digital model: WD5000LPCX-80VHAT1 size: 465.76 GiB
    block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s tech: HDD rpm: 5400 serial: <filter>
    fw-rev: 1A02 scheme: GPT
Partition:
  ID-1: / raw-size: 24.91 GiB size: 24.91 GiB (100.00%) used: 8.6 GiB (34.5%) fs: btrfs
    dev: /dev/sda1 maj-min: 8:1
  ID-2: /boot/efi raw-size: 512 MiB size: 511 MiB (99.80%) used: 584 KiB (0.1%) fs: vfat
    dev: /dev/sda4 maj-min: 8:4
  ID-3: /home raw-size: 9.8 GiB size: 9.8 GiB (100.00%) used: 3.93 GiB (40.1%) fs: btrfs
    dev: /dev/sda2 maj-min: 8:2
  ID-4: /var/log raw-size: 24.91 GiB size: 24.91 GiB (100.00%) used: 8.6 GiB (34.5%) fs: btrfs
    dev: /dev/sda1 maj-min: 8:1
  ID-5: /var/tmp raw-size: 24.91 GiB size: 24.91 GiB (100.00%) used: 8.6 GiB (34.5%) fs: btrfs
    dev: /dev/sda1 maj-min: 8:1
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 50 (default 100) zswap: no
  ID-1: swap-1 type: zram size: 7.65 GiB used: 0 KiB (0.0%) priority: 100 comp: zstd
    avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 4 dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 44.0 C pch: 38.0 C mobo: N/A
  Fan Speeds (rpm): cpu: 1900
Info:
  Processes: 277 Uptime: 2m wakeups: 0 Memory: total: 8 GiB available: 7.65 GiB
  used: 2.71 GiB (35.4%) Init: systemd v: 255 default: graphical tool: systemctl Compilers:
  gcc: 13.2.1 Packages: 1165 pm: pacman pkgs: 1146 libs: 287 tools: pamac,paru pm: flatpak pkgs: 19
  Client: shell wrapper v: 5.2.21-release inxi: 3.3.31
Garuda (2.6.22-1):
  System install date:     2023-11-27
  Last full system update: 2023-12-26
  Is partially upgraded:   No
  Relevant software:       snapper NetworkManager dracut
  Windows dual boot:       No/Undetected
  Failed units:            

Where did you stick the sysctl.conf file?

2 Likes

This isn’t enough information for anyone to be able to see if there is an error or misconfiguration somewhere. At the very least, link to the doc you followed and outline the steps you have done so for.

What is the expected result? What are you seeing instead?

Do you understand what changing the swappiness value does? I am asking because there is a lot of misinformation about swappiness.

TL;DR: swappiness does not change the threshold at which your system will start using swap, it changes how aggressively the kernel prefers to swap out pages from physical RAM to the swap space.

3 Likes

okay , this is the sysctl output

sysctl vm.swappiness                                                                                ░▒▓ ✔ ▓▒░
vm.swappiness = 133

I set the swapiness value permenantly following this guide in the archwiki https://wiki.archlinux.org/title/Swap

I did

sudo micro /etc/sysctl.d/99-swappiness.conf vm.swappiness = 10
I did create that file :
my output of sudo micro /etc/sysctl.d/99-swappiness.conf :

vm.swappiness = 10
vm.vfs_cache_pressure=50

and set the sysctl vm.swapiness=10 as a kernel parameter like it’s showing in my garuda-inxi.

I understand what swapiness means.

Your only swap device is zram, which has it’s swappiness set in /usr/lib/sysctl.d/99-sysctl-garuda.conf. If you want to change the swappiness of your zram device you can change it there.


Reducing the swappiness of your zram device will most likely reduce your system performance. I’m not sure what you are actually trying to do, but if you are attempting to spare some writes to the disk you should be aware that zram does not use the hard drive, it uses RAM. So you may be sacrificing performance for no benefit.

Testing suggests a higher swappiness value gives better performance on a system using zram.

zram - ArchWiki

Optimizing swap on zram

Since zram behaves differently than disk swap, we can configure the system’s swap to take full potential of the zram advantages:

/etc/sysctl.d/99-vm-zram-parameters.conf
vm.swappiness = 180 
vm.watermark_boost_factor = 0 
vm.watermark_scale_factor = 125 
vm.page-cluster = 0

Explanation of the configuration:

These values are what Pop!_OS uses. That Pop!_OS GitHub PR also links to some testing done by users on r/Fedora, which determined that vm.page-cluster = 0 is ideal. They also found a high swappiness value to be ideal, which matches what is suggested by the kernel docs:

“The default value is 60. For in-memory swap, like zram or zswap, as well as hybrid setups that have swap on faster devices than the filesystem, values beyond 100 can be considered. For example, if the random IO against the swap device is on average 2x faster than IO from the filesystem, swappiness should be 133 (x + 2x = 200, 2x = 133.33).”

On a system with a hard drive, random IO against the zswap device would be orders of magnitude faster than IO against the filesystem, so swappiness should be ~200. Even on a system with a fast SSD, a high swappiness value may be ideal.

2 Likes

I understand now thank you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.