[Devel] [PATCH vz10 08/32] mm/oom: build the berserker mode only with CONFIG_MEMCG

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


From: Eva Kurchatova <eva.kurchatova at virtuozzo.com>

oom_berserker() works on the memory cgroup the OOM happened in: it takes
memcg->oom_rage_lock, updates memcg->oom_time/oom_rage, falls back to
root_mem_cgroup and calls task_in_mem_cgroup().  None of that exists when
CONFIG_MEMCG is disabled:

  mm/oom_kill.c: error: 'root_mem_cgroup' undeclared
  mm/oom_kill.c: error: invalid use of undefined type 'struct mem_cgroup'

Compile the function only when CONFIG_MEMCG is enabled and provide an
empty stub otherwise: without a memory controller there is no per-cgroup
OOM rate to get enraged about, and the caller stays unchanged.

Fixes: 6517e9ae0449 ("oom: resurrect berserker mode")
Feature: mm/oom: berserker mode
https://virtuozzo.atlassian.net/browse/VSTOR-134732
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/oom_kill.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 1fd5f99ce3b9..5cf0fefade48 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -1047,6 +1047,7 @@ static int oom_kill_memcg_member(struct task_struct *task, void *message)
 /*
  * Kill more processes if oom happens too often in this context.
  */
+#ifdef CONFIG_MEMCG
 static void oom_berserker(struct oom_control *oc)
 {
 	static DEFINE_RATELIMIT_STATE(berserker_rs,
@@ -1150,6 +1151,9 @@ static void oom_berserker(struct oom_control *oc)
 
 	pr_err("OOM killer in rage %d: %d tasks killed\n", rage, killed);
 }
+#else
+static inline void oom_berserker(struct oom_control *oc) { }
+#endif /* CONFIG_MEMCG */
 
 atomic_t global_oom = ATOMIC_INIT(0);
 
-- 
2.47.1



More information about the Devel mailing list