From 884a19ba6eed71315627784b33812c48c7fd9d6d Mon Sep 17 00:00:00 2001 From: Louis Popi Date: Mon, 20 Feb 2017 09:47:23 +0100 Subject: msm8916-common: Use CAF Memory configuration script Change-Id: I9f38d9176c646f7951203f626b82dfbd251ed3b9 --- product/init.mk | 1 + rootdir/Android.mk | 7 +++ rootdir/etc/init.qcom.mem.sh | 84 ++++++++++++++++++++++++++++++++++ rootdir/etc/init.qcom.power_msm8916.rc | 2 + rootdir/etc/init.qcom.power_msm8939.rc | 9 +--- rootdir/etc/init.qcom.rc | 4 ++ 6 files changed, 100 insertions(+), 7 deletions(-) create mode 100755 rootdir/etc/init.qcom.mem.sh diff --git a/product/init.mk b/product/init.mk index 069c202..f3744ec 100644 --- a/product/init.mk +++ b/product/init.mk @@ -1,6 +1,7 @@ # Init scripts PRODUCT_PACKAGES += \ init.qcom.rc \ + init.qcom.mem.sh \ init.qcom.power.rc \ init.qcom.ssr.rc \ init.recovery.qcom.rc \ diff --git a/rootdir/Android.mk b/rootdir/Android.mk index 8cd0b4f..922e6e1 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -9,6 +9,13 @@ LOCAL_MODULE_CLASS := ETC LOCAL_SRC_FILES := etc/init.qcom.bt.sh include $(BUILD_PREBUILT) +include $(CLEAR_VARS) +LOCAL_MODULE := init.qcom.mem.sh +LOCAL_MODULE_TAGS := optional eng +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.qcom.mem.sh +include $(BUILD_PREBUILT) + # Init scripts include $(CLEAR_VARS) diff --git a/rootdir/etc/init.qcom.mem.sh b/rootdir/etc/init.qcom.mem.sh new file mode 100755 index 0000000..743e599 --- /dev/null +++ b/rootdir/etc/init.qcom.mem.sh @@ -0,0 +1,84 @@ +#!/system/bin/sh +# Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Set Memory paremeters. +# +# Set per_process_reclaim tuning parameters +# 2GB 64-bit will have aggressive settings when compared to 1GB 32-bit +# 1GB and less will use vmpressure range 50-70, 2GB will use 10-70 +# 1GB and less will use 512 pages swap size, 2GB will use 1024 +# +# Set Low memory killer minfree parameters +# 32 bit all memory configurations will use 15K series +# 64 bit all memory configurations will use 18K series +# +# Set ALMK parameters (usually above the highest minfree values) +# 32 bit will have 53K & 64 bit will have 81K +# + +arch_type=`uname -m` +MemTotalStr=`cat /proc/meminfo | grep MemTotal` +MemTotal=${MemTotalStr:16:8} +MEMORY_THRESHOLD=1048576 +IsLowMemory=MemTotal /sys/module/lowmemorykiller/parameters/adj_max_shift +echo $set_almk_ppr_adj > /sys/module/process_reclaim/parameters/min_score_adj + +echo 1 > /sys/module/process_reclaim/parameters/enable_process_reclaim +echo 70 > /sys/module/process_reclaim/parameters/pressure_max +echo 30 > /sys/module/process_reclaim/parameters/swap_opt_eff +echo 1 > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk + +if [ "$arch_type" == "aarch64" ] && [ $MemTotal -gt 1048576 ]; then + echo 10 > /sys/module/process_reclaim/parameters/pressure_min + echo 1024 > /sys/module/process_reclaim/parameters/per_swap_size + echo "18432,23040,27648,32256,55296,80640" > /sys/module/lowmemorykiller/parameters/minfree + echo 81250 > /sys/module/lowmemorykiller/parameters/vmpressure_file_min +elif [ "$arch_type" == "aarch64" ] && [ $MemTotal -lt 1048576 ]; then + echo 50 > /sys/module/process_reclaim/parameters/pressure_min + echo 512 > /sys/module/process_reclaim/parameters/per_swap_size + echo "18432,23040,27648,32256,55296,80640" > /sys/module/lowmemorykiller/parameters/minfree + echo 81250 > /sys/module/lowmemorykiller/parameters/vmpressure_file_min +else + echo 50 > /sys/module/process_reclaim/parameters/pressure_min + echo 512 > /sys/module/process_reclaim/parameters/per_swap_size + echo "15360,19200,23040,26880,34415,43737" > /sys/module/lowmemorykiller/parameters/minfree + echo 53059 > /sys/module/lowmemorykiller/parameters/vmpressure_file_min +fi diff --git a/rootdir/etc/init.qcom.power_msm8916.rc b/rootdir/etc/init.qcom.power_msm8916.rc index f7bb26c..7f4e287 100644 --- a/rootdir/etc/init.qcom.power_msm8916.rc +++ b/rootdir/etc/init.qcom.power_msm8916.rc @@ -1,4 +1,6 @@ on enable-low-power + start qcom-mem + # HMP scheduler load tracking settings write /proc/sys/kernel/sched_window_stats_policy 3 write /proc/sys/kernel/sched_ravg_hist_size 3 diff --git a/rootdir/etc/init.qcom.power_msm8939.rc b/rootdir/etc/init.qcom.power_msm8939.rc index e79610d..1f4a424 100644 --- a/rootdir/etc/init.qcom.power_msm8939.rc +++ b/rootdir/etc/init.qcom.power_msm8939.rc @@ -1,4 +1,6 @@ on enable-low-power + start qcom-mem + write /proc/sys/kernel/sched_boost 1 # RPS mask @@ -76,13 +78,6 @@ on enable-low-power write /dev/cpuset/system-background/cpus 4-6 write /dev/cpuset/top-app/cpus 0-7 - # Per-process reclaim - write /sys/module/process_reclaim/parameters/enable_process_reclaim 1 - write /sys/module/process_reclaim/parameters/pressure_min 10 - write /sys/module/process_reclaim/parameters/per_swap_size 1024 - write /sys/module/process_reclaim/parameters/pressure_max 70 - write /sys/module/process_reclaim/parameters/swap_opt_eff 30 - rm /data/system/perfd/default_values start perfd diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc index ef1ede8..800ca37 100644 --- a/rootdir/etc/init.qcom.rc +++ b/rootdir/etc/init.qcom.rc @@ -477,3 +477,7 @@ service wcnss-service /system/bin/wcnss_service user system group system wifi radio oneshot + +service qcom-mem /system/bin/sh /system/etc/init.qcom.mem.sh + disabled + oneshot -- cgit v1.2.3