conf: Support memory limit exception for specific app 03/303603/1
authorUnsung Lee <unsung.lee@samsung.com>
Mon, 27 Nov 2023 07:53:48 +0000 (16:53 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Tue, 2 Jan 2024 08:46:11 +0000 (17:46 +0900)
Support memory limit exception for specific app if <limit> value is -1.
This functionality is required to exclude specific app from
ServicePerAppLimitAction, WidgetPerAppLimitAction, GUIPerAppLimitAction, and
BackgroundPerAppLimitAction.

Change-Id: Ia58c4538ca541b78adc61a32d870730063915c6f
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
conf/README
src/common/cgroup/memory-cgroup.c
src/common/util.h
src/resource-limiter/memory/lowmem-limit.c

index 9575f7d..fed4218 100644 (file)
@@ -549,6 +549,7 @@ Comment: Specify the memory limitation of this app/service/process.
          If <action> is specified, <action> overwrites the global action (reference section 1.5).
         If <action> is not specified, action is decided by global action (i.e., MemoryLimitTrigger).
         If <limit> size is smaller than app size during app loading time, the memory limit is not applied.
+        If <limit> size is -1, then this app has no memory limitations (reference section 1.3 and 1.4)
 Example: MemLimitAction=4096KB
 
 Key: MemoryBackgroundLru
index 5d2e6e1..b104aa7 100644 (file)
@@ -192,7 +192,11 @@ static int get_memory_bytes(const char *value, uint64_t *memory_bytes)
        char size[3];
        char *ptr = strchr(value, 'B');
        if (ptr == NULL) {
-               _E("[CONFIG] Cannot find 'B' in the string (%s)", value);
+               if (atoi(value) == -1) {
+                       *memory_bytes = BYTE_SIZE_MAX;
+                       return RESOURCED_ERROR_NONE;
+               }
+
                return RESOURCED_ERROR_FAIL;
        }
 
index 6f3ee45..7e0d1ca 100644 (file)
@@ -91,6 +91,8 @@ static inline void closedirp(DIR **d)
 #define _cleanup_fclose_ _cleanup_(fclosep)
 #define _cleanup_closedir_ _cleanup_(closedirp)
 
+#define BYTE_SIZE_MAX  (uint64_t)0xffffffffffff
+
 #define BYTE_TO_KBYTE(b) ((b) >> 10)
 #define BYTE_TO_MBYTE(b) ((b) >> 20)
 #define BYTE_TO_PAGE(b) ((b) >> 12)
index 3c4004b..0296611 100644 (file)
@@ -512,6 +512,12 @@ int lowmem_limit_set_app(unsigned long long limit_bytes, struct proc_app_info *p
                return RESOURCED_ERROR_INVALID_PARAMETER;
        }
 
+       /* This app is not interested in memory limit */
+       if (limit_bytes == BYTE_SIZE_MAX) {
+               _D("Do not set memory limit for app (%s)", pai->appid);
+               return RESOURCED_ERROR_NONE;
+       }
+
        result = asprintf(&path, "%s/%s", MEMCG_PRIVATE_PATH, pai->appid);
        if (result < 0) {
                _E("[MEMORY-LIMIT] not enough memory");