5

Using Ozcan ROM 6.3 on my Samsung Galaxy S4, I'm observing kswapd0 process making CPU laggy. The same thing happened on another TW KK ROM - Omega. After researching on it for weeks, I realized that it's the process that does the SWAP job - transferring RAM contents to storage when memory is low.

Presently, I don't want to use SWAP, so the following are the workarounds that I tried to disable SWAP:

  • Tried Apps like Swapper2, Reset Swap to delete swapfile. The process vanishes for few seconds but it looks like the swapfile again gets created (checked by using command, free).
  • Used the command swapoff -a (to Stop swapping on all swap devices) but it gives me an error - swapoff: /etc/fstab: No such file or directory.

So, my Queries are as follows:

  • Why and how does SWAP gets enabled automatically? Is the kernel or ROM responsible for it?

  • When actually could the SWAP partition be created when I didn't do it manually? On flashing the ROM?

  • What I'm doing wrong in the swapoff comand? After reading about the same error, I think it's related to the location of the swapfile. So, how can I know the location of the swapfile? Any suggestions on disabling the SWAP permanently or making kswapd0 use less CPU if the lag is not directly related to SWAP?

(Originally posted on XDA)

  • Hi and welcome to Android.SE! Thank you for this good question. We hope you'll like the place and decide to stay. I know it took more than half a year for you to get an answer. For the future: try to come back and edit any unanswered questions of yours often. Add progress updates on your research and experimentation. Each time you edit, it bumps your question to the top of the homepage, potentially getting it more attention. – unforgettableid Aug 6 '15 at 0:26
  • creieras.wordpress.com/2011/12/16/… says it's a problem with the way the kernel handles memory. – endolith May 5 '16 at 16:02
1

It might not be possible to disable kswapd0. Even if it's possible to disable it, you should not try. You see, kswapd0 does important work even if you don't have a swap file.

On the Ubuntu Stack Exchange website, psusi explains:

Swap space is only used for data that is not backed by any other file. Data that is mapped from other files on disk (such as executable programs) is still swapped to their respective files even if you don't have a swap device.

You should visit psusi's original answer and vote it up.

  • ok but why is it hogging the CPU? – endolith Dec 11 '15 at 3:31
  • @endolith: I presume it's swapping binaries into and out out of RAM. This takes CPU time. Don't worry about the CPU time that kswapd0 takes up. – unforgettableid Dec 14 '15 at 8:02
  • But it's taking a LOT of CPU time, and the phone is hot for no reason – endolith May 5 '16 at 16:00
  • How much is a lot? Also, how hot is the phone? For what it's worth, certain apps can tell you the battery temperature (with help from the thermistor built into every Android phone battery). Also, other apps can tell you the CPU temperature. Also, you can use some external device to measure the phone's external temperature. Maybe a thermal imaging camera? – unforgettableid May 20 '16 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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