You are not logged in.

#1 2012-07-09 01:33:27

tungsten
Member
Registered: 2012-02-22
Posts: 14

kswapd using 100% CPU, I don't even have swap.

This process kswapd (kswapd0, actually) suddenly starts using 100% of one of my cores for no good reason, usually when moving many GBs around, but sometimes for no good reason at all.
I have no swap.
It also prevents the computer from sucessfully suspending. Only way to go back to normal is rebooting.

I found nothing here or in the Wiki, and I'm posting this here since it seems to be a kernel related issue.

Offline

#2 2012-07-09 02:29:02

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,033

Re: kswapd using 100% CPU, I don't even have swap.

A web search about this had lots of returns.
Seems there's memory pressures and kswapd is endlessly looking for swap to use, at least that was the most common situation.


You're just jealous because the voices only talk to me.

Offline

#3 2012-07-09 09:10:04

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: kswapd using 100% CPU, I don't even have swap.

I had the same issue on a sandy bridge machine of mine, this was fixed with a kernel update (I think it was 3.0).
does this bring your machine back to normal when it is running at 100%?

echo 3 > /proc/sys/vm/drop_caches

I actually ran this as a cron job every few minutes back then as a workaround without knowing what it actually does. big_smile

Offline

#4 2012-07-14 04:46:48

tungsten
Member
Registered: 2012-02-22
Posts: 14

Re: kswapd using 100% CPU, I don't even have swap.

That command did nothing, but I noticed that sometimes the problem appears and goes away spontaneously.

Offline

#5 2012-07-14 10:18:34

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: kswapd using 100% CPU, I don't even have swap.

tungsten wrote:

That command did nothing, but I noticed that sometimes the problem appears and goes away spontaneously.

have you tried linux-mainline from the AUR? If you are lucky it's fixed there.

Offline

#6 2012-10-28 21:40:07

ValdikSS
Member
Registered: 2011-03-30
Posts: 31

Re: kswapd using 100% CPU, I don't even have swap.

Still not fixed for me in 3.6.3

Offline

#7 2012-10-30 15:40:38

eric
Member
From: under heaven
Registered: 2004-02-11
Posts: 117

Re: kswapd using 100% CPU, I don't even have swap.

I didn't have this problem until a few days ago with linux-mainline-3.7rc2. Before this version I have been using various versions of the linux-kx-ck and linux-mainline kernel without this problem.

To make the computer usable I've put kswap0 on a lower priority:

schedtool -D -n 19 `pidof kswapd0`

Output of top:

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND           
   21 root      39  19     0    0    0 R  98.5  0.0 944:00.92 kswapd0           
 3092 root      18  -2 82080  38m  17m S   0.3  1.9  21:54.12 X                 
 3225 eric      -2  -3  288m  52m  28m S   0.3  2.6   7:21.26 kwin              

Offline

#8 2012-11-01 15:25:19

ValdikSS
Member
Registered: 2011-03-30
Posts: 31

Re: kswapd using 100% CPU, I don't even have swap.

Just bumped to this issue. Kswapd0 consumed 100% cpu for a while and everything went fine in 2-3 minutes. I have no swap.

Offline

#9 2012-11-02 17:37:32

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Re: kswapd using 100% CPU, I don't even have swap.

Haven't rebooted my netbook (Atom N270, i686, 1 GB ram) for a few weeks. After the latest update of linux-mainline from miffe's repo + a reboot a few days ago it started for me too. It just happened for the second time in those few days.

3.7rc3-1

Dropping caches doesn't affect anything.

After echo 3 > /proc/sys/vm/drop_caches:

 # free -m
             total       used       free     shared    buffers     cached
Mem:          1000        415        584          0          1         39
-/+ buffers/cache:        373        626
Swap:            0          0          0

I wanted to try if kswapd0 would calm down when turning on swap (just an idea), so I tried to create a file with "dd if=/dev/zero of=/data/swapfile bs=1M count=1000" and while doing that, kswapd0 stopped doing whatever it was doing. Coincidence? Maybe. The last time it went on for quite much longer and I just rebooted without trying things.

edit: happened again and almost instantly after starting the dd kswapd0 stopped consuming cpu cycles. I don't think it's coincidence.


edit2: So after dd it will happen more frequently. The threshold seems to be about 285 megabyte written to the disk (>400 megabyte are cached afterwards). Less and kswapd0 won't stop. Written to /dev/null and it won't stop either, it needs to be written to the disk. Very interesting.

