Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: memcontrol: treat disabled memcg as kmem accounting disabled
@ 2026-08-27  9:17 Hao Li
  2026-08-27 12:04 ` Michal Hocko
  0 siblings, 1 reply; 4+ messages in thread
From: Hao Li @ 2026-08-27  9:17 UTC (permalink / raw)
  To: hannes, mhocko, roman.gushchin, shakeel.butt
  Cc: muchun.song, akpm, cgroups, linux-mm, linux-kernel, Hao Li

mem_cgroup_kmem_disabled() currently only checks whether the
"cgroup.memory=nokmem" option is specified. However, kmem accounting is
also unavailable when memcg itself is disabled.

Check both conditions to ensure the function accurately reflects the
kmem accounting state.

Signed-off-by: Hao Li <hao.li@linux.dev>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1ebceade4021..b28f6165c354 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -132,7 +132,7 @@ static DEFINE_SPINLOCK(objcg_lock);
 
 bool mem_cgroup_kmem_disabled(void)
 {
-	return cgroup_memory_nokmem;
+	return cgroup_memory_nokmem || mem_cgroup_disabled();
 }
 
 static void memcg_uncharge(struct mem_cgroup *memcg, unsigned int nr_pages);
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-28 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-27  9:17 [PATCH] mm: memcontrol: treat disabled memcg as kmem accounting disabled Hao Li
2026-08-27 12:04 ` Michal Hocko
2026-08-28  0:47   ` Hao Li
2026-08-28 13:58     ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox