[Devel] [PATCH RH9 04/10] shmem/ve: virtualize tmpfs default size
Cyrill Gorcunov
gorcunov at gmail.com
Sun Oct 10 21:17:59 MSK 2021
From: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Set default size to half of physpages from ve memory cgroup. User in ct
would get -ENOSPC on 1/2 memory limit reached like we do on host.
https://jira.sw.ru/browse/PCLIN-26841
https://jira.sw.ru/browse/PSBM-127785
(extracted from vz7 commit dce154c32257 ("ub/memcg: introduce
ub_total_pages"))
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
+++
shmem/ve: Keep host's totalram_pages intact during CT tmpfs default size calculation
During tmpfs default size virtualization we occasionally
overwrite 'totalram_pages' global value used for host.
Fix it.
mFixes: b563045c1998 ("shmem/ve: virtualize tmpfs default size")
https://jira.sw.ru/browse/PSBM-130518
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
mm/shmem.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 6ba6b558d7c1..0810a3549600 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -38,6 +38,7 @@
#include <linux/hugetlb.h>
#include <linux/frontswap.h>
#include <linux/fs_parser.h>
+#include <linux/ve.h>
#include <asm/tlbflush.h> /* for arch/microblaze update_mmu_cache() */
@@ -124,16 +125,33 @@ struct shmem_options {
};
#ifdef CONFIG_TMPFS
+static unsigned long tmpfs_ram_pages(void)
+{
+ struct ve_struct *ve = get_exec_env();
+ struct cgroup_subsys_state *css;
+ unsigned long ve_ram_pages;
+
+ if (ve_is_super(ve))
+ return totalram_pages();
+
+ css = ve_get_init_css(ve, memory_cgrp_id);
+ ve_ram_pages = min(totalram_pages(),
+ mem_cgroup_total_pages(mem_cgroup_from_css(css)));
+ css_put(css);
+
+ return ve_ram_pages;
+}
+
static unsigned long shmem_default_max_blocks(void)
{
- return totalram_pages() / 2;
+ return tmpfs_ram_pages() / 2;
}
static unsigned long shmem_default_max_inodes(void)
{
unsigned long nr_pages = totalram_pages();
- return min(nr_pages - totalhigh_pages(), nr_pages / 2);
+ return min(nr_pages - totalhigh_pages(), tmpfs_ram_pages() / 2);
}
#endif
--
2.31.1
More information about the Devel
mailing list