diff options
author | Marek Szyprowski <m.szyprowski@samsung.com> | 2020-10-13 14:46:43 +0200 |
---|---|---|
committer | Marek Szyprowski <m.szyprowski@samsung.com> | 2020-10-13 15:59:52 +0200 |
commit | fc689eb68979cc7a0c16c257f9cea37fce499457 (patch) | |
tree | 92e451ebe6d9e248348e5be70489d468790ab4e5 | |
parent | d5a521dbb6136038d537665cd049ef78c1217d10 (diff) | |
download | resourced-sandbox/mszyprowski/cma_workaround.tar.gz resourced-sandbox/mszyprowski/cma_workaround.tar.bz2 resourced-sandbox/mszyprowski/cma_workaround.zip |
procfs: assume that only half of the free CMA memory is available (heuristic)sandbox/mszyprowski/cma_workaround
CMA free pages are both reported separately AND included in the
MemAvailable. Use heuristic approach tested on low-memory systems with
high load: assume that only the half of the free CMA pages can be used
for the any purpose any time, so reduce the number of reported
MemAvailable by the half of the CmaFree.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I0b35cf64949c9f40a5dc880ab7361011c6d28f96
-rw-r--r-- | src/common/procfs.c | 10 | ||||
-rw-r--r-- | src/common/procfs.h | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/common/procfs.c b/src/common/procfs.c index 9f22727e..5b740206 100644 --- a/src/common/procfs.c +++ b/src/common/procfs.c @@ -612,6 +612,7 @@ static const char* const meminfo_string_lookup[MEMINFO_ID_MAX] = { [MEMINFO_ID_VMALLOC_TOTAL] = "VmallocTotal", [MEMINFO_ID_VMALLOC_USED] = "VmallocUsed", [MEMINFO_ID_VMALLOC_CHUNK] = "VmallocChunk", + [MEMINFO_ID_CMA_FREE] = "CmaFree", }; const char *meminfo_id_to_string(enum meminfo_id id) @@ -637,7 +638,8 @@ int proc_get_meminfo(struct meminfo *mi, unsigned long long mask) if (remain_mask & MEMINFO_MASK_MEM_AVAILABLE) remain_mask |= (MEMINFO_MASK_MEM_FREE | - MEMINFO_MASK_CACHED); + MEMINFO_MASK_CACHED | + MEMINFO_MASK_CMA_FREE); while (remain_mask) { _cleanup_free_ char *k = NULL; @@ -691,6 +693,12 @@ int proc_get_meminfo(struct meminfo *mi, unsigned long long mask) meminfo_id_to_string(i)); } + /* + * Heuristic: not all CMA free memory can be used for any purpose, + * so assume that only half of it is freely available + */ + mi->value[MEMINFO_ID_MEM_AVAILABLE] -= mi->value[MEMINFO_ID_CMA_FREE] / 2; + return RESOURCED_ERROR_NONE; } diff --git a/src/common/procfs.h b/src/common/procfs.h index 46eb2fb5..39127711 100644 --- a/src/common/procfs.h +++ b/src/common/procfs.h @@ -106,6 +106,7 @@ enum meminfo_id { MEMINFO_ID_VMALLOC_TOTAL, MEMINFO_ID_VMALLOC_USED, MEMINFO_ID_VMALLOC_CHUNK, + MEMINFO_ID_CMA_FREE, MEMINFO_ID_MAX, }; @@ -147,6 +148,7 @@ enum meminfo_id { #define MEMINFO_MASK_VMALLOC_TOTAL (1ULL << MEMINFO_ID_VMALLOC_TOTAL) #define MEMINFO_MASK_VMALLOC_USED (1ULL << MEMINFO_ID_VMALLOC_USED) #define MEMINFO_MASK_VMALLOC_CHUNK (1ULL << MEMINFO_ID_VMALLOC_CHUNK) +#define MEMINFO_MASK_CMA_FREE (1ULL << MEMINFO_ID_CMA_FREE) #define MEMINFO_MASK_ALL ((1ULL << MEMINFO_ID_MAX) - 1) struct meminfo_mapping { |