lowmem-monitor-psi: Add the lowest PSI level 22/300622/1 accepted/tizen/8.0/unified/20231103.040827
authorUnsung Lee <unsung.lee@samsung.com>
Mon, 30 Oct 2023 04:41:45 +0000 (13:41 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 30 Oct 2023 06:02:38 +0000 (15:02 +0900)
Add the lowest PSI level to monitor low memory early.
This is because, sometimes Out-of-Memory (OOM) is triggered earlier than LMK
in ths past 3 level PSIs.

New PSI also cannot perfectly detect LMK status before OOM is triggered.
However, it covers some LMK status detected by vmpressure(low).

In conclusion, change PSI like below:
PSI_LEVEL1(NEW): 30ms/500ms (6%)
LOW -> PSI_LEVEL2
MEDIUM -> PSI_LEVEL3
HIGH -> PSI_LEVEL4

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

index f498f4a..a9d9267 100644 (file)
 
 enum psi_mem_level {
        PSI_MEM_LEVEL_UNKNOWN,
-       PSI_MEM_LEVEL_LOW,
-       PSI_MEM_LEVEL_MEDIUM,
-       PSI_MEM_LEVEL_HIGH,
+       PSI_MEM_LEVEL_1,
+       PSI_MEM_LEVEL_2,
+       PSI_MEM_LEVEL_3,
+       PSI_MEM_LEVEL_4,
        PSI_MEM_LEVEL_MAX,
 };
 
@@ -73,9 +74,10 @@ static enum psi_mem_level g_current_psi_mem_level = PSI_MEM_LEVEL_UNKNOWN;
 static void assert_psi_mem_level(int psi_mem_level)
 {
        switch (psi_mem_level) {
-       case PSI_MEM_LEVEL_LOW:
-       case PSI_MEM_LEVEL_MEDIUM:
-       case PSI_MEM_LEVEL_HIGH:
+       case PSI_MEM_LEVEL_1:
+       case PSI_MEM_LEVEL_2:
+       case PSI_MEM_LEVEL_3:
+       case PSI_MEM_LEVEL_4:
                return;
        default:
                _E("Invalid PSI memory level: %d", psi_mem_level);
@@ -199,9 +201,10 @@ static void raise_lowmem_event(void)
        int mem_level;
 
        switch (g_current_psi_mem_level) {
-       case PSI_MEM_LEVEL_LOW:
-       case PSI_MEM_LEVEL_MEDIUM:
-       case PSI_MEM_LEVEL_HIGH:
+       case PSI_MEM_LEVEL_1:
+       case PSI_MEM_LEVEL_2:
+       case PSI_MEM_LEVEL_3:
+       case PSI_MEM_LEVEL_4:
                break;
        default:
                return;
@@ -296,25 +299,33 @@ static void destroy_psi_monitor_thread(void)
 }
 
 static struct psi_memory_monitor_info g_psi_memory_monitor_info_list[PSI_MEM_LEVEL_MAX] = {
-       [PSI_MEM_LEVEL_LOW] = {
-               .psi_mem_level = PSI_MEM_LEVEL_LOW,
-               .psi_mem_level_str = "low",
+       [PSI_MEM_LEVEL_1] = {
+               .psi_mem_level = PSI_MEM_LEVEL_1,
+               .psi_mem_level_str = "level1",
+               .psi_type = PSI_TYPE_SOME,
+               .stall_us = 30000,
+               .window_us = 500000,
+               .fd = -1,
+       },
+       [PSI_MEM_LEVEL_2] = {
+               .psi_mem_level = PSI_MEM_LEVEL_2,
+               .psi_mem_level_str = "level2",
                .psi_type = PSI_TYPE_SOME,
                .stall_us = 70000,
                .window_us = 1000000,
                .fd = -1,
        },
-       [PSI_MEM_LEVEL_MEDIUM] = {
-               .psi_mem_level = PSI_MEM_LEVEL_MEDIUM,
-               .psi_mem_level_str = "medium",
+       [PSI_MEM_LEVEL_3] = {
+               .psi_mem_level = PSI_MEM_LEVEL_3,
+               .psi_mem_level_str = "level3",
                .psi_type = PSI_TYPE_SOME,
                .stall_us = 100000,
                .window_us = 1000000,
                .fd = -1,
        },
-       [PSI_MEM_LEVEL_HIGH] = {
-               .psi_mem_level = PSI_MEM_LEVEL_HIGH,
-               .psi_mem_level_str = "high",
+       [PSI_MEM_LEVEL_4] = {
+               .psi_mem_level = PSI_MEM_LEVEL_4,
+               .psi_mem_level_str = "level4",
                .psi_type = PSI_TYPE_FULL,
                .stall_us = 70000,
                .window_us = 1000000,
@@ -323,17 +334,21 @@ static struct psi_memory_monitor_info g_psi_memory_monitor_info_list[PSI_MEM_LEV
 };
 
 static struct epoll_event_data g_psi_event_datas[PSI_MEM_LEVEL_MAX] = {
-       [PSI_MEM_LEVEL_LOW] = {
+       [PSI_MEM_LEVEL_1] = {
+               .handler = (epoll_event_handler)psi_memory_monitor_handler,
+               .data = &g_psi_memory_monitor_info_list[PSI_MEM_LEVEL_1],
+       },
+       [PSI_MEM_LEVEL_2] = {
                .handler = (epoll_event_handler)psi_memory_monitor_handler,
-               .data = &g_psi_memory_monitor_info_list[PSI_MEM_LEVEL_LOW],
+               .data = &g_psi_memory_monitor_info_list[PSI_MEM_LEVEL_2],
        },
-       [PSI_MEM_LEVEL_MEDIUM] = {
+       [PSI_MEM_LEVEL_3] = {
                .handler = (epoll_event_handler)psi_memory_monitor_handler,
-               .data = &g_psi_memory_monitor_info_list[PSI_MEM_LEVEL_MEDIUM],
+               .data = &g_psi_memory_monitor_info_list[PSI_MEM_LEVEL_3],
        },
-       [PSI_MEM_LEVEL_HIGH] = {
+       [PSI_MEM_LEVEL_4] = {
                .handler = (epoll_event_handler)psi_memory_monitor_handler,
-               .data = &g_psi_memory_monitor_info_list[PSI_MEM_LEVEL_HIGH],
+               .data = &g_psi_memory_monitor_info_list[PSI_MEM_LEVEL_4],
        },
 };