Last edited by Cdh (2012-11-03 20:46:33)


฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz

Offline

#10 2013-01-04 12:47:08

ValdikSS
Member
Registered: 2011-03-30
Posts: 31

Re: kswapd using 100% CPU, I don't even have swap.

Still here in 3.7.1. Got it on video http://youtu.be/_-kT4dLVKLk
To temporary trigger this bug, run dd bs=1M count=2000 if=/dev/zero of=file.spin and watch for kswapd0 IO abuse.

Offline

#11 2013-02-05 20:01:23

neilzium
Member
Registered: 2011-12-17
Posts: 41

Re: kswapd using 100% CPU, I don't even have swap.

I've discovered that this issue can occur if you have bad RAM. it's doesn't seem to occur with the lts kernel but this could be because the newer kernel caches much more agressively. I finally found this issue due to random CRC errors occuring when unraring some big files. memtest however showed no errors but is known for not being very reliable for stability testing. This used to occur daily for me but since I've swapped out my RAM it's disappeared.
I still don't understand why kswapd spends anytime waiting for IO when there is no swap though.

Offline

#12 2013-02-25 22:17:56

mister_playboy
Member
Registered: 2012-01-23
Posts: 17

Re: kswapd using 100% CPU, I don't even have swap.

This issue has started to affect me since kernel 3.7.8.  I have tried turning swap on and off, and setting kswapd0 to a lower priority, but those things have no effect.

If kswapd0 pegs one of my cores I can start closing programs until the problem clears, but if it pegs both cores (which is much more common), I'm essentially forced to hard reset.  I've tried waiting as long as an hour in that situation and the problem never resolves.  Everything is totally unresponsive other than the cursor being able to be moved with a massive delay.


Teach not that I died in vain; rather, teach that I did not die by demonstrating that I live in you.--- ACIM

Offline

#13 2013-12-12 14:40:58

Munksgaard
Member
Registered: 2012-12-03
Posts: 7

Re: kswapd using 100% CPU, I don't even have swap.

I have the same problem. Linux hertz 3.12.1-1-ARCH #1 SMP PREEMPT Thu Nov 21 08:18:42 CET 2013 x86_64 GNU/Linux

Did anyone find a fix?

Last edited by Munksgaard (2013-12-12 14:41:20)

Offline

#14 2013-12-14 17:59:02

dlh
Member
Registered: 2010-11-26
Posts: 44

Re: kswapd using 100% CPU, I don't even have swap.

I can confirm issue on 3.12.5-1-ck

Offline

#15 2013-12-16 10:56:17

bartonc
Member
From: Minden, Nevada, USA
Registered: 2012-02-27
Posts: 25

Re: kswapd using 100% CPU, I don't even have swap.

Just noticed this here
$ uname -a
Linux -- 3.12.4-1-ARCH #1 SMP PREEMPT Sun Dec 8 21:18:00 CET 2013 x86_64 GNU/Linux
Of couse, I'm running Windows in a VM and have pressure on memory resouces (80% used).
I've also got a swap fill that 120% of memory which is barely (1.3%) used.
(And, yes, I will be doubling my RAM this Christmas.)

Last edited by bartonc (2013-12-16 10:59:57)

Offline

#16 2014-02-14 08:43:03

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: kswapd using 100% CPU, I don't even have swap.

Same issue on a machine running 3.11.6-1-ARCH; sometimes some random memory-allocation will result in kswapd0 and kswapd1 running at 100% resulting in a high load. This machine has no swap configured. Since it has ECC ram; I'm pretty sure it's not a hardware problem. This machine has 32Gb memory with only 8 Gb actively in use.

Does anyone have any explanation as to what kswapd is doing while there is no swap configured? I have been able to 'fix' this by running echo 1 > /proc/sys/vm/drop_caches

Offline

#17 2014-02-14 11:29:24

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: kswapd using 100% CPU, I don't even have swap.

Seeing as this hasn't been solved for quite a long time, maybe one of you guys should make a bug report upstream.

Offline

#18 2014-03-28 23:40:14

Californian
Member
Registered: 2014-03-05
Posts: 24

Re: kswapd using 100% CPU, I don't even have swap.

Has anyone reported this bug or found a more permanent fix? If not, I'll try to see if I can figure out how to report it; I am having the same problem.

Offline

#19 2014-03-29 03:26:46

