Kswapd0 high CPU usage

For the past few weeks, my home server has experienced bouts of extremely high CPU usage courtesy of kswapd0. This came as quite a surprise to me since none of the software on my server is particularly resource-intensive. KSysGuard says as much; as I type this, it shows RAM usage as sitting at just under 1 GB, and I’ve got 4 GB installed. However, it also shows that 1.1 GB of swap space is being used.

To make matters even more confusing, I used the command-line tool top to double-check RAM usage, and it paints a completely different picture:

top - 17:00:14 up 1 day, 9:22, 4 users, load average: 3.32, 2.61, 2.14
Tasks: 158 total, 2 running, 155 sleeping, 0 stopped, 1 zombie
%Cpu(s): 6.7 us, 72.0 sy, 0.0 ni, 1.0 id, 19.2 wa, 0.0 hi, 1.1 si, 0.0 st
KiB Mem: 3938232 total, 3786688 used, 151544 free, 1032 buffers
KiB Swap: 4075516 total, 1181264 used, 2894252 free, 2953960 cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
34 root 20 0 0 0 0 D 80.5 0.0 226:44.13 kswapd0
638 root 20 0 176m 20m 8292 R 48.9 0.5 11:19.97 Xorg
461 sickbea+ 20 0 1279m 66m 2196 S 16.3 1.7 114:08.57 python
12331 honor 20 0 488m 17m 7748 S 3.7 0.5 0:44.75 ksysguard
1635 honor 20 0 701m 21m 6132 S 2.3 0.5 8:03.55 kwin
2459 honor 20 0 265m 11m 4048 S 2.0 0.3 1:01.08 krfb
1593 root 20 0 0 0 0 D 1.7 0.0 1:51.23 flush-8:16
1747 honor 20 0 1203m 58m 10m S 0.7 1.5 13:03.42 plasma-desktop
11 root 20 0 0 0 0 S 0.3 0.0 1:36.69 rcu_preempt
177 root 0 -20 0 0 0 S 0.3 0.0 2:09.07 kworker/0:1H
464 sabnzbd 20 0 1492m 9600 2104 S 0.3 0.2 3:13.91 SABnzbd.py
2782 honor 20 0 1007m 27m 8704 S 0.3 0.7 7:40.14 ktorrent
1 root 20 0 46072 3340 848 S 0.0 0.1 0:01.18 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:08.96 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/u:0H
8 root rt 0 0 0 0 S 0.0 0.0 0:00.10 migration/0
9 root -2 0 0 0 0 S 0.0 0.0 0:15.35 rcuc/0
10 root -2 0 0 0 0 S 0.0 0.0 0:00.00 rcub/0
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_sched
14 root rt 0 0 0 0 S 0.0 0.0 0:00.40 watchdog/0
15 root rt 0 0 0 0 S 0.0 0.0 0:00.39 watchdog/1
16 root -2 0 0 0 0 S 0.0 0.0 0:11.24 rcuc/1
17 root 20 0 0 0 0 S 0.0 0.0 0:09.02 ksoftirqd/1
18 root rt 0 0 0 0 S 0.0 0.0 0:00.12 migration/1
20 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H
21 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 cpuset
22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
23 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
24 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
25 root 20 0 0 0 0 S 0.0 0.0 0:00.01 bdi-default
26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
27 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
28 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff
29 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd
30 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md
33 root 20 0 0 0 0 S 0.0 0.0 0:00.02 khungtaskd
35 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
36 root 39 19 0 0 0 S 0.0 0.0 0:00.69 khugepaged
37 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark
38 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
43 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kthrotld
44 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kpsmoused
46 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 deferwq
83 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0
84 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_1
85 root 20 0 0 0 0 S 0.0 0.0 0:00.78 kworker/u:2
87 root 20 0 0 0 0 S 0.0 0.0 0:00.01 scsi_eh_2
88 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_3
99 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kmpath_rdacd
246 root 20 0 0 0 0 S 0.0 0.0 0:29.98 jbd2/sda1-8
247 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ext4-dio-unwrit
254 root 20 0 0 0 0 S 0.0 0.0 0:05.55 flush-8:0
273 root 0 -20 0 0 0 S 0.0 0.0 0:03.49 kworker/1:1H
280 root 20 0 591m 11m 11m S 0.0 0.3 0:14.51 systemd-journal
281 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
312 root 20 0 39108 496 492 S 0.0 0.0 0:00.05 systemd-udevd
358 root -51 0 0 0 0 S 0.0 0.0 0:00.00 irq/43-mei
378 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kvm-irqfd-clean
386 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 hd-audio0
401 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 led_workqueue
443 root 20 0 0 0 0 S 0.0 0.0 0:01.54 jbd2/sda3-8
444 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ext4-dio-unwrit

