Swap & what am I doing wrong?

Sometimes (no discerning pattern) the memory swap starts and everything grinds to a halt. It just happened again earlier this morning.

The memory used was 1.8GB (I have 12GB RAM) and the swap was 600MB. I was just running my usual programs. (I should have run inxi before rebooting)

What can I do to stop the swap unless it gets to 2/3 of the available ram?

$ cat /sys/fs/cgroup/memory/memory.swappiness
10

$ inxi -Fxxxz
System:    Host: ethelbert Kernel: 5.4.52-1-MANJARO x86_64 bits: 64 compiler: gcc v: 10.1.0 
           Desktop: KDE Plasma 5.19.3 tk: Qt 5.15.0 wm: kwin_x11 dm: SDDM 
           Distro: Manjaro Linux 
Machine:   Type: Desktop Mobo: MSI model: 970A-G46 (MS-7693) v: 2.0 serial: <filter> 
           BIOS: American Megatrends v: 2.8 date: 01/08/2016 
CPU:       Topology: 8-Core model: AMD FX-8350 bits: 64 type: MCP arch: Bulldozer 
           L2 cache: 2048 KiB 
           flags: avx lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 64033 
           Speed: 3342 MHz min/max: 1400/4000 MHz boost: enabled Core speeds (MHz): 1: 3342 
           2: 1779 3: 2637 4: 3013 5: 2888 6: 2957 7: 2657 8: 3038 
Graphics:  Device-1: AMD Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] 
           vendor: Micro-Star MSI driver: amdgpu v: kernel bus ID: 01:00.0 
           chip ID: 1002:67df 
           Display: x11 server: X.Org 1.20.8 driver: amdgpu unloaded: modesetting 
           alternate: ati,fbdev,vesa compositor: kwin_x11 resolution: 1920x1080~60Hz 
           OpenGL: 
           renderer: Radeon RX 570 Series (POLARIS10 DRM 3.35.0 5.4.52-1-MANJARO LLVM 10.0.0) 
           v: 4.6 Mesa 20.1.3 direct render: Yes 
Audio:     Device-1: AMD SBx00 Azalia vendor: Micro-Star MSI driver: snd_hda_intel v: kernel 
           bus ID: 00:14.2 chip ID: 1002:4383 
           Device-2: AMD Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] 
           vendor: Micro-Star MSI driver: snd_hda_intel v: kernel bus ID: 01:00.1 
           chip ID: 1002:aaf0 
           Sound Server: ALSA v: k5.4.52-1-MANJARO 
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
           vendor: Micro-Star MSI driver: r8169 v: kernel port: d000 bus ID: 04:00.0 
           chip ID: 10ec:8168 
           IF: enp4s0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
Drives:    Local Storage: total: 5.46 TiB used: 2.09 TiB (38.4%) 
           ID-1: /dev/sda vendor: Western Digital model: WD30EFRX-68EUZN0 size: 2.73 TiB 
           speed: 6.0 Gb/s rotation: 5400 rpm serial: <filter> rev: 0A82 scheme: GPT 
           ID-2: /dev/sdb vendor: Western Digital model: WD30EFRX-68EUZN0 size: 2.73 TiB 
           speed: 6.0 Gb/s rotation: 5400 rpm serial: <filter> rev: 0A82 scheme: GPT 
Partition: ID-1: / size: 491.15 GiB used: 29.70 GiB (6.0%) fs: ext4 dev: /dev/sda2 
           ID-2: /boot size: 999.7 MiB used: 98.5 MiB (9.9%) fs: vfat dev: /dev/sda1 
           ID-3: /home size: 2.19 TiB used: 534.43 GiB (23.8%) fs: ext4 dev: /dev/sda3 
           ID-4: swap-1 size: 13.67 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sda4 
Sensors:   System Temperatures: cpu: 27.4 C mobo: N/A gpu: amdgpu temp: 35 C 
           Fan Speeds (RPM): N/A gpu: amdgpu fan: 998 
Info:      Processes: 243 Uptime: 4m Memory: 11.65 GiB used: 2.23 GiB (19.2%) Init: systemd 
           v: 245 Compilers: gcc: 10.1.0 Shell: bash v: 5.0.18 running in: konsole 
           inxi: 3.0.37 

Thanks

Do you use hibernation? If you don't, I think you could remove swap partition and use something like zram instead.

https://wiki.archlinux.org/index.php/Improving_performance#Zram_or_zswap

Hi!
If your swappiness is config to 10 it shouldn't activate like that
try this
cat /proc/sys/vm/swappiness
this will tell you the swappiness confing
then edit this file
/etc/sysctl.d/99-sysctl.conf
and add something like this
vm.swappiness = 10

Was already set to 10, see 1st line before inxi

Thanks

I don't use the hibernation, but I need the swap when I do some video editing with kdenlive. I think that it's the only program that should make me swap as sometimes it goes over the 12GB of RAM

Thanks

1 Like

The best solution is to use systemd-swap

sudo apt install systemd-swap

sudo pacman -S systemd-swap
sudo mkdir /etc/systemd/swap.conf.d
sudo touch /etc/systemd/swap.conf.d/overrides.conf

Then

sudo nano /etc/systemd/swap.conf.d/overrides.conf

you need to enable zswap & swapfc and NOT zram, thus add :

swapfc_enabled=1
swapfc_min_count=1

Save & restart

Your swap will be created if needed (obviously, you need to get rid of any partition or swapfile before that)

(partial source : https://wiki.manjaro.org/index.php?title=Swap )

Thanks

Ooops, I somehow forgot to tell you to start systemd-swap service, didi you ?
In case you didn't :

systemctl start systemd-swap
systemctl enable systemd-swap

Then, to check all is ok

swapon -s

Are you sure about that?
I assume you meant something like:

$ sudo pacman -S systemd-swap

Arghhh ! :flushed:
Yess ! I have a twin install on Debian & sometimes do type commands too quickly !
You're right (I amended my post)
Thank you !

Forum kindly sponsored by