#include <eventsystem.h>
#include <malloc.h>
+#include <system/syscommon-plugin-resourced-memory-lmk.h>
+
#include "trace.h"
#include "cgroup.h"
#include "lowmem.h"
return lowmem_task_info_proc_array;
}
-struct lowmem_governor_ops {
- int(*get_kill_candidates)(GArray *, GArray *, GArray *, unsigned long);
-};
-
-static struct lowmem_governor_ops governor_ops = { NULL };
-void lowmem_register_lmk_governor(int(*get_kill_candidates)(GArray *,
- GArray *, GArray *, unsigned long))
-{
- governor_ops.get_kill_candidates = get_kill_candidates;
-}
-
static int(*lowmem_controller_kill_candidates)(GArray *, unsigned, unsigned int,
int, int, int *, unsigned int *,
unsigned, void(*)(void));
int start_oom, int end_oom, unsigned should_be_freed, int flags,
unsigned int *total_size, int *completed, unsigned int threshold)
{
+ int ret;
unsigned int total_victim_size = 0;
int candidates_cnt = 0;
int victim_cnt = 0;
if (!lowmem_kill_candidates)
lowmem_kill_candidates = g_array_new(false, false, sizeof(struct task_info *));
- assert(governor_ops.get_kill_candidates != NULL);
- candidates_cnt = governor_ops.get_kill_candidates(
+ candidates_cnt = syscommon_plugin_resourced_memory_lmk_get_kill_candidates(
lowmem_kill_candidates,
task_info_app_array,
task_info_proc_array,
totalram_kb);
-
- _D("[LMK] candidates_cnt=%d", candidates_cnt);
if (candidates_cnt <= 0) {
status = LOWMEM_RECLAIM_NEXT_TYPE;
goto leave;
}
+ /**
+ * Add, delete, and reorder already ordered lowmem_kill_candidates
+ * according to the governor post rule.
+ */
+ ret = syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post(
+ lowmem_kill_candidates);
+ if (ret < 0) {
+ status = LOWMEM_RECLAIM_NEXT_TYPE;
+ goto leave;
+ }
+
+ ret = syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_wss(
+ lowmem_kill_candidates);
+ if (ret < 0) {
+ status = LOWMEM_RECLAIM_NEXT_TYPE;
+ goto leave;
+ }
+
+ ret = syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_foreground(
+ lowmem_kill_candidates);
+ if (ret < 0) {
+ status = LOWMEM_RECLAIM_NEXT_TYPE;
+ goto leave;
+ }
+
+ _D("[LMK] candidates_cnt=%d", lowmem_kill_candidates->len);
assert(lowmem_controller_kill_candidates != NULL);
victim_cnt = lowmem_controller_kill_candidates(lowmem_kill_candidates,
should_be_freed, threshold,