The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at 
https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 8638e9646ad6339ce35d3f936446cecf8b71447b
Author: Pavel Tikhomirov <ptikhomi...@virtuozzo.com>
Date:   Tue Oct 12 16:18:23 2021 +0300

    shmem/ve: virtualize tmpfs default size
    
    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 <ptikhomi...@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.
    
    https://jira.sw.ru/browse/PSBM-130518
    Signed-off-by: Konstantin Khorenko <khore...@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
 
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to