You are not logged in.

#1 2019-07-11 18:38:54

MattMatt2
Member
Registered: 2019-03-11
Posts: 29

Kswapd0 makes my computer completly unresponsive

Hi,
I've got a problem with the kernel swap daemon [identified as kswapd0 by top]. It's just taking my 95% of my CPU, making my computer completly unresponsive, and I'm forced to force shutdown.
I think that is because I've got no swap, but I don't want to have any, because I'm afraid it destroys my SSD.

What I tried:
kill -9 58 (kills kswapd, but automatically restarts)
echo 3 > /proc/sys/vm/drop_caches (sometimes working, but I still have to write it, and sometimes it's too late).

Here is the output of uname -a:
Linux archlinux 5.1.16-arch1-1-ARCH #1 SMP PREEMPT Wed Jul 3 20:23:07 UTC 2019 x86_64 GNU/Linux
My processor is Intel(R) Celeron(R) CPU N3450 @ 1.10GHz,
and I've got 3756MiB of RAM (according to neofetch)

If you need any other information, I'll answer.

Thanks for your

Offline

#2 2019-07-11 19:17:34

loqs
Member
Registered: 2014-03-06
Posts: 19,101

Re: Kswapd0 makes my computer completly unresponsive

Welcome to the arch linux forums MattMatt2.
Edit:
Missed you had already tried drop_caches.

Last edited by loqs (2019-07-11 21:02:34)

Offline

#3 2019-07-11 19:31:38

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,423

Re: Kswapd0 makes my computer completly unresponsive

Most modern SSDs can take literal terabytes of writes a year and still be expected to live 10 years. If you are that strapped for resources it really is the best idea to get yourself a swap partition/file.

Last edited by V1del (2019-07-11 19:31:56)

Offline

#4 2019-07-11 20:35:10

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,496

Re: Kswapd0 makes my computer completly unresponsive

You're running out of RAM, the system has to drop non-anonymous memory (mapped files, executables, libraries, …) and at some point you're dropping the library that's currently used so the system has to immediately re-read it, sacrificing whatever else it finds.

Get more RAM, use less RAM or add a swap partition/file (see V1del's remark - you can also use a usb key for this, but it's going  to slow down and die MUCH faster).
If you do not expect to run OOM, find the offending process (on a consumer desktop it's usually the browser)

There're ways to manpulate the kernel behavior but unless you're willing to aggressively kill processes (not kswapd, but your browser) in this situation, your best option might be to increase vfs_cache_pressure (though this might be counter-productive if the OOM thrashing is caused by something loading dentry and inode caches - your drop_caches experience does however not support that scenario)

Offline

#5 2019-07-11 21:16:21

MattMatt2
Member
Registered: 2019-03-11
Posts: 29

Re: Kswapd0 makes my computer completly unresponsive

Well, thanks for your answers. I'll check vfs_cache_pressure. I've installed ArchLinux on external SSD before, and I used swap with a USB drive. That worked well.

Actually, It's Minecraft that uses so much RAM tongue.

But there's something I don't understand:
My computer was sold with Windows 10, and I didn't encounter any problem while starting minecraft.
Does Windows also uses swap (or any system working like that)?

Offline

#6 2019-07-11 21:26:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,496

Re: Kswapd0 makes my computer completly unresponsive

Google for Swapfile.sys, Hiberfil.sys and Pagefile.sys …

Offline

#7 2019-07-11 23:03:42

latalante1
Member
Registered: 2018-08-30
Posts: 112

Re: Kswapd0 makes my computer completly unresponsive

MattMatt2 wrote:

Hi,
I think that is because I've got no swap, but I don't want to have any, because I'm afraid it destroys my SSD.

Not using the swap file is a very bad idea.
Are you afraid of SSD failure? Seriously.

Start using ZRam. It's used on most Android smartphones, on all Chromebooks even on the Google CloudShell (there is no swap file) that I'm currently writing.
Make use of you and you will have the same benefits. This is the fastest possible swap file, operating only in RAM.

Step 1
edit /etc/mkinitcpio.conf and zram module

MODULES=(...zram)

Step 2
edit /etc/fstab

/dev/zram0      none    swap    defaults,pri=100        0 0

Chromebook with 2G RAM using 2.8 GB zram swap.

Step 3
create file /etc/udev/rules.d/99-zram.rules

KERNEL=="zram0", ATTR{comp_algorithm}="lzo", ATTR{disksize}="3G" RUN="/usr/bin/mkswap /dev/zram0", TAG+="systemd"

If these 3 steps are too difficult, you can use this option.
https://src.fedoraproject.org/fork/chri … ree/master

Offline

#8 2019-07-12 02:43:56

latalante1
Member
Registered: 2018-08-30
Posts: 112

Re: Kswapd0 makes my computer completly unresponsive

Limiting the number of writes on the disk (quite radical). Laptop mode.
cat /etc/sysctl.d/99-sysctl.conf

vm.dirty_expire_centisecs = 12000
vm.dirty_writeback_centisecs = 12000
vm.dirty_background_ratio = 10

cat /etc/fstab

/dev/sda2       /               ext4            rw,data=ordered,commit=600   0 1

As a result, a minimum of 10 minutes without writing to the disk.

pidstat -dl 20
Linux 5.2.0     07/12/2019      _x86_64_        (2 CPU)
01:10:00 AM   UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s iodelay  Command

01:10:20 AM   UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s iodelay  Command
[...]
[...]
01:20:00 AM   UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s iodelay  Command

Offline

#9 2019-07-14 18:43:09

MattMatt2
Member
Registered: 2019-03-11
Posts: 29

Re: Kswapd0 makes my computer completly unresponsive

Okay, thanks for your answers. I'll consider adding some swap to my computer (4 GB).

Offline

Board footer

Powered by FluxBB