summaryrefstree
path: root/boot/ramdisk/init.ram.rc
blob: d75fde774b30e7af12b29b2909de784f95eb8677 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#    All memory configuration as following, which include ZRAM, LMK, RTCC,
# KSM, and some memory properties. The configurations parameters could
# auto-adaptive according to memory size.
#    The Value of property ro.run.ramconfig should be {ro.ramsize} / 256, but if diff
# ro.ramsize use the same memory configuration parameters, the Value ro.run.ramconfig
# should be the same. such as 512M, 768M use the same configurations parameters.
#
#    NOTE : IF Add new ro.run.ramconfig, PLEASE copy the configurations
# between BEGIN line and  END line, Then change the parameters that you want.

on early-boot
    chown system root /sys/class/rtcc/rtcc_trigger


# Table ro.ramsize mapping to ro.run.ramconfig
on property:ro.ramsize=512M
    setprop ro.run.ramconfig 2
on property:ro.ramsize=768M
    setprop ro.run.ramconfig 2

on property:ro.ramsize=1024M
    setprop ro.run.ramconfig 4
on property:ro.ramsize=1536M
    setprop ro.run.ramconfig 4
on property:ro.ramsize=2048M
    setprop ro.run.ramconfig 4


######## ramconfig=2,3 memory parameter configurations BEGIN #######
on property:ro.run.ramconfig=2
    setprop ro.config.low_ram true

#Set ZRAM configure parameters
    setprop zram.disksize 400
    write /proc/sys/vm/extra_free_kbytes 10240

#Set LMK watermark as {18M,30M,54M,66M,78M,90M}
    write /sys/module/lowmemorykiller/parameters/adj 0,100,200,600,900,906
    write /sys/module/lowmemorykiller/parameters/minfree 4608,7680,13824,16896,30720,38400
    setprop sys.lmk.adj "0,100,200,600,900,906"
    setprop sys.lmk.minfree "4608,7680,13824,16896,30720,38400"
    setprop lmk.autocalc false

#Enable KSM and ZRAM
    setprop ro.config.ksm.support true
    setprop ro.config.zram.support true

######## ramconfig=2,3 memory parameter configurations END #########


######## ramconfig=4,6,8 memory parameter configurations BEGIN #######
on property:ro.run.ramconfig=4
    setprop ro.config.low_ram false

#Set ZRAM configure parameters
    setprop zram.disksize 600
    write /proc/sys/vm/extra_free_kbytes 4096

#Set LMK watermark as {45M,54M,63M,72M,80M,92MB}
    write /sys/module/lowmemorykiller/parameters/adj 0,100,300,800,900,906
    write /sys/module/lowmemorykiller/parameters/minfree 11520,13824,16128,18432,36864,46080
    setprop sys.lmk.adj "0,100,300,800,900,906"
    setprop sys.lmk.minfree "11520,13824,16128,18432,36864,46080"
    setprop lmk.autocalc false

#Set RTCC minfree watermarks as {224M,192M,160M,128M,96M}
    write /sys/module/rtcc/parameters/minfree 57344,49152,40960,32768,24576

#Enable ZRAM
    setprop ro.config.zram.support true

######## ramconfig=4,6,8 memory parameter configurations END #########


#Configurate ZRAM, then start zram service
on property:ro.config.zram.support=true
    setprop sys.vm.swappiness 30
    write /proc/sys/vm/page-cluster  0
    start zram

#Configurate KSM, then run KSM
on property:ro.config.ksm.support=true
    write /sys/kernel/mm/ksm/pages_to_scan 100
    write /sys/kernel/mm/ksm/sleep_millisecs 500
    write /sys/kernel/mm/ksm/run   1