Skip to contentSkip to conversation

tools/cgroup: sum shrinker object counts across NUMA nodes

PATCH Applied Ren Tamura 1 participant 1 message Sep 30 Memory management

lore
Share & tools
lore

Ren Tamura

author
#0 lore raw

PATCH 1/1 tools/cgroup: sum shrinker object counts across NUMA nodes

Each row of a memcg-aware shrinker's debugfs count file contains the cgroup ID followed by one object count per NUMA node. memcg_shrinker.py uses only the first count when sorting and displaying entries.

This undercounts objects on NUMA systems. An entry with counts of 0 and 23 is treated as zero and omitted from the output, even though its total is 23.

Sum all count fields after the cgroup ID so that the displayed totals and sort order account for every node. Single-node input retains the same result.

Fixes d261ea23533b ("tools: add memcg_shrinker.py")
Assisted-by LLM

---
Validation (2026-09-24, mainline 62f4c998b297): ran the original and modified scanner and display code on Linux against count-file fixtures. Multi-node counts changed from 0/7/4 to 23/18/4, while a single-node count of 9 stayed unchanged. This validation uses fixtures, not a live NUMA shrinker workload.

LLM assistance: finding small cgroup fixes, drafting code and commit messages, and preparing validation.

 tools/cgroup/memcg_shrinker.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/cgroup/memcg_shrinker.py +1 -1
index e81c3017ada9643de72d9fcb5e8fb6808382a31b..714772449c6ba9142215e88cf9e4526bdbcb9ee6 100644
@@ -31,7 +31,7 @@ def scan_shrinkers(shrinker_debugfs):
                     items = line.split(' ')
                     ino = int(items[0])
                     # (count, shrinker, memcg ino)
-                    shrinkers.append((int(items[1]), shrinker, ino))
+                    shrinkers.append((sum(map(int, items[1:])), shrinker, ino))
     return shrinkers
 
 

base-commit: 551c722f40809618230001baccf219193e22fc5a