I have reported this as a bug but the project team seem more interested in burying their head in the sand so you won't get any help at all from them. I even asked for help on the +FreeXperia +Google+ page but I gave up on asking for any help from anyone there a long time ago.
The provided Linux kernel definitely does have zRAM enabled.
# ll /dev/block/zram*
brw------- 1 root root 253, 0 Sep 10 13:10 /dev/block/zram0
brw------- 1 root root 253, 0 Sep 10 13:10 /dev/block/zram0
The problem lies within the UI to configure it. No scripts seem to be created or executed so either the option is a stub or it is simply broken.
Initially I decided to use SetXperia which, again, proves that the kernel part is fine, but SetXperia remains in RAM all the time, and even in the notification area. I just don't see the point in that.
It can't be that difficult to enable zRAM, right?
Using the Ubuntu zram-config package it was fairly easy to work out what was needed and hence create a script.
#!/system/bin/sh
SWAPPINESS="35"
TAG="zram-config"
log -p i -t $TAG "Setting vm.swappiness to $SWAPPINESS"
logwrapper sysctl -w vm.swappiness=$SWAPPINESS
log -p i -t $TAG "Done."
log -p i -t $TAG "Setting up zram"
echo 75497472 > /sys/block/zram0/disksize
logwrapper mkswap /dev/block/zram0
logwrapper swapon /dev/block/zram0
log -p i -t $TAG "Done."
log -p i -t $TAG "All done."
SWAPPINESS="35"
TAG="zram-config"
log -p i -t $TAG "Setting vm.swappiness to $SWAPPINESS"
logwrapper sysctl -w vm.swappiness=$SWAPPINESS
log -p i -t $TAG "Done."
log -p i -t $TAG "Setting up zram"
echo 75497472 > /sys/block/zram0/disksize
logwrapper mkswap /dev/block/zram0
logwrapper swapon /dev/block/zram0
log -p i -t $TAG "Done."
log -p i -t $TAG "All done."
I dropped this script into /data/local/userinit.d/zram-config (remember to set +x on the script).
All the log and logwrapper stuff is obviously to send details to the log. It probably doesn't work as the script is run before Android is loaded. Indeed, I've never seen anything using logcat unless it's run manually. They are not needed for the script to work.
vm.swappiness is set to 60 by default. You shouldn't change that unless you know what you're doing. In my case sysctl -w vm.swappiness=35 does this. I could not find a config file for sysctl (such as /etc/sysctl.conf) as is the case for most Linux distributions.
The Ubuntu script sets up the amount of zRAM based on the amount of RAM and creates separate devices based on the number of cores, which makes sense because it's a generic script to be used on a vast array of machines including, recently, mobile platforms. There's no real need to do that unless you plan on dropping the script on a variety of different devices. You should decide for yourself how much zRAM you want to configure.
echo 75497472 > /sys/block/zram0/disksize sets my zRAM device to 75 MB.
mkswap /dev/block/zram0 sets up the device as a swap device, as you would with any normal swap.
swapon /dev/block/zram0 enables the swap.
This can, of course, be used with any device that has zRAM enabled in the kernel.
# uname -a
Linux localhost 2.6.32.9-FXP #1 PREEMPT Fri Apr 19 17:37:58 EEST 2013 armv7l GNU/Linux
I recommend installing ZRAM Status from the Play Store so that you can see that your zRAM is being used, along with some interesting, nerdy statistics.
Remember that you will need to reboot your device (or run the script manually) to enable zRAM the first time.
No comments :
Post a Comment