dwe11er
Member
Registered: 2014-03-18
Posts: 73

Re: kswapd using 100% CPU, I don't even have swap.

Add a swapfile or use zram (zramswap package from AUR).

Offline

#20 2014-05-27 11:04:44

lem79
Member
Registered: 2014-02-22
Posts: 9

Re: kswapd using 100% CPU, I don't even have swap.

FWIW, I just encountered this issue on Ubuntu 12.04.4 LTS running kernel 3.13.0-26-generic #48~precise1-Ubuntu.

I then noticed that I hadn't updated my fstab to point to the correct swap partition (so I had no swap). I did that, then used swapon -a to turn it on, while running top in another terminal.

125MB was immediately written to the swap partition, and kswapd0's CPU usage stopped.

Offline

#21 2014-07-14 13:45:37

hifi25nl
Member
Registered: 2011-05-07
Posts: 262

Re: kswapd using 100% CPU, I don't even have swap.

I have the same problem on last kernel 3.15.5-1. No problem on linux-lts or linux-rt. The system is without swap and with vm.swappiness = 0.
I had to install zramswap and now high CPU after moving/downloading some big files has disappeared.

This bug is not resolved yet.

Last edited by hifi25nl (2014-07-14 13:45:54)

Offline

#22 2014-11-26 01:39:27

Shnatsel
Member
From: Moscow
Registered: 2014-07-25
Posts: 11
Website

Re: kswapd using 100% CPU, I don't even have swap.

Fun fact: the issue is described in IBM support pages and it references this thread as a source. And they don't know of a fix either!

http://www-01.ibm.com/support/docview.w … wg21665911


All of the above is a personal opinion and does not represent the views of my granny's dog or the projects to which I contribute.

Offline

#23 2014-11-27 15:12:00

ecloud
Member
Registered: 2010-09-15
Posts: 20

Re: kswapd using 100% CPU, I don't even have swap.

Me too, for what it's worth.  Thinkpad Helix with only (!) 4 GB RAM, so running KDE and Qt Creator and trying to get work done is enough to create memory pressure.   kernel 3.14 (which I keep using because of a not-yet-merged patch to support some sensors).  schedtool -D -n 19 `pidof kswapd0` did seem to help.

Last edited by ecloud (2014-11-27 15:14:31)

Offline

#24 2015-01-07 06:38:21

BiG_NoBoDy
Member
Registered: 2015-01-07
Posts: 1

Re: kswapd using 100% CPU, I don't even have swap.

Hi,

Hope it's not too late. And someone will be able to test my suggestion.

just noticed the same on RHEL6.3 smile smile and just wanted to say, maybe you can try XFS not ext4 ?

As I understand it's a booody ext with it's new features on ext4...

----------------- edit 1 ------------------
P.S. changing priority to lower it's not a solving issue, just fixing it for today... smile

----------------- edit 2 ------------------
also noticed on my RHEL box, that I also have big disk IO for these kswap0 issues, also jbd2 process is striking for io... check it with iotop. wink

Last edited by BiG_NoBoDy (2015-01-07 06:41:46)

Offline

#25 2015-12-24 13:16:07

articice
Member
Registered: 2014-04-02
Posts: 2

Re: kswapd using 100% CPU, I don't even have swap.

I have XFS and a 3.13.6 kernel.

I just googled "LulzSec" and suddenly this kswapd problem appeared. Hope it's a coincidence :)

I still had 20 GiB free memory (no swap), but when I did as they recommend here

echo 3 > /proc/sys/vm/drop_caches

the problem disappeared. So I think it actually does something.


BiG_NoBoDy wrote:

maybe you can try XFS not ext4 ?

I wouldn't recommend XFS unless you have a RAID array or an SSD. My experience with XFS was very much frustrating.
I have one 15K SAS direct attach drive, and it has a bad block now (and I can't re-allocate it using scu.d), and I've found out that XFS does not really support bad blocks. I can't fix the issue without re-booting! (that's how you solved problems back in the days of Windows 98).
Second, it's performance on such a setup is just horrible compared to ext3.
Moreover, my kernel version is plagued by an XFS bug when everything hangs suddenly. They call it something like a spontaneous bug that happens on "innocuous desktop workloads".

On the positive side, it does allow filesystem checks and de-fragmentations without re-booting, which ext4 doesn't.

Last edited by articice (2015-12-24 13:24:54)

Offline

Board footer

Powered by FluxBB