plugin-api: resourced: Add a skeleton of get_kill_candidates_post funcs 95/294695/14
authorUnsung Lee <unsung.lee@samsung.com>
Thu, 22 Jun 2023 02:43:05 +0000 (11:43 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Sun, 30 Jul 2023 04:46:33 +0000 (13:46 +0900)
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 <unsung.lee@samsung.com>
src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk-interface.h
src/plugin-api/resourced/include/syscommon-plugin-resourced-memory-lmk.h
src/plugin-api/resourced/src/syscommon-plugin-resourced-memory-lmk.c

index 9bfc4ac..3b7447a 100644 (file)
@@ -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
index 5f1a8b5..bdcb8e8 100644 (file)
@@ -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
index c79eeb0..205e975 100644 (file)
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+#include <assert.h>
 #include <glib.h>
 
 #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);
+}