Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: memcg: dump memcg protection info on oom or alloc failures

Currently kernel dumps memory state on oom and allocation failures. One
of the question usually raised on those dumps is why the kernel has not
reclaimed the reclaimable memory instead of triggering oom. One potential
reason is the usage of memory protection provided by memcg. So, let's
also dump the memory protected by the memcg in such reports to ease the
debugging.

Link: https://lkml.kernel.org/r/20251107234041.3632644-1-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Shakeel Butt and committed by
Andrew Morton
bc8e51c0 05be0287

+20
+5
include/linux/memcontrol.h
··· 1764 1764 1765 1765 bool mem_cgroup_node_allowed(struct mem_cgroup *memcg, int nid); 1766 1766 1767 + void mem_cgroup_show_protected_memory(struct mem_cgroup *memcg); 1767 1768 #else 1768 1769 static inline bool mem_cgroup_kmem_disabled(void) 1769 1770 { ··· 1830 1829 static inline bool mem_cgroup_node_allowed(struct mem_cgroup *memcg, int nid) 1831 1830 { 1832 1831 return true; 1832 + } 1833 + 1834 + static inline void mem_cgroup_show_protected_memory(struct mem_cgroup *memcg) 1835 + { 1833 1836 } 1834 1837 #endif /* CONFIG_MEMCG */ 1835 1838
+13
mm/memcontrol.c
··· 5635 5635 { 5636 5636 return memcg ? cpuset_node_allowed(memcg->css.cgroup, nid) : true; 5637 5637 } 5638 + 5639 + void mem_cgroup_show_protected_memory(struct mem_cgroup *memcg) 5640 + { 5641 + if (mem_cgroup_disabled() || !cgroup_subsys_on_dfl(memory_cgrp_subsys)) 5642 + return; 5643 + 5644 + if (!memcg) 5645 + memcg = root_mem_cgroup; 5646 + 5647 + pr_warn("Memory cgroup min protection %lukB -- low protection %lukB", 5648 + K(atomic_long_read(&memcg->memory.children_min_usage)*PAGE_SIZE), 5649 + K(atomic_long_read(&memcg->memory.children_low_usage)*PAGE_SIZE)); 5650 + }
+1
mm/oom_kill.c
··· 472 472 if (should_dump_unreclaim_slab()) 473 473 dump_unreclaimable_slab(); 474 474 } 475 + mem_cgroup_show_protected_memory(oc->memcg); 475 476 if (sysctl_oom_dump_tasks) 476 477 dump_tasks(oc); 477 478 }
+1
mm/page_alloc.c
··· 3977 3977 filter &= ~SHOW_MEM_FILTER_NODES; 3978 3978 3979 3979 __show_mem(filter, nodemask, gfp_zone(gfp_mask)); 3980 + mem_cgroup_show_protected_memory(NULL); 3980 3981 } 3981 3982 3982 3983 void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)