memory: add relative vmpressure threshold for iot-headless 87/260687/4
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 1 Jul 2021 05:09:24 +0000 (14:09 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Thu, 8 Jul 2021 07:49:35 +0000 (16:49 +0900)
resourced-headless have managed vmpressure based on ratio of available
memory to the total memory. Since resourced-headless has been replaced
with resourced, bring this functionality into resourced for iot-headless
profile.

Change-Id: I4683fce74d61417bb3052dd857a912be5058d614
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
packaging/resourced.spec
src/CMakeLists.txt
src/memory/memory-iot-headless.conf [new file with mode: 0644]
src/memory/memory.conf
src/memory/vmpressure-lowmem-handler.c

index 8bbb7c9..6705d59 100644 (file)
@@ -205,10 +205,12 @@ if [ $1 -eq 0 ]; then
 fi
 
 %post config-iot-headless
+%{_sbindir}/update-alternatives --install %{confdir}/memory.conf resourced-config-memory %{confdir}/configs/config-memory-iot-headless.conf 150
 %{_sbindir}/update-alternatives --install %{confdir}/vip-process.conf resourced-config-vip-process %{confdir}/configs/config-vip-process-iot-headless.conf 150
 
 %preun config-iot-headless
 if [ $1 -eq 0 ]; then
+       %{_sbindir}/update-alternatives --remove resourced-config-memory %{confdir}/configs/config-memory-iot-headless.conf
        %{_sbindir}/update-alternatives --remove resourced-config-vip-process %{confdir}/configs/config-vip-process-iot-headless.conf
 fi
 
@@ -251,6 +253,7 @@ fi
 
 %files config-iot-headless
 %manifest resourced.manifest
+%{confdir}/configs/config-memory-iot-headless.conf
 %{confdir}/configs/config-vip-process-iot-headless.conf
 
 %if %{?mem_stress} == ON
index 91e2fb4..4c6a6c7 100644 (file)
@@ -214,6 +214,7 @@ INSTALL(TARGETS ${RD_BINARY_NAME}
 IF("${MEMORY_MODULE}" STREQUAL "ON")
        INSTALL(FILES ${MEMORY_SOURCE_DIR}/memory.conf DESTINATION ${RD_CONFIG_PATH})
        INSTALL(FILES ${MEMORY_SOURCE_DIR}/memory-tv.conf DESTINATION ${RD_CONFIG_PATH})
+       INSTALL(FILES ${MEMORY_SOURCE_DIR}/memory-iot-headless.conf DESTINATION ${RD_CONFIG_PATH})
 ENDIF()
 
 IF("${CPU_MODULE}" STREQUAL "ON")
diff --git a/src/memory/memory-iot-headless.conf b/src/memory/memory-iot-headless.conf
new file mode 100644 (file)
index 0000000..f4dfce6
--- /dev/null
@@ -0,0 +1,237 @@
+[VIP_PROCESS]
+# predefined process list
+PREDEFINE=enlightenment
+PREDEFINE=dbus-daemon
+PREDEFINE=amd
+PREDEFINE=launchpad_preloading_preinitializing_daemon
+PREDEFINE=process_pool_launchpad_preloading_preinitializing_daemon
+
+# Use the ratio of the available memory to the total memory as vmpressure threshold.
+# If used with [Memory#] section, the last threshold will be applied.
+#[MemoryRatio]
+#ThresholdRatioDedup=30           # %
+#ThresholdRatioSwap=24            # %
+#ThresholdRatioLow=12             # %
+#ThresholdRatioMedium=10          # %
+#ThresholdRatioLeave=15           # %
+#NumMaxVictims=1
+
+[Memory64]
+# Threshold to start dedup
+ThresholdDedup=16              # MB
+
+# Threshold to start swap
+ThresholdSwap=15               # MB
+
+# Threshold to start reclaim
+ThresholdLow=8                 # MB
+
+# Threshold to start low memory killer
+ThresholdMedium=5              # MB
+
+# Threshold to stop low memory killer
+ThresholdLeave=8               # MB
+
+# Number of max victims
+NumMaxVictims=1
+
+[Memory256]
+# Threshold to start dedup
+ThresholdDedup=60              # MB
+
+# Threshold to start swap
+ThresholdSwap=40               # MB
+
+# Threshold to start reclaim
+ThresholdLow=20                        # MB
+
+# Threshold to start low memory killer
+ThresholdMedium=10             # MB
+
+# Threshold to stop low memory killer
+ThresholdLeave=20              # MB
+
+# Number of max victims
+NumMaxVictims=2
+
+[Memory448]
+# Threshold to start dedup
+ThresholdDedup=120             # MB
+
+# Threshold to start swap
+ThresholdSwap=100              # MB
+
+# Threshold to start reclaim
+ThresholdLow=60                        # MB
+
+# Threshold to start low memory killer
+ThresholdMedium=50             # MB
+
+# Threshold to stop low memory killer
+ThresholdLeave=70              # MB
+
+# Threshold for proactive memory killer
+ProactiveThreshold=80          # MB
+
+# Leave Threshold for proactive memory killer
+ProactiveLeave=100             # MB
+
+# Number of max victims
+NumMaxVictims=5
+
+[Memory512]
+# Threshold to start dedup
+ThresholdDedup=140             # MB
+
+# Threshold to start swap
+ThresholdSwap=100              # MB
+
+# Threshold to start reclaim
+ThresholdLow=70                        # MB
+
+# Threshold to start low memory killer
+ThresholdMedium=60             # MB
+
+# Threshold to stop low memory killer
+ThresholdLeave=80              # MB
+
+# Threshold for proactive memory killer
+ProactiveThreshold=80          # MB
+
+# Leave Threshold for proactive memory killer
+ProactiveLeave=100             # MB
+
+# Number of max victims
+NumMaxVictims=5
+
+[Memory768]
+# Threshold to start dedup
+ThresholdDedup=180             # MB
+
+# Threshold to start swap
+ThresholdSwap=150              # MB
+
+# Threshold to start reclaim
+ThresholdLow=90                # MB
+
+# Threshold to start low memory killer
+ThresholdMedium=80             # MB
+
+# Threshold to stop low memory killer
+ThresholdLeave=100             # MB
+
+# Threshold for proactive memory killer
+ProactiveThreshold=100         # MB
+
+# Leave Threshold for proactive memory killer
+ProactiveLeave=130             # MB
+
+# Number of max victims
+NumMaxVictims=5
+
+[Memory1024]
+# Threshold to start dedup
+ThresholdDedup=400             # MB
+
+# Threshold to start swap
+ThresholdSwap=300              # MB
+
+# Threshold to start reclaim
+ThresholdLow=120               # MB
+
+# Threshold to start low memory killer
+ThresholdMedium=100            # MB
+
+# Threshold to stop low memory killer
+ThresholdLeave=150             # MB
+
+# Threshold for proactive memory killer
+ProactiveThreshold=150         # MB
+
+# Leave Threshold for proactive memory killer
+ProactiveLeave=230             # MB
+
+# Number of max victims
+NumMaxVictims=5
+
+[Memory2048]
+# Threshold to start dedup
+ThresholdDedup=400             # MB
+
+# Threshold to start swap
+ThresholdSwap=300              # MB
+
+# Threshold to start reclaim
+ThresholdLow=200               # MB
+
+# Threshold to start low memory killer
+ThresholdMedium=160            # MB
+
+# Threshold to stop low memory killer
+ThresholdLeave=300             # MB
+
+# Number of max victims
+NumMaxVictims=10
+
+[Memory3072]
+# Threshold to start dedup
+ThresholdDedup=600        # MB
+
+# Threshold to start swap
+ThresholdSwap=500        # MB
+
+# Threshold to start reclaim
+ThresholdLow=400        # MB
+
+# Threshold to start low memory killer
+ThresholdMedium=250        # MB
+
+# Threshold to stop low memory killer
+ThresholdLeave=500        # MB
+
+# Number of max victims
+NumMaxVictims=10
+
+[POPUP]
+oom_popup=no
+
+[BackgroundReclaim]
+# Unset this option if it causes any unexepcted issue (e.g. jerky animation).
+AfterScreenDim=yes
+
+[Compaction]
+CompactEnable=1
+# External fragmentation level
+# The higher the level the less restrictive
+# conditions for triggering compaction.
+Fraglevel=800
+
+[MemLimit]
+# Control memory limit
+# values for MemLimitTrigger :
+#              oom (regiter event using oom_control and kill process in kernel)
+#              threshold(regiter event using usage_in_bytes and kill process in resourced)
+#              others(don't register any event for memory limit)
+MemLimitTrigger=oom
+
+# Memory limits for each supported application types.  Effective only when MemLimitTrigger
+# is set to oom or threshold.
+MemLimitService=128            # MB
+# MemLimitWidget=160            # MB
+# MemLimitGUIApp=1024           # MB
+
+# Following configuration option sets memory limit for background GUI
+# and Widget applications.  It's valid to set this option only if
+# both MemLimitWidget and MemLimitGUIApp are set.
+# MemLimitBgApp=768             # MB
+
+[Logging]
+Enable=1
+# memps logpath
+#              memps: OOM log
+#              memps_memlimit: lowmem limit log
+MaxNumLogfile=50       # default: 50
+LogPath=/var/log       # default: /var/log
+# logfile prefix
+PrefixMemps=memps
+PrefixMempsMemLimit=memps_memlimit
index 2eb59e1..f4dfce6 100644 (file)
@@ -6,9 +6,19 @@ PREDEFINE=amd
 PREDEFINE=launchpad_preloading_preinitializing_daemon
 PREDEFINE=process_pool_launchpad_preloading_preinitializing_daemon
 
+# Use the ratio of the available memory to the total memory as vmpressure threshold.
+# If used with [Memory#] section, the last threshold will be applied.
+#[MemoryRatio]
+#ThresholdRatioDedup=30           # %
+#ThresholdRatioSwap=24            # %
+#ThresholdRatioLow=12             # %
+#ThresholdRatioMedium=10          # %
+#ThresholdRatioLeave=15           # %
+#NumMaxVictims=1
+
 [Memory64]
 # Threshold to start dedup
-ThresholdDedup=16              # MB 
+ThresholdDedup=16              # MB
 
 # Threshold to start swap
 ThresholdSwap=15               # MB
@@ -27,7 +37,7 @@ NumMaxVictims=1
 
 [Memory256]
 # Threshold to start dedup
-ThresholdDedup=60              # MB 
+ThresholdDedup=60              # MB
 
 # Threshold to start swap
 ThresholdSwap=40               # MB
@@ -46,7 +56,7 @@ NumMaxVictims=2
 
 [Memory448]
 # Threshold to start dedup
-ThresholdDedup=120             # MB 
+ThresholdDedup=120             # MB
 
 # Threshold to start swap
 ThresholdSwap=100              # MB
@@ -71,7 +81,7 @@ NumMaxVictims=5
 
 [Memory512]
 # Threshold to start dedup
-ThresholdDedup=140             # MB 
+ThresholdDedup=140             # MB
 
 # Threshold to start swap
 ThresholdSwap=100              # MB
@@ -96,7 +106,7 @@ NumMaxVictims=5
 
 [Memory768]
 # Threshold to start dedup
-ThresholdDedup=180             # MB 
+ThresholdDedup=180             # MB
 
 # Threshold to start swap
 ThresholdSwap=150              # MB
@@ -121,7 +131,7 @@ NumMaxVictims=5
 
 [Memory1024]
 # Threshold to start dedup
-ThresholdDedup=400             # MB 
+ThresholdDedup=400             # MB
 
 # Threshold to start swap
 ThresholdSwap=300              # MB
@@ -146,7 +156,7 @@ NumMaxVictims=5
 
 [Memory2048]
 # Threshold to start dedup
-ThresholdDedup=400             # MB 
+ThresholdDedup=400             # MB
 
 # Threshold to start swap
 ThresholdSwap=300              # MB
index c0d1c9a..6906272 100644 (file)
@@ -1559,7 +1559,8 @@ static int set_memory_config(const char *section_name, const struct parse_result
        if (!result || !section_name)
                return -EINVAL;
 
-       if (strncmp(result->section, section_name, strlen(section_name)+1))
+       if (strncmp(result->section, "MemoryRatio", strlen("MemoryRatio")+1)
+               && strncmp(result->section, section_name, strlen(section_name)+1))
                return RESOURCED_ERROR_NONE;
 
        if (!strncmp(result->name, "ThresholdDedup", strlen("ThresholdDedup")+1)) {
@@ -1577,6 +1578,26 @@ static int set_memory_config(const char *section_name, const struct parse_result
        } else if (!strncmp(result->name, "ThresholdLeave", strlen("ThresholdLeave")+1)) {
                int value = atoi(result->value);
                lowmem_memcg_set_leave_threshold(MEMCG_MEMORY, value);
+       } else if (!strncmp(result->name, "ThresholdRatioDedup", strlen("ThresholdRatioDedup")+1)) {
+               double ratio = atoi(result->value);
+               int value = (double)totalram * ratio / 100.0;
+               lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_DEDUP, BYTE_TO_MBYTE(value));
+       } else if (!strncmp(result->name, "ThresholdRatioSwap", strlen("ThresholdRatioSwap")+1)) {
+               double ratio = atoi(result->value);
+               int value = (double)totalram * ratio / 100.0;
+               lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_SWAP, BYTE_TO_MBYTE(value));
+       } else if (!strncmp(result->name, "ThresholdRatioLow", strlen("ThresholdRatioLow")+1)) {
+               double ratio = atoi(result->value);
+               int value = (double)totalram * ratio / 100.0;
+               lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_LOW, BYTE_TO_MBYTE(value));
+       } else if (!strncmp(result->name, "ThresholdRatioMedium", strlen("ThresholdRatioMedium")+1)) {
+               double ratio = atoi(result->value);
+               int value = (double)totalram * ratio / 100.0;
+               lowmem_memcg_set_threshold(MEMCG_MEMORY, LOWMEM_MEDIUM, BYTE_TO_MBYTE(value));
+       } else if (!strncmp(result->name, "ThresholdRatioLeave", strlen("ThresholdRatioLeave")+1)) {
+               double ratio = atoi(result->value);
+               int value = (double)totalram * ratio / 100.0;
+               lowmem_memcg_set_leave_threshold(MEMCG_MEMORY, BYTE_TO_MBYTE(value));
        } else if (!strncmp(result->name, "ForegroundRatio", strlen("ForegroundRatio")+1)) {
                float ratio = atof(result->value);
                memcg_info_set_limit(memcg_tree[MEMCG_APPS]->info, ratio, totalram);