From 544876dbd9415ff28f6401f6197f6e45a1c0759f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosme=20Dom=C3=ADnguez=20D=C3=ADaz?= Date: Sun, 6 May 2018 16:36:28 +0200 Subject: msm8996-common: Disable Transparent Huge Pages (THP) when we don't have enough RAM. * My device has 6GB of RAM so I didn't notice any issue. However devices with 3GB or less become unusable with THP enabled, according to @YaroST12 * Also, for devices with enough RAM, we'll restrict THP to madvise regions as suggested by the kernel documentation: "Embedded systems should enable hugepages only inside madvise regions to eliminate any risk of wasting any precious byte of memory and to only run faster." [1] [1] https://www.kernel.org/doc/Documentation/vm/transhuge.txt --- rootdir/etc/init.qcom.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'rootdir') diff --git a/rootdir/etc/init.qcom.sh b/rootdir/etc/init.qcom.sh index 46f5fa4..3004dfa 100755 --- a/rootdir/etc/init.qcom.sh +++ b/rootdir/etc/init.qcom.sh @@ -67,3 +67,14 @@ fi cp /firmware/image/modem_pr/mbn_ota.txt /data/vendor/radio/modem_config chown radio.radio /data/vendor/radio/modem_config/mbn_ota.txt echo 1 > /data/vendor/radio/copy_complete + +MemTotalStr=`cat /proc/meminfo | grep MemTotal` +MemTotal=${MemTotalStr:16:8} + +if [ $MemTotal -lt 5242880 ]; then + echo never > /sys/kernel/mm/transparent_hugepage/enabled + echo never > /sys/kernel/mm/transparent_hugepage/defrag +else + echo madvise > /sys/kernel/mm/transparent_hugepage/enabled + echo madvise > /sys/kernel/mm/transparent_hugepage/defrag +fi -- cgit v1.2.3