msm8937-common: init: Set zram size according to RAM size
This commit is contained in:
parent
079e05c76f
commit
a3c26ff2a1
2 changed files with 27 additions and 1 deletions
|
@ -122,10 +122,36 @@ void check_device()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_zram_size(void)
|
||||||
|
{
|
||||||
|
FILE *f = fopen("/sys/block/zram0/disksize", "wb");
|
||||||
|
int MB = 1024 * 1024;
|
||||||
|
std::string zram_disksize;
|
||||||
|
struct sysinfo si;
|
||||||
|
|
||||||
|
// Check if zram exist
|
||||||
|
if (f == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize system info
|
||||||
|
sysinfo(&si);
|
||||||
|
|
||||||
|
// Set zram disksize (divide RAM size by 3)
|
||||||
|
zram_disksize = std::to_string(si.totalram / MB / 3);
|
||||||
|
|
||||||
|
// Write disksize to sysfs
|
||||||
|
fprintf(f, "%sM", zram_disksize.c_str());
|
||||||
|
|
||||||
|
// Close opened file
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
void vendor_load_properties()
|
void vendor_load_properties()
|
||||||
{
|
{
|
||||||
init_alarm_boot_properties();
|
init_alarm_boot_properties();
|
||||||
check_device();
|
check_device();
|
||||||
|
set_zram_size();
|
||||||
|
|
||||||
property_set("dalvik.vm.heapstartsize", heapstartsize);
|
property_set("dalvik.vm.heapstartsize", heapstartsize);
|
||||||
property_set("dalvik.vm.heapgrowthlimit", heapgrowthlimit);
|
property_set("dalvik.vm.heapgrowthlimit", heapgrowthlimit);
|
||||||
|
|
|
@ -23,4 +23,4 @@
|
||||||
|
|
||||||
/devices/soc/7864900.sdhci/mmc_host* auto auto nosuid,nodev wait,voldmanaged=sdcard1:auto,noemulatedsd,encryptable=footer
|
/devices/soc/7864900.sdhci/mmc_host* auto auto nosuid,nodev wait,voldmanaged=sdcard1:auto,noemulatedsd,encryptable=footer
|
||||||
/devices/soc/78db000.usb/msm_hsusb_host* auto auto nosuid,nodev wait,voldmanaged=usbotg:auto
|
/devices/soc/78db000.usb/msm_hsusb_host* auto auto nosuid,nodev wait,voldmanaged=usbotg:auto
|
||||||
/dev/block/zram0 none swap defaults zramsize=1073741824,max_comp_streams=4
|
/dev/block/zram0 none swap defaults max_comp_streams=4
|
||||||
|
|
Loading…
Reference in a new issue