From: Unsung Lee Date: Thu, 22 Jun 2023 02:43:05 +0000 (+0900) Subject: plugin-api: resourced: Add a skeleton of get_kill_candidates_post funcs X-Git-Tag: accepted/tizen/unified/20230803.174812~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd9e938afd953da3504b82ef76da4a78cb84e03b;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git plugin-api: resourced: Add a skeleton of get_kill_candidates_post funcs Add a skeleton of three get_kill_candidates_post funcs. These functions are directly mapped to get_kill_candidates_post funcs in resourced backend. Support LMK governor post funcs which will be called after LMK governor function to reorder a victim candidate list resourced supports three type of get_kill_candidates_post ops newly - int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post( GArray *candidates) to consider user custom governor policy - int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_wss( GArray *candidates) to consider working set size of app - int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_foreground( GArray *candidates) to consider window information of app Change-Id: I2a3c42635ce105f4400a68c8c382fb6548a11f8e Signed-off-by: Unsung Lee --- diff --git a/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk-interface.h b/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk-interface.h index 9bfc4ac..3b7447a 100644 --- a/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk-interface.h +++ b/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk-interface.h @@ -36,7 +36,9 @@ typedef struct _syscommon_plugin_backend_resourced_memory_lmk_funcs { GArray *task_info_app_array, GArray *task_info_proc_array, unsigned long totalram_kb); - + int (*get_kill_candidates_post)(GArray *candidates); + int (*get_kill_candidates_post_with_wss)(GArray *candidates); + int (*get_kill_candidates_post_with_foreground)(GArray *candidates); } syscommon_plugin_backend_resourced_memory_lmk_funcs; #ifdef __cplusplus diff --git a/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk.h b/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk.h index 5f1a8b5..bdcb8e8 100644 --- a/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk.h +++ b/src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk.h @@ -107,6 +107,39 @@ int syscommon_plugin_resourced_memory_lmk_get_kill_candidates( GArray *task_info_proc_array, unsigned long totalram_kb); +/** + * @brief Reorder candidates list, sorted first by get_kill_candidates fuction, + according to custom rule + * @param[in] candidates is a GArray to return kill candidates, it is already + sorted by get_kill_candidates + * @return @c zero on success, + * otherwise a negative error value + */ +int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post( + GArray *candidates); + +/** + * @brief Reorder candidates list sorted first by get_kill_candidates fuction + according to working set size rule + * @param[in] candidates is a GArray to return kill candidates, it is already + sorted by get_kill_candidates + * @return @c zero on success, + * otherwise a negative error value + */ +int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_wss( + GArray *candidates); + +/** + * @brief Reorder candidates list sorted first by get_kill_candidates fuction + according to foreground rule (i.e., rule for foreground apps) + * @param[in] candidates is a GArray to return kill candidates, it is already + sorted by get_kill_candidates + * @return @c zero on success, + * otherwise a negative error value + */ +int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_foreground( + GArray *candidates); + #ifdef __cplusplus } #endif 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 c79eeb0..205e975 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 @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include #include #include "syscommon-plugin-common.h" @@ -104,3 +105,66 @@ int syscommon_plugin_resourced_memory_lmk_get_kill_candidates( task_info_proc_array, totalram_kb); } + +EXPORT +int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post( + GArray *candidates) +{ + int ret = 0; + + if (!funcs) { + ret = syscommon_plugin_resourced_memory_lmk_get_backend(); + if (ret < 0) + return ret; + } + + assert(funcs); + if (!funcs->get_kill_candidates_post) { + _E("No \"get_kill_candidates_post\" function"); + return -ENOTSUP; + } + + return funcs->get_kill_candidates_post(candidates); +} + +EXPORT +int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_wss( + GArray *candidates) +{ + int ret = 0; + + if (!funcs) { + ret = syscommon_plugin_resourced_memory_lmk_get_backend(); + if (ret < 0) + return ret; + } + + assert(funcs); + if (!funcs->get_kill_candidates_post_with_wss) { + _E("No \"get_kill_candidates_post_with_wss\" function"); + return -ENOTSUP; + } + + return funcs->get_kill_candidates_post_with_wss(candidates); +} + +EXPORT +int syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_foreground( + GArray *candidates) +{ + int ret = 0; + + if (!funcs) { + ret = syscommon_plugin_resourced_memory_lmk_get_backend(); + if (ret < 0) + return ret; + } + + assert(funcs); + if (!funcs->get_kill_candidates_post_with_foreground) { + _E("No \"get_kill_candidates_post_with_foreground\" function"); + return -ENOTSUP; + } + + return funcs->get_kill_candidates_post_with_foreground(candidates); +}