lowmem: Add lmk_try_count in syscommon_plugin_resourced_memory_lmk_get_kill_candidate... 89/298389/1
authorUnsung Lee <unsung.lee@samsung.com>
Wed, 6 Sep 2023 08:51:53 +0000 (17:51 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Wed, 6 Sep 2023 08:52:54 +0000 (17:52 +0900)
Add lmk_try_count argument
into syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_wss to
notify the current LMK cycle to resourced LMK backend plugin.

Change-Id: Ia83ab53c6179beec00b3f2430e9218256077032e
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/resource-limiter/memory/lowmem.c

index 587221d..8f216b6 100644 (file)
@@ -718,7 +718,8 @@ void lowmem_register_lmk_controller(int(*kill_candidates)(GArray *, unsigned,
 static int lowmem_kill_victims(int max_victims,
                enum syscommon_resourced_memory_lmk_oom_level oom_level,
                int start_oom, int end_oom, unsigned should_be_freed, int flags,
-               unsigned int *total_size, int *completed, unsigned int threshold)
+               unsigned int *total_size, int *completed,
+               unsigned int threshold, int lmk_try_count)
 {
        int ret;
        unsigned int total_victim_size = 0;
@@ -782,7 +783,7 @@ static int lowmem_kill_victims(int max_victims,
 
        if (lmk_governor_post_is_enabled_of_wss()) {
                ret = syscommon_plugin_resourced_memory_lmk_get_kill_candidates_post_with_wss(
-                               lowmem_kill_candidates);
+                               lowmem_kill_candidates, lmk_try_count);
                if (ret < 0) {
                        status = LOWMEM_RECLAIM_NEXT_TYPE;
                        goto leave;
@@ -894,7 +895,7 @@ static int calculate_range_of_oom(
        return RESOURCED_ERROR_NONE;
 }
 
-static void lowmem_handle_request(struct lowmem_control *ctl)
+static void lowmem_handle_request(struct lowmem_control *ctl, int lmk_try_count)
 {
        int start_oom, end_oom;
        int count = 0, victim_cnt = 0;
@@ -932,7 +933,8 @@ retry:
        /* precaution */
        current_size = 0;
        victim_cnt = lowmem_kill_victims(max_victim_cnt, oom_level, start_oom, end_oom,
-                           reclaim_size_mb, ctl->flags, &current_size, &status, ctl->size_mb);
+                           reclaim_size_mb, ctl->flags, &current_size, &status,
+                           ctl->size_mb, lmk_try_count);
 
        if (victim_cnt) {
                current_size = KBYTE_TO_MBYTE(current_size);
@@ -1002,7 +1004,7 @@ static void *lowmem_reclaim_worker(void *arg)
        g_async_queue_ref(lmw->queue);
 
        while (1) {
-               int try_count = 0;
+               int lmk_try_count = 0;
                struct lowmem_control *ctl;
 
                LOWMEM_WORKER_IDLE(lmw);
@@ -1021,8 +1023,9 @@ static void *lowmem_reclaim_worker(void *arg)
 
                LOWMEM_WORKER_RUN(lmw);
 process_again:
-               _D("[LMK] %d tries", ++try_count);
-               lowmem_handle_request(ctl);
+               lmk_try_count++;
+               _D("[LMK] %d tries", lmk_try_count);
+               lowmem_handle_request(ctl, lmk_try_count);
                /**
                 * Case the process failed to reclaim requested amount of memory
                 * or still under have memory pressure - try the timeout wait.