From 617110ad7fb7e15be6e18237ae357854ae7fa298 Mon Sep 17 00:00:00 2001 From: Unsung Lee Date: Tue, 5 Sep 2023 10:41:26 +0900 Subject: [PATCH] plugin-api: resourced: Move common struct and enum from *.h to *-interface.h Move common struct and enum, referened by both resourced and resourced backend, from syscommon-plugin-resourced-memory-lmk.h to syscommon-plugin-resourced-memory-lmk-interface.h for consistency. *.h can be referenced only by resourced. On the other hand, *-interface.h can be referenced by both side. Therefore, common struct and enum should be defined in *-interface.h. Change-Id: I0529e21da6688eeebb9a0583521dc69c2e400f2c Signed-off-by: Unsung Lee --- ...on-plugin-resourced-memory-lmk-interface.h | 56 ++++++++++++++++++ .../syscommon-plugin-resourced-memory-lmk.h | 58 +------------------ .../syscommon-plugin-resourced-memory-lmk.c | 1 - 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h index a07f0c4..2d3d746 100644 --- a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk-interface.h @@ -31,6 +31,62 @@ extern "C" { #endif +enum syscommon_resourced_memory_lmk_oom_level { + OOM_LEVEL_BACKGROUND_LEAST_RECENTLY_USED, + OOM_LEVEL_BACKGROUND_MOST_RECENTLY_USED, + OOM_LEVEL_FOREGROUND, + OOM_LEVEL_FOREGROUND_AND_PROC, + OOM_LEVEL_ALL, +}; + +struct task_info { + /* + * Mostly, there are not multiple processes with the same pgid. + * So, for the frequent case, we use pid variable to avoid + * allocating arrays. + */ + pid_t pid; + GArray *pids; + pid_t pgid; + /* oom_score_adj is smae as /proc//oom_score_adj */ + int oom_score_adj; + /* + * oom_score_lru is same as oom_score_adj or adjusted by + * proc_app_info lru_state for apps that are marked as favourite. + * + * oom_score_lru is the main value used in comparison for LMK. + */ + int oom_score_lru; + int size; + /** + * proc_app_info_oom_killed and proc_app_info_flags + * are not used if task is not an app. + * Especially, proc_app_info_oom_killed is NULL when this task + * is not an app. + */ + bool *proc_app_info_oom_killed; + int proc_app_info_flags; + + /** + * TODO: A process can have more than one window, + * and an app can have more than one process. Therefore, + * a task_info can have more than one window. + */ + int window_pid; + int x; + int y; + int z; + int w; + int h; + int layer; + int opaque; + int visibility; + bool is_transformed; + bool alpha; + bool is_focused; + bool is_mapped; +}; + typedef struct _syscommon_plugin_backend_resourced_memory_lmk_funcs { int (*get_kill_candidates)(GArray *candidates, GArray *task_info_app_array, diff --git a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h index d3d5b67..b2ac1b0 100644 --- a/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h +++ b/src/plugin-api/resourced/include/system/syscommon-plugin-resourced-memory-lmk.h @@ -28,66 +28,12 @@ #include #include +#include "syscommon-plugin-resourced-memory-lmk-interface.h" + #ifdef __cplusplus extern "C" { #endif -enum syscommon_resourced_memory_lmk_oom_level { - OOM_LEVEL_BACKGROUND_LEAST_RECENTLY_USED, - OOM_LEVEL_BACKGROUND_MOST_RECENTLY_USED, - OOM_LEVEL_FOREGROUND, - OOM_LEVEL_FOREGROUND_AND_PROC, - OOM_LEVEL_ALL, -}; - -struct task_info { - /* - * Mostly, there are not multiple processes with the same pgid. - * So, for the frequent case, we use pid variable to avoid - * allocating arrays. - */ - pid_t pid; - GArray *pids; - pid_t pgid; - /* oom_score_adj is smae as /proc//oom_score_adj */ - int oom_score_adj; - /* - * oom_score_lru is same as oom_score_adj or adjusted by - * proc_app_info lru_state for apps that are marked as favourite. - * - * oom_score_lru is the main value used in comparison for LMK. - */ - int oom_score_lru; - int size; - /** - * proc_app_info_oom_killed and proc_app_info_flags - * are not used if task is not an app. - * Especially, proc_app_info_oom_killed is NULL when this task - * is not an app. - */ - bool *proc_app_info_oom_killed; - int proc_app_info_flags; - - /** - * TODO: A process can have more than one window, - * and an app can have more than one process. Therefore, - * a task_info can have more than one window. - */ - int window_pid; - int x; - int y; - int z; - int w; - int h; - int layer; - int opaque; - int visibility; - bool is_transformed; - bool alpha; - bool is_focused; - bool is_mapped; -}; - /** * @brief Get the backend data of resourced-memory-lmk module * @return @c 0 on success, otherwise a negative error value diff --git a/src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c b/src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c index 0d97201..6ccb8b2 100644 --- a/src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c +++ b/src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c @@ -29,7 +29,6 @@ #include #include -#include #ifndef EXPORT #define EXPORT __attribute__((visibility("default"))) -- 2.34.1