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.

Link: https://lore.kernel.org/179074810112.139422.9274126921568167859@gmail.com
Fixes: d261ea2353 ("tools: add memcg_shrinker.py")
Signed-off-by: Ren Tamura <ren.tamura.oss@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Assisted-by: LLM
Cc: Roman Gushchin <roman.gushchin@linux.dev>
This commit is contained in:
Ren Tamura 2026-09-30 15:03:17 +09:00 committed by Andrew Morton
parent dc0b17144d
commit ae2514c955

View File

@ -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