If I’m reading this correctly, top is saying that RAM usage is almost maxed out. What’s going on here? How can I get kswapd0 under control? I did a search for similar topics, but the kernel bug talked about in earlier threads was supposedly fixed.

Please tell us of your openSUSE version and desktop being used and present kernel version. I find a lot of complaints like your with the most recent using kernel 3.7, included in openSUSE 12.3. Perhaps a kernel upgrade to 3.9 might help? Have a look here:

openSUSE and Installing New Linux Kernel Versions - Blogs - openSUSE Forums

Thank You,

Thank you. Upgrading kernel to 3.9 appears to have resolved this problem. In case someone with the same problem finds this thread later on, my server runs openSUSE 12.3 KDE, and the high CPU usage was caused by kernel 3.7, which 12.3 comes with.

Good to hear a new kernel was the fix for this problem. What method did you decide to use to install kernel 3.9?

Thank You,

It appears I may have spoken too soon. I used:

sudo zypper ar http://download.opensuse.org/repositories/Kernel:/stable/standard/ Kernel-Stable
sudo zypper refresh
sudo zypper in --from Kernel-Stable kernel-desktop

The high CPU usage is back, and this time it’s even more confusing than before. The old discrepancy in RAM usage between top and KSysGuard is back, and now there’s a CPU usage discrepancy. Both top and KSysGuard report total CPU usage in the area of ~30%, but the CPU Monitor plasmoid I keep on the desktop sometimes shows much higher usage. I didn’t have that before.

So that should be kernel 3.9.4. Did you check by using the terminal command uname -r?

Thank You,

Yes, that’s correct.


3.9.4-1.g51bf0ff-desktop

Please help!
CPU usage 100% with “kswapd” process. All works slow (CPU occuped). This begin after boot and continue all the time PC working.
I use openSUSE 13.1 KIWI image .iso. The same packages collection works fine on 12.3. I tink this is kernel bug… :’(

Here output of some commands:

uname -a:
Linux steel.linux 3.11.6-4-default #1 SMP Wed Oct 30 18:04:56 UTC 2013 (e6d4a27) i686 i686 i386 GNU/Linux
(default kernel from OSS repo)

lsb_release -a:

LSB Version:    core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-ia32:core-3.2-ia32:core-4.0-ia32:desktop-4.0-ia32:desktop-4.0-noarch:graphics-2.0-ia32:graphics-2.0-noarch:graphics-3.2-ia32:graphics-3.2-noarch:graphics-4.0-ia32:graphics-4.0-noarch
Distributor ID:    openSUSE project
Description:    openSUSE 13.1 (Bottle) (i586)
Release:    13.1
Codename:    Bottle

free -h:

             total       used       free     shared    buffers     cached
Mem:          1,2G       1,1G        92M       125M       9,6M       813M
-/+ buffers/cache:       277M       916M
Swap:         1,5G       324M       1,2G

top:
http://paste.opensuse.org/88213307

dmesg:
http://paste.opensuse.org/33515517

ps auxww:
http://paste.opensuse.org/46676485

zypper ls:
http://paste.opensuse.org/46582839

repos URLs:
http://paste.org.ru/?5lvo73

rpm -qa:
http://paste.org.ru/?vsherh

SOLVED. Was added “bad” repository.

SORRY! NOT SOLVED!
CPU still 100% loaded :frowning:

I also had this problem. My computer was useless for a few minutes or longer, completely ignoring mouse & keyboard. Sometimes I had to hit the power button to get out of it. After determining kswapd0 was the likely culprit, I did a Google search and came up with this command:
echo 1 > /proc/sys/vm/drop_caches

I added it to /etc/init.d/after.local, so that it runs at boot. So far it seems to be much better, though I haven’t given it a few days to be sure. One benefit was immediately obvious though. On this computer, I could never get anywhere near the 35 Mb download I get from my ISP, using this computer. After adding that command, I now can. As I mentioned, I’ll have to give this some more time to be sure, but it does appear to be the fix.

Apparently, that fix didn’t work. The problem returned tonight.