README.md
1Android Low Memory Killer Daemon
2================================
3
4
5Introduction
6------------
7
8Android Low Memory Killer Daemon (lmkd) is a process monitoring memory
9state of a running Android system and reacting to high memory pressure
10by killing the least essential process(es) to keep system performing
11at acceptable levels.
12
13
14Background
15----------
16
17Historically on Android systems memory monitoring and killing of
18non-essential processes was handled by a kernel lowmemorykiller driver.
19Since Linux Kernel 4.12 the lowmemorykiller driver has been removed and
20instead userspace lmkd daemon performs these tasks.
21
22
23Android Properties
24------------------
25
26lmkd can be configured on a particular system using the following Android
27properties:
28
29 - `ro.config.low_ram`: choose between low-memory vs high-performance
30 device. Default = false.
31
32 - `ro.lmk.use_minfree_levels`: use free memory and file cache thresholds for
33 making decisions when to kill. This mode works
34 the same way kernel lowmemorykiller driver used
35 to work. Default = false
36
37 - `ro.lmk.low`: min oom_adj score for processes eligible to be
38 killed at low vmpressure level. Default = 1001
39 (disabled)
40
41 - `ro.lmk.medium`: min oom_adj score for processes eligible to be
42 killed at medium vmpressure level. Default = 800
43 (non-essential processes)
44
45 - `ro.lmk.critical`: min oom_adj score for processes eligible to be
46 killed at critical vmpressure level. Default = 0
47 (all processes)
48
49 - `ro.lmk.critical_upgrade`: enables upgrade to critical level. Default = false
50
51 - `ro.lmk.upgrade_pressure`: max mem_pressure at which level will be upgraded
52 because system is swapping too much. Default = 100
53 (disabled)
54
55 - `ro.lmk.downgrade_pressure`: min mem_pressure at which vmpressure event will
56 be ignored because enough free memory is still
57 available. Default = 100 (disabled)
58
59 - `ro.lmk.kill_heaviest_task`: kill heaviest eligible task (best decision) vs.
60 any eligible task (fast decision). Default = false
61
62 - `ro.lmk.kill_timeout_ms`: duration in ms after a kill when no additional
63 kill will be done. Default = 100
64
65 - `ro.lmk.debug`: enable lmkd debug logs, Default = false
66
67 - `ro.lmk.swap_free_low_percentage`: level of free swap as a percentage of the
68 total swap space used as a threshold to consider
69 the system as swap space starved. Default = 10
70
71 - `ro.lmk.thrashing_limit`: number of workingset refaults as a percentage of
72 the file-backed pagecache size used as a threshold
73 to consider system thrashing its pagecache.
74 Default for low-RAM devices = 30, for high-end
75 devices = 100
76
77 - `ro.lmk.thrashing_limit_decay`: thrashing threshold decay expressed as a
78 percentage of the original threshold used to lower
79 the threshold when system does not recover even
80 after a kill. Default for low-RAM devices = 50,
81 for high-end devices = 10
82
83 - `ro.lmk.psi_partial_stall_ms`: partial PSI stall threshold in milliseconds for
84 triggering low memory notification. Default for
85 low-RAM devices = 200, for high-end devices = 70
86
87 - `ro.lmk.psi_complete_stall_ms`: complete PSI stall threshold in milliseconds for
88 triggering critical memory notification. Default =
89 700
90 - `ro.lmk.pressure_after_kill_min_score`: min oom_adj_score score threshold for
91 cycle after kill used to allow blocking of killing
92 critical processes when not enough memory was freed
93 in a kill cycle. Default score = 0.
94 - `ro.lmk.direct_reclaim_threshold_ms`: direct reclaim duration threshold in
95 milliseconds to consider the system as stuck in
96 direct reclaim. Default = 0 (disabled)
97 - `ro.lmk.swap_compression_ratio`: swap average compression ratio to be used when
98 estimating how much data can be swapped. Setting it
99 to 0 will ignore available memory and assume that
100 configured swap size can be always utilized fully.
101 Default = 1 (no compression).
102 - `ro.lmk.lowmem_min_oom_score`: min oom_score_adj level used to select processes
103 to kill when memory is critically low. Setting it
104 to 1001 will prevent any kills for this reason. Min
105 acceptable value is 201 (apps up to perceptible).
106 Default = 701 (all cached apps excluding the last
107 active one).
108
109lmkd will set the following Android properties according to current system
110configurations:
111
112 - `sys.lmk.minfree_levels`: minfree:oom_adj_score pairs, delimited by comma
113
114 - `sys.lmk.reportkills`: whether or not it supports reporting process kills
115 to clients. Test app should check this property
116 before testing low memory kill notification.
117 Default will be unset.
118