From 665448ab37c57507adb1a314bbc0bc1f9fcf69e2 Mon Sep 17 00:00:00 2001 From: "Eugene San (eugenesan)" Date: Wed, 16 Sep 2015 10:01:27 -0400 Subject: [PATCH] Optimize storage, use cache as secondary swap and reuse devlog as cache Change-Id: I15cf136cf180f0e6686cd37641cc4170867adecd --- .../base/core/res/res/xml/storage_list.xml | 2 +- recovery/root/etc/twrp.fstab | 4 +- rootdir/etc/fstab.pyramid | 10 ++-- rootdir/etc/init.pyramid.rc | 46 +++++++++++-------- rootdir/etc/init.pyramid.sh | 46 +++++++++++-------- system_prop.mk | 17 ++++--- 6 files changed, 72 insertions(+), 53 deletions(-) diff --git a/overlay/frameworks/base/core/res/res/xml/storage_list.xml b/overlay/frameworks/base/core/res/res/xml/storage_list.xml index 5d92fdae..92249ddf 100644 --- a/overlay/frameworks/base/core/res/res/xml/storage_list.xml +++ b/overlay/frameworks/base/core/res/res/xml/storage_list.xml @@ -35,7 +35,7 @@ android:allowMassStorage="false" android:maxFileSize="4096" /> - diff --git a/recovery/root/etc/twrp.fstab b/recovery/root/etc/twrp.fstab index d24c4484..20614abe 100644 --- a/recovery/root/etc/twrp.fstab +++ b/recovery/root/etc/twrp.fstab @@ -4,8 +4,8 @@ /recovery emmc /dev/block/mmcblk0p21 /system ext4 /dev/block/mmcblk0p22 /data f2fs /dev/block/mmcblk0p23 length=-16384 -/cache f2fs /dev/block/mmcblk0p24 +/cache f2fs /dev/block/mmcblk0p28 /misc emmc /dev/block/mmcblk0p31 /sdcard1 vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=display="sdcard1";andsec;storage;wipeingui;removable /data1 f2fs /dev/block/mmcblk1p2 /dev/block/mmcblk1 flags=display="data1";wipeingui;removable -/usbdisk vfat /dev/block/sda1 /dev/block/sda flags=display="usbdisk";storage;wipeingui;removable +/usb-otg vfat /dev/block/sda1 /dev/block/sda flags=display="usb-otg";storage;wipeingui;removable diff --git a/rootdir/etc/fstab.pyramid b/rootdir/etc/fstab.pyramid index 59c9dffe..a955c971 100644 --- a/rootdir/etc/fstab.pyramid +++ b/rootdir/etc/fstab.pyramid @@ -7,10 +7,9 @@ /dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults /dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults /dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults -/dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait +/dev/block/platform/msm_sdcc.1/by-name/devlog /cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check +/dev/block/platform/msm_sdcc.1/by-name/devlog /cache f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check /dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,noatime,barrier=1 wait -/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check -/dev/block/platform/msm_sdcc.1/by-name/cache /cache f2fs rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr wait,check /dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check,encryptable=footer,length=-16384 /dev/block/platform/msm_sdcc.1/by-name/userdata /data f2fs noatime,nodiratime,nosuid,nodev,inline_xattr,discard,rw wait,check,encryptable=footer,length=-16384 /dev/block/platform/msm_sdcc.3/by-num/p2 /data1 ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check @@ -23,4 +22,7 @@ d* auto auto defaults voldmanaged=usbdisk:auto,noemulatedsd # ZRAM -/dev/block/zram0 none swap defaults zramsize=268435456 \ No newline at end of file +/dev/block/zram0 none swap defaults zramsize=134217728 + +# Cache as secondary swap +/dev/block/platform/msm_sdcc.1/by-name/cache none swap defaults defaults diff --git a/rootdir/etc/init.pyramid.rc b/rootdir/etc/init.pyramid.rc index 26308de3..63d85304 100755 --- a/rootdir/etc/init.pyramid.rc +++ b/rootdir/etc/init.pyramid.rc @@ -1,13 +1,20 @@ import init.pyramid.usb.rc on early-init - write /sys/devices/system/cpu/cpu1/online 1 - write /sys/block/mmcblk0/bdi/read_ahead_kb 512 - write /sys/block/mmcblk0/queue/scheduler noop + write /sys/devices/system/cpu/cpu1/online 1 + write /sys/block/mmcblk0/bdi/read_ahead_kb 512 + write /sys/block/mmcblk0/queue/scheduler noop + write /sys/block/mmcblk1/bdi/read_ahead_kb 512 + write /sys/block/mmcblk1/queue/scheduler noop - # ZRAM - write /sys/block/zram0/comp_algorithm lz4 - write /sys/block/zram0/max_comp_streams 2 + # ZRAM + write /sys/block/zram0/comp_algorithm lz4 + write /sys/block/zram0/max_comp_streams 2 + + # UKMS + write /sys/kernel/mm/uksm/run 1 + write /sys/kernel/mm/uksm/cpu_governor medium + write /sys/kernel/mm/uksm/sleep_millisecs 500 on init mkdir /devlog 0700 root root @@ -46,7 +53,10 @@ on fs mkdir /firmware_q6 0771 system system # mount all mmc partitions mount_all /fstab.pyramid + # init and enable swap partitions (zram and cache) + mkswap /dev/block/platform/msm_sdcc.1/by-name/cache swapon_all /fstab.pyramid + write /proc/sys/vm/swappiness 60 mkdir /data/tombstones 0771 system system symlink /data/tombstones /tombstones @@ -259,21 +269,20 @@ service dhcpcd_wlan0 /system/bin/dhcpcd -ABKL oneshot service dhcpcd_p2p /system/bin/dhcpcd -aABKL - disabled - oneshot + disabled + oneshot service dhcpcd_bt-pan /system/bin/dhcpcd -ABKL - disabled - oneshot + disabled + oneshot service iprenew_bt-pan /system/bin/dhcpcd -n - disabled - oneshot + disabled + oneshot service iprenew_wlan0 /system/bin/dhcpcd -n - disabled - oneshot -# wifi-- + disabled + oneshot # external sdcard daemon running as media_rw (1023) service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1 @@ -286,6 +295,9 @@ service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emul on property:init.svc.bootanim=stopped start qcom-post-boot + # config storage access + write /sys/block/mmcblk0/queue/scheduler fiops + write /sys/block/mmcblk1/queue/scheduler row on property:ro.hdmi.enable=true start hdmid @@ -336,9 +348,5 @@ on property:sys.boot_completed=1 # Wake on volume write /sys/keyboard/vol_wakeup 1 -on property:init.svc.bootanim=stopped - write /sys/block/mmcblk0/queue/scheduler fiops - on property:sys.radio.shutdown=true exec /system/bin/sh /system/etc/init.qcom.efs.sync.sh - diff --git a/rootdir/etc/init.pyramid.sh b/rootdir/etc/init.pyramid.sh index 4429f84b..127ef985 100755 --- a/rootdir/etc/init.pyramid.sh +++ b/rootdir/etc/init.pyramid.sh @@ -1,28 +1,38 @@ #!/system/bin/sh export PATH=${PATH}:/system/bin/:/system/xbin/ +LOG="/cache/${0}.log" + +log -p i -t userinit "[${0}][Start]" # Log related mounts and mount points before -log -p i -t userinit "[${0}] Before" -echo "[${0}] Before" >> /cache/${0}.log -mount >> /cache/${0}.log -ls -la /data/ >> /cache/${0}.log -ls -la /data1/ >> /cache/${0}.log +echo "[Start]" >> ${LOG} +mount >> ${LOG} +echo "[/]" >> ${LOG} +ls -la / >> ${LOG} +echo "[/data]" >> ${LOG} +ls -la /data/ >> ${LOG} +echo "[/data1]" >> ${LOG} +ls -la /data1/ >> ${LOG} +du -sch /data1/* >> ${LOG} -# Attempt to link data content to secondary data (optional) +# Attempt to link data components to secondary data (optional) # If we fail those locations will be used as usual # Ensure permissions are set correctly -test -d /data1/app && chmod 0771 /data1/app && chown system:system /data1/app && rm -Rf /data/app && ln -s /data1/app /data/app && log -p i -t userinit "[${0}] Linked /data1/app" && echo "[${0}] Linked /data1/app" >> /cache/${0}.log -#test -d /data1/app-asec && chmod 0700 /data1/app-asec && chown root:root /data1/app-asec && rm -Rf /data/app-asec && ln -s /data1/app-asec /data/app-asec && log -p i -t userinit "[${0}] Linked /data1/app-asec" && echo "[${0}] Linked /data1/app-asec" >> /cache/${0}.log -#test -d /data1/app-lib && chmod 0771 /data1/app-lib && chown system:system /data1/app-lib && rm -Rf /data/app-lib && ln -s /data1/app-lib /data/app-lib && log -p i -t userinit "[${0}] Linked /data1/app-lib" && echo "[${0}] Linked /data1/app-lib" >> /cache/${0}.log -#test -d /data1/app-private && chmod 0771 /data1/app-private && chown system:system /data1/app-private && rm -Rf /data/app-private && ln -s /data1/app-private /data/app-private && log -p i -t userinit "[${0}] Linked /data1/app-private" && echo "[${0}] Linked /data1/app-private" >> /cache/${0}.log -test -d /data1/dalvik-cache && chmod 0771 /data1/dalvik-cache && chown root:root /data1/dalvik-cache && rm -Rf /data/dalvik-cache && ln -s /data1/dalvik-cache /data/dalvik-cache && log -p i -t userinit "[${0}] Linked /data1/dalvik-cache" && echo "[${0}] Linked /data1/dalvik-cache" >> /cache/${0}.log -test -d /data1/data && chmod 0771 /data1/data && chown system:system /data1/data && rm -Rf /data/data && ln -s /data1/data /data/data && log -p i -t userinit "[${0}] Linked /data1/data" && echo "[${0}] Linked /data1/data" >> /cache/${0}.log -test -d /data1/media && chmod 0770 /data1/media && chown media_rw:media_rw /data1/media && rm -Rf /data/media && ln -s /data1/media /data/media && log -p i -t userinit "[${0}] Linked /data1/media" && echo "[${0}] Linked /data1/media" >> /cache/${0}.log +test -d /data1/dalvik-cache && chmod 0771 /data1/dalvik-cache && chown root:root /data1/dalvik-cache && rm -Rf /data/dalvik-cache && ln -s /data1/dalvik-cache /data/dalvik-cache && log -p i -t userinit "[${0}] Linked /data1/dalvik-cache" && echo "[${0}] Linked /data1/dalvik-cache" >> ${LOG} +test -d /data1/app && chmod 0771 /data1/app && chown system:system /data1/app && rm -Rf /data/app && ln -s /data1/app /data/app && log -p i -t userinit "[${0}] Linked /data1/app" && echo "[${0}] Linked /data1/app" >> ${LOG} +test -d /data1/data && chmod 0771 /data1/data && chown system:system /data1/data && rm -Rf /data/data && ln -s /data1/data /data/data && log -p i -t userinit "[${0}] Linked /data1/data" && echo "[${0}] Linked /data1/data" >> ${LOG} +test -d /data1/media && chmod 0770 /data1/media && chown media_rw:media_rw /data1/media && rm -Rf /data/media && ln -s /data1/media /data/media && log -p i -t userinit "[${0}] Linked /data1/media" && echo "[${0}] Linked /data1/media" >> ${LOG} # Log related mounts and mount points after -log -p i -t userinit "[${0}] After" -echo "[${0}] After" >> /cache/${0}.log -mount >> /cache/${0}.log -ls -la /data/ >> /cache/${0}.log -ls -la /data1/ >> /cache/${0}.log +echo "[Stop]" >> ${LOG} +mount >> ${LOG} +echo "[/]" >> ${LOG} +ls -la / >> ${LOG} +echo "[/data]" >> ${LOG} +ls -la /data/ >> ${LOG} +echo "[/data1]" >> ${LOG} +ls -la /data1/ >> ${LOG} +du -sch /data1/* >> ${LOG} + +log -p i -t userinit "[${0}][Stop]" diff --git a/system_prop.mk b/system_prop.mk index f658125f..bdf56a85 100644 --- a/system_prop.mk +++ b/system_prop.mk @@ -5,27 +5,26 @@ PRODUCT_PROPERTY_OVERRIDES += \ ro.sf.lcd_density=240 -# radio +# Radio PRODUCT_PROPERTY_OVERRIDES += \ mobiledata.interfaces=rmnet0 \ rild.libpath=/system/lib/libhtc_ril.so \ ro.telephony.ril_class=HtcMsm8660RIL -# wifi +# WiFi PRODUCT_PROPERTY_OVERRIDES += \ - wifi.interface=wlan0 + wifi.interface=wlan0 # UMS PRODUCT_PROPERTY_OVERRIDES += \ - persist.sys.usb.config=mtp,adb \ ro.vold.umsdirtyratio=20 -# tweaks +# Tweaks PRODUCT_PROPERTY_OVERRIDES += \ - dalvik.vm.dexopt-data-only=1 \ - dalvik.vm.dexopt-flags=m=y \ - windowsmgr.max_events_per_sec=300 \ - pm.sleep_mode=1 + dalvik.vm.dexopt-data-only=1 \ + dalvik.vm.dexopt-flags=m=y \ + windowsmgr.max_events_per_sec=300 \ + pm.sleep_mode=1 # Display PRODUCT_PROPERTY_OVERRIDES += \