diff options
Diffstat (limited to 'src')
-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 { |