[Devel] [PATCH rh7] ub: account shmem in cached in meminfo
Vladimir Davydov
vdavydov at parallels.com
Wed Jun 3 02:15:51 PDT 2015
This patch ports:
diff-ub-account-shmem-to-meminfo-cached
diff-ub-meminfo-cached-make-sure-meminfo-memFree-plus-Cached-plus-Slab-less-than-MemTotal
Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: ub: account Shmem to meminfo:Cached
Date: Wed, 3 Dec 2014 16:30:22 +0300
Upstream, Shmem is accounted as file pages so it must contribute to
meminfo:Cached, otherwise output of certain versions of free(1) might
get screwed (negative 'cached').
https://jira.sw.ru/browse/PSBM-28682
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
=============================================================================
Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: ub/cached: make sure meminfo:MemFree+Cached+Slab<=MemTotal
Date: Tue, 30 Dec 2014 18:23:45 +0300
Since commit diff-ub-account-shmem-to-meminfo-cached, container's
meminfo:Cached includes meminfo:Shmem to conform to the behavior of
vanilla kernels. However, the value of meminfo:Shmem reported inside
containers is not quite the same as it would be in a non-virtualized
environment: it includes swapped out memory, while on vanilla kernels it
only shows the resident shared memory size. As a result,
meminfo:MemFree+Cached can be greater than meminfo:MemTotal, in which
case it's trimmed to MemTotal, so that meminfo:MemFree+Cached+Slab is
likely to be greater than MemTotal. This, in turn, confuses our
userspace tools (PACI autoscaling).
The right fix would be to account only resident shared memory under
meminfo:Shmem, but since it's tricky to implement, because shmem may be
shadowed, let's simply trim meminfo:MemFree+Cached to MemTotal-Slab.
https://jira.sw.ru/browse/PSBM-31006
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
=============================================================================
Related to https://jira.sw.ru/browse/PSBM-33637
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
kernel/bc/vm_pages.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/bc/vm_pages.c b/kernel/bc/vm_pages.c
index a6f311e33894..c52d34f377b5 100644
--- a/kernel/bc/vm_pages.c
+++ b/kernel/bc/vm_pages.c
@@ -188,9 +188,6 @@ static int bc_fill_meminfo(struct user_beancounter *ub,
ub_sync_memcg(ub);
ub_page_stat(ub, &node_online_map, mi->pages);
- mi->cached = min(mi->si->totalram - mi->si->freeram,
- mi->pages[LRU_INACTIVE_FILE] +
- mi->pages[LRU_ACTIVE_FILE]);
mi->locked = ub->ub_parms[UB_LOCKEDPAGES].held;
mi->shmem = ub->ub_parms[UB_SHMPAGES].held;
dcache = ub->ub_parms[UB_DCACHESIZE].held;
@@ -211,6 +208,12 @@ static int bc_fill_meminfo(struct user_beancounter *ub,
mi->slab_unreclaimable =
DIV_ROUND_UP(max(0L, (long)ub->ub_parms[UB_KMEMSIZE].held -
dcache), PAGE_SIZE);
+
+ mi->cached = min(mi->si->totalram - mi->si->freeram -
+ mi->slab_reclaimable - mi->slab_unreclaimable,
+ mi->pages[LRU_INACTIVE_FILE] +
+ mi->pages[LRU_ACTIVE_FILE] +
+ ub->ub_parms[UB_SHMPAGES].held);
out:
return ret;
}
--
2.1.4
More information about the Devel
mailing list