mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ren Tamura <ren.tamura.oss@gmail.com>
To: akpm@linux-foundation.org
Cc: roman.gushchin@linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] tools/cgroup: sum shrinker object counts across NUMA nodes
Date: Wed, 30 Sep 2026 15:03:17 +0900	[thread overview]
Message-ID: <179074810112.139422.9274126921568167859@gmail.com> (raw)

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
Signed-off-by: Ren Tamura <ren.tamura.oss@gmail.com>
---
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(-)

diff --git a/tools/cgroup/memcg_shrinker.py b/tools/cgroup/memcg_shrinker.py
index e81c3017ada9643de72d9fcb5e8fb6808382a31b..714772449c6ba9142215e88cf9e4526bdbcb9ee6 100644
--- a/tools/cgroup/memcg_shrinker.py
+++ b/tools/cgroup/memcg_shrinker.py
@@ -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

                 reply	other threads:[~2026-09-30  6:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179074810112.139422.9274126921568167859@gmail.com \
    --to=ren.tamura.oss@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=roman.gushchin@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®