[Devel] [PATCH VZ8] shmem/ve: virtualize tmpfs default size
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Fri May 28 16:55:46 MSK 2021
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>
---
mm/shmem.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 0852032cc1da..377a038ff24f 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -35,6 +35,7 @@
#include <linux/uio.h>
#include <linux/khugepaged.h>
#include <linux/hugetlb.h>
+#include <linux/ve.h>
#include <asm/tlbflush.h> /* for arch/microblaze update_mmu_cache() */
@@ -106,14 +107,30 @@ struct shmem_falloc {
};
#ifdef CONFIG_TMPFS
+static unsigned long tmpfs_ram_pages(void)
+{
+ struct ve_struct *ve = get_exec_env();
+ struct cgroup_subsys_state *css;
+
+ if (ve_is_super(ve))
+ return totalram_pages;
+
+ css = ve_get_init_css(ve, memory_cgrp_id);
+ totalram_pages = min(totalram_pages,
+ mem_cgroup_total_pages(mem_cgroup_from_css(css)));
+ css_put(css);
+
+ return totalram_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)
{
- return min(totalram_pages - totalhigh_pages, totalram_pages / 2);
+ return min(totalram_pages - totalhigh_pages, tmpfs_ram_pages() / 2);
}
#endif
--
2.31.1
More information about the Devel
mailing list