Gentoo Archives: gentoo-user

From: Mick <michaelkintzios@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] kswapd0 100% CPU with swapoff and no memory demands on system
Date: Sat, 03 May 2014 10:30:43
Message-Id: 201405031130.12724.michaelkintzios@gmail.com
In Reply to: [gentoo-user] kswapd0 100% CPU with swapoff and no memory demands on system by Chris Stankevitz
1 I can't answer all your questions, but here is what I can answer:
2
3 On Saturday 03 May 2014 08:16:24 Chris Stankevitz wrote:
4 > Hello,
5 >
6 > I have a small system:
7 >
8 > - 6GB drive
9 >
10 > - ext4 partition mounted readonly
11 >
12 > - swap partition that is not listed in fstab and not enabled. (I will
13 > swapon it every few weeks or so if I need it for a large compile job)
14 >
15 > - 2 GB RAM
16 >
17 > When the system boots it processing video from a USB camera. The
18 > program dynamically allocates and releases memory while it runs, but
19 > stores no data in memory or on disk (read-only). The memory usage
20 > does not grow over time.
21 >
22 > When things are going well, top looks like so:
23 >
24 > ===
25 >
26 > Tasks: 68 total, 1 running, 67 sleeping, 0 stopped, 0 zombie
27 > %Cpu0 : 88.3 us, 11.7 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si,
28 > 0.0 st %Cpu1 : 25.5 us, 2.3 sy, 0.0 ni, 72.1 id, 0.0 wa, 0.0 hi, 0.0
29 > si, 0.0 st %Cpu2 : 6.0 us, 0.7 sy, 0.0 ni, 93.3 id, 0.0 wa, 0.0 hi,
30 > 0.0 si, 0.0 st %Cpu3 : 25.7 us, 2.3 sy, 0.0 ni, 72.0 id, 0.0 wa,
31 > 0.0 hi, 0.0 si, 0.0 st KiB Mem: 1861644 total, 161648 used, 1699996
32 > free, 6948 buffers KiB Swap: 0 total, 0 used, 0
33 > free, 57728 cached
34 >
35 > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
36 > 2129 root 20 0 1774440 81712 25388 S 160.0 4.4 25:55.46 obt
37 > 705 root 20 0 0 0 0 S 1.0 0.0 0:07.87 kswapd0
38 > 2049 ueyed 20 0 620472 14092 13652 S 1.0 0.8 0:09.34
39 > ueyeusbd
40 >
41 >
42 > ====
43 >
44 >
45 > Q1: Why does the kswapd0 process from time to time take up 100% CPU?
46
47 I can't answer this, other than say that something is using up your memory and
48 the kernel is processing heavily (assessing) the number of free pages in the
49 system to see if they are getting too low and therefore it should start
50 swapping pages out into your swap partition. It runs on a timer, so it will
51 check this every now and then and therefore you will find it fluctuates over
52 time.
53
54
55 > Q2: Why does top show "cached swap" eventhough I do not have swap mounted?
56
57 It doesn't, although if you read that row from left to right you would assume
58 that the cached number shown there is swapped cache.
59
60 It is actually referring to data in your memory cache. If someone was to pull
61 the plug then all this data in RAM would be lost. If you run:
62
63 cat /proc/meminfo
64
65 you will see that there are two entries there, 'Cached' which corresponds to
66 your cached value in Top and also 'SwapCached' which refers to the amount of
67 data that was swapped out and has now been swapped back in memory, but it is
68 still kept in the swapfile in case it needs to be swapped out again soon (it
69 tries to save I/O operations from the filesystem).
70
71
72 > Q3: Is there anything I can do to prevent kswapd0 from using CPU on my
73 > system? e.g. disable SWAP in the kernel config
74
75 Well, I guess that if you have disabled swap in the kernel the kernel daemon
76 will not be available whenever you run that kernel.
77
78
79 > I suspect the answer to Q1 is:
80 >
81 > a) kernel is not configured properly for my hardware
82 > or
83 > b) there is some bad side effect to my readonly root fs
84
85 I have found reports and allegations of a kernel bug with kswapd in Google,
86 but I don't know if this is related to your problem.
87
88 --
89 Regards,
90 Mick

Attachments

File name MIME type
signature.asc application/pgp-signature