4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is furnished
11 * to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #ifndef __SYSCOMMON_PLUGIN_RESOURCED_MEMORY_LMK_H__
26 #define __SYSCOMMON_PLUGIN_RESOURCED_MEMORY_LMK_H__
37 * Mostly, there are not multiple processes with the same pgid.
38 * So, for the frequent case, we use pid variable to avoid
44 /* oom_score_adj is smae as /proc/<pid>/oom_score_adj */
47 * oom_score_lru is same as oom_score_adj or adjusted by
48 * proc_app_info lru_state for apps that are marked as favourite.
50 * oom_score_lru is the main value used in comparison for LMK.
55 * proc_app_info_oom_killed and proc_app_info_flags
56 * are not used if task is not an app.
57 * Especially, proc_app_info_oom_killed is NULL when this task
60 bool *proc_app_info_oom_killed;
61 int proc_app_info_flags;
64 * TODO: A process can have more than one window,
65 * and an app can have more than one process. Therefore,
66 * a task_info can have more than one window.
84 * @brief Get the backend data of resourced-memory-lmk module
85 * @return @c 0 on success, otherwise a negative error value
87 int syscommon_plugin_resourced_memory_lmk_get_backend(void);
90 * @brief Put the backend data of resourced-memory-lmk module
91 * @return @c 0 on success, otherwise a negative error value
93 int syscommon_plugin_resourced_memory_lmk_put_backend(void);
96 * @brief Call the get_kill_candidates function of resourced-memory-lmk module
97 * @param[in] candidates is an an GArray to return kill candidates
98 * @param[in] task_info_app_array is a GArray that contains app info
99 * @param[in] task_info_proc_array is a GArray that contains process info
100 * @param[in] totalram_kb is the total amount of memory in kibibytes
101 * @return @c the number of kill candidates on success,
102 * otherwise a negative error value
104 int syscommon_plugin_resourced_memory_lmk_get_kill_candidates(
106 GArray *task_info_app_array,
107 GArray *task_info_proc_array,
108 unsigned long totalram_kb);
111 * @brief Reorder candidates list, sorted first by get_kill_candidates fuction,
112 according to custom rule
113 * @param[in] candidates is a GArray to return kill candidates, it is already
114 sorted by get_kill_candidates
115 * @return @c zero on success,
116 * otherwise a negative error value
118 int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post(
122 * @brief Reorder candidates list sorted first by get_kill_candidates fuction
123 according to working set size rule
124 * @param[in] candidates is a GArray to return kill candidates, it is already
125 sorted by get_kill_candidates
126 * @return @c zero on success,
127 * otherwise a negative error value
129 int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_wss(
133 * @brief Reorder candidates list sorted first by get_kill_candidates fuction
134 according to foreground rule (i.e., rule for foreground apps)
135 * @param[in] candidates is a GArray to return kill candidates, it is already
136 sorted by get_kill_candidates
137 * @return @c zero on success,
138 * otherwise a negative error value
140 int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_foreground(
147 #endif /* __SYSCOMMON_PLUGIN_RESOURCED_MEMORY_LMK_H__ */