From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khorenko Date: Fri, 21 Aug 2026 18:36:55 +0200 Subject: [Devel] [PATCH vz10 09/32] proc: build the per-Container oom_score limit lookup only with CONFIG_MEMCG In-Reply-To: <20260821163718.187766-1-khorenko@virtuozzo.com> References: <20260821163718.187766-1-khorenko@virtuozzo.com> Message-ID: <20260821163718.187766-10-khorenko@virtuozzo.com> List-Id: From: Eva Kurchatova proc_oom_score() scales the badness against the memory cgroup limit of the Container the task belongs to, using memory_cgrp_id, mem_cgroup_from_css() and mem_cgroup_get_max(). None of those exist with CONFIG_MEMCG disabled: fs/proc/base.c: error: 'memory_cgrp_id' undeclared (first use in this function) Wrap the whole lookup in CONFIG_MEMCG. totalpages is already initialized to totalram_pages() + total_swap_pages, so without a memory controller oom_score simply falls back to being scaled against all of the machine's memory, which is what a kernel without memory cgroups can report. Fixes: 708b02c17c36 ("proc,memcg: use memcg limits for showing oom_score inside CT") Feature: mm/oom: per-CT oom_score virtualization https://virtuozzo.atlassian.net/browse/VSTOR-134732 Signed-off-by: Eva Kurchatova Signed-off-by: Konstantin Khorenko --- fs/proc/base.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index 8174b2a8a5dc..f7cae1c59ec4 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -692,6 +692,7 @@ static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns, unsigned long points = 0; long badness; +#ifdef CONFIG_MEMCG scoped_guard (rcu) { struct cgroup_subsys_state *css = task_css(task, memory_cgrp_id); @@ -703,6 +704,7 @@ static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns, totalpages = mem_cgroup_get_max(memcg); } } +#endif badness = oom_badness(task, totalpages, NULL); /* -- 2.47.1