[Devel] [PATCH RH8 10/11] ve/meminfo: show "MemAvailable: ..." line in CT's meminfo
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Fri Jun 4 17:45:37 MSK 2021
From: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
'available' memory is calculated in the same way as in
si_mem_available(), but 'WMARK_LOW' and 'totalreserve_pages' are not
honored as irrelevant for Containers.
https://jira.sw.ru/browse/PSBM-90190
Signed-off-by: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
(cherry-picked from 50cef4107c1106d547f5118a202bc8e0c0467c5c)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 6e09d00..b7ed25e 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -48,6 +48,7 @@ static int meminfo_proc_show_mi(struct seq_file *m, struct meminfo *mi)
show_val_kb(m, "MemTotal: ", mi->si->totalram);
show_val_kb(m, "MemFree: ", mi->si->freeram);
+ show_val_kb(m, "MemAvailable: ", mi->available);
show_val_kb(m, "Buffers: ", 0);
show_val_kb(m, "Cached: ", mi->cached);
diff --git a/include/linux/virtinfo.h b/include/linux/virtinfo.h
index f6fb836..10cb6e7 100644
--- a/include/linux/virtinfo.h
+++ b/include/linux/virtinfo.h
@@ -17,6 +17,7 @@ struct meminfo {
unsigned long pages[NR_LRU_LISTS];
unsigned long cached, dirty_pages, writeback_pages, shmem;
unsigned long slab_reclaimable, slab_unreclaimable;
+ unsigned long available;
};
#endif /* __LINUX_VIRTINFO_H */
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c0f825a..2d85414 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3800,6 +3800,17 @@ void mem_cgroup_fill_meminfo(struct mem_cgroup *memcg, struct meminfo *mi)
/* locked pages are accounted per zone */
/* mi->locked = 0; */
+
+ /*
+ * The way of calculating 'available' memory repeats behavior of
+ * si_mem_available(), except 'WMARK_LOW' and 'totalreserve_pages'
+ * are not taken into account. These values reflect reservation of
+ * physycal memory and they are not relevant for CT.
+ */
+ mi->available = mi->si->freeram;
+ mi->available += mi->pages[LRU_ACTIVE_FILE] +
+ mi->pages[LRU_INACTIVE_FILE];
+ mi->available += mi->slab_reclaimable;
}
static int memcg_numa_stat_show(struct seq_file *m, void *v)
--
1.8.3.1
More information about the Devel
mailing list