Join now - be part of our community!

High IOWAIT/CPU usage in Lollipop

profile.country.IT.title
Michelasso
Contributor

High IOWAIT/CPU usage in Lollipop

After installing Lollipop I checked a bit what was running on it and with "busybox top" (but also the stock "top" command) via adb shell I noticed that the IOWAIT was very high (50%). Other tools show that while active the CPU frequency is stuck at 1190Mhz with at least 2 cores. So I did a factory reset, and nothing changed. Here is a sample:

Mem: 733016K used, 152060K free, 0K shrd, 40788K buff, 180220K cached

CPU:  1.2% usr  7.4% sys  0.0% nic 47.3% idle 43.8% io  0.0% irq  0.0% sirq

Load average: 10.85 11.35 10.77 2/1680 31466

  PID  PPID USER     STAT   VSZ %VSZ CPU %CPU COMMAND

  759   341 1000     S <  1136m131.3   1  1.7 system_server

   84     2 0        DW       0  0.0   1  1.0 [kswapd0]

It just stays like that all times I check.I also tried umounting the external SD card, no changes. I don't know if it is related to kswapd0 process (I noticed there is a swap device as well now? About 450MB) or else, but after a factory reset this is disturbing. It's needless to say that it drains the battery like crazy.

9 REPLIES 9
profile.country.IT.title
Michelasso
Contributor

Is anyone from Sony support checking the M2 forum? 

1adrian1
Contributor

This isn't run by Sony staff
profile.country.IT.title
Michelasso
Contributor


@1adrian1 wrote:
This isn't run by Sony staff

What? Really? But I've seen in other threads some Sony Support staff replying and taking care of the issues.

profile.country.IT.title
Michelasso
Contributor

So finally I have got root and with it i could dig the problem. It was the kswapd0 daemon indeed, or better, the zRAM. Lollipop on our M2 devices enables zRAM, which is the compressed (in RAM) virtual memory. This would be a good thing, since it gives virtual access to more bytes in the RAM at (usually) a low CPU cost. But if the cost is to have an average iowait of 40% (with the idle time never going above 60-70%)  something went really, really wrong. I had the zram enabled in the custom kernel of my old mono core Gingerbread phone and with no activity the idle time was 95% or more.

Anyway, to make a long story short disabling the zram it went back to normal. In order to do it one needs to run the following command as root:

swapoff /dev/block/zram0

To do it automatically just put the same command in a script in /etc/init.d (if your rooting supports it).

Oh, this is NOT a solution. Just a work around for rooted users. Sony is better fixing this.

profile.country.IT.title
Michelasso
Contributor

With the help of some other users at XDA I managed to identify even a bettwer workaround (obviously it still needs root) which keeps the zram enabled (with the zram disabled forget about the multitasking keeping in memory the open applications). Just make an /etc/init.d script with the following lines (if you know how that works - Don't forget to call the shell in the header!) or for more semplicity just add them to the /etc/init.d/00stop_ric script:

sysctl -w vm.swappiness=60
sysctl -w vm.laptop_mode=1 sysctl -w vm.drop_caches=1

obviously removing the previous "swapoff" command if present. It does work (the I/O wait few minutes after boot goes down to 0), it has been used by many now and some even report that they have got an appreciable battery gain (which would make sense). Still in my opinion kswapd0 is working too much, which is disappointing since ART in Lollipop was supposed to use less RAM, not more! But I suppose that particular one is a Google issue.

PS: Since those are all workarounds it would be nice if someone from Sony in the forum will bring this to the attention of the developers.

1adrian1
Contributor

Not touched my zram settings and getting superb battery life now back to how it was on kk if not better. Never less than 5-6hrs screen time no matter how much I use it
profile.country.IT.title
Michelasso
Contributor

And that would be useful to the discussion.. because? A constant high I/O Wait is bad. And wrong. Plain and simple. It isn't only a matter of battery, it is also a matter of having CPU cores doing nothing because they are waiting for who knows what. 

Oh, and by the way. There has been a guy showing a screen time of 8 and 1/2 hours changing the zram parameters.

1adrian1
Contributor

I'm sure you can I can get 6hrs with zram as Sony intended so it probably is easily achievable. If it was that bad they Wouldn't have used it. The biggest cause of battery drain I've found is Google services as usual running a million things(slight exaduration) in the background.
profile.country.IT.title
Michelasso
Contributor

Sony introduced the zram because Lollipop eats RAM for breakfast, leaving little for anything else. Other then the internal memory because of ART, sure. If one simply disables zram the I/O Wait goes to normal but you can  kiss goodbye to any multitasking. Not that zram improves it much anyway. That Andorid memory hog needs at least 2Gb to run as intended.

Still, that's not the point. But since it seem quite clear you have not the required skills and knowledge let's end the discussion here, shall we?