[Devel] [PATCH vz10 12/32] mm/shmem: build the tmpfs size virtualization only with CONFIG_VE

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 21 19:36:58 MSK 2026


tmpfs_ram_pages() sizes a Container's default tmpfs mounts against the
Container's memory cgroup limit, looking the cgroup up by memory_cgrp_id
and reading memcg->memory.max.  The function is compiled whenever
CONFIG_TMPFS is set, so with CONFIG_MEMCG=n - which CONFIG_VE=n allows,
and plain "make defconfig" used to produce - the build fails:

  mm/shmem.c: error: 'memory_cgrp_id' undeclared (first use in this
              function)
  mm/shmem.c: error: invalid use of undefined type 'struct mem_cgroup'

CONFIG_VE selects CONFIG_MEMCG, so compile the Container branch under
CONFIG_VE and keep the host branch, which already returns
totalram_pages(), as the only remaining path.

Fixes: e38fda88c26d ("shmem/ve: virtualize tmpfs default size")
Feature: fs: tmpfs virtualization
https://virtuozzo.atlassian.net/browse/VSTOR-134732
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/shmem.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index a86564c6637e..522322d4f359 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -143,20 +143,23 @@ static bool shmem_orders_configured __initdata;
 #ifdef CONFIG_TMPFS
 static unsigned long tmpfs_ram_pages(void)
 {
+#ifdef CONFIG_VE
 	struct ve_struct *ve = get_exec_env();
-	struct cgroup_subsys_state *css;
-	unsigned long ve_ram_pages;
-	struct mem_cgroup *memcg;
 
-	if (ve_is_super(ve))
-		return totalram_pages();
+	if (!ve_is_super(ve)) {
+		struct cgroup_subsys_state *css;
+		unsigned long ve_ram_pages;
+		struct mem_cgroup *memcg;
 
-	css = ve_get_init_css(ve, memory_cgrp_id);
-	memcg = mem_cgroup_from_css(css);
-	ve_ram_pages = min(totalram_pages(), memcg->memory.max);
-	css_put(css);
+		css = ve_get_init_css(ve, memory_cgrp_id);
+		memcg = mem_cgroup_from_css(css);
+		ve_ram_pages = min(totalram_pages(), memcg->memory.max);
+		css_put(css);
 
-	return ve_ram_pages;
+		return ve_ram_pages;
+	}
+#endif
+	return totalram_pages();
 }
 
 static unsigned long shmem_default_max_blocks(void)
-- 
2.47.1



More information about the Devel mailing list