I see kswapd using 100% CPU... how can I tell on which process's behalf kswapd is being used so much?

link|improve this question
Uhm. kswapd is the process. It runs on behalf of the kernel. – mailq Sep 28 '11 at 20:27
See serverfault.com/questions/24124/… – P.T. Sep 28 '11 at 22:17
@mailq... yes, but isnt it swapping some user space's memory? and if so, how do I tell which process's memory it is swapping at that moment? – Deshawn Sep 28 '11 at 22:41
feedback

2 Answers

up vote 2 down vote accepted

kswapd is managing swap space in response to memory demands greater than physically available for all processes.

It is process agnostic, it is only interested in what pages are access and when (it is more complex than this of course but to keep things simple we may as well view it this way).

So the real question is "what processes have the greatest burden on memory that are causing kswapd to need to page all the time".

That is most easily answered using 'top' and switching to memory usage sort mode.

link|improve this answer
Thanks!. Doe skswapd kick in ONLY when the actual pages touched exceeds physical or does it kick in even though a process has allocated the memory or mapped the SHM region but not used it? That is, is it only when the problem happens or does it do book keeping and swap things in and out even though there is physical memory available but just because some process has been idle etc? – Deshawn Sep 29 '11 at 0:35
As I understand it, kswapd will under normal circumstances remove any pages from main memory that don't need to be there, because any page that is freed is one that can be used for caching or other processes. Ie, it is better to have an old unused page already on disk rather than to incur the slowness cost of moving it in response to a request for memory from another process. – Paul Sep 29 '11 at 0:47
feedback

You can script it.. but you can also do it via top

Run top then press O followed by p then enter

Now all the processes are sorted by swap usage and you can see which ones are using it

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.