From: Juri Lelli <juri.lelli@redhat.com>
To: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
Waiman Long <llong@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Marcel Ziswiler <marcel.ziswiler@codethink.co.uk>,
Luca Abeni <luca.abeni@santannapisa.it>,
Juri Lelli <juri.lelli@redhat.com>
Subject: [PATCH 4/5] tools/sched: Add root_domains_dump.py which dumps root domains info
Date: Fri, 27 Jun 2025 13:51:17 +0200 [thread overview]
Message-ID: <20250627115118.438797-5-juri.lelli@redhat.com> (raw)
In-Reply-To: <20250627115118.438797-1-juri.lelli@redhat.com>
Root domains information is somewhat hard to access at runtime. Even
with sched_debug and sched_verbose, such information is only printed
on kernel console when domains are modified.
Add a simple drgn script to more easily retrieve root domains
information at runtime.
Since tools/sched is a new directory, add it to MAINTAINERS as well.
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
---
MAINTAINERS | 1 +
tools/sched/root_domains_dump.py | 68 ++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+)
create mode 100755 tools/sched/root_domains_dump.py
diff --git a/MAINTAINERS b/MAINTAINERS
index a92290fffa163..b986a49383c9c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22165,6 +22165,7 @@ F: include/linux/wait.h
F: include/uapi/linux/sched.h
F: kernel/fork.c
F: kernel/sched/
+F: tools/sched/
SCHEDULER - SCHED_EXT
R: Tejun Heo <tj@kernel.org>
diff --git a/tools/sched/root_domains_dump.py b/tools/sched/root_domains_dump.py
new file mode 100755
index 0000000000000..56dc91f017b20
--- /dev/null
+++ b/tools/sched/root_domains_dump.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env drgn
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2025 Juri Lelli <juri.lelli@redhat.com>
+# Copyright (C) 2025 Red Hat, Inc.
+
+desc = """
+This is a drgn script to show the current root domains configuration. For more
+info on drgn, visit https://github.com/osandov/drgn.
+
+Root domains are only printed once, as multiple CPUs might be attached to the
+same root domain.
+"""
+
+import os
+import argparse
+
+import drgn
+from drgn import FaultError
+from drgn.helpers.common import *
+from drgn.helpers.linux import *
+
+def print_root_domains_info():
+
+ # To store unique root domains found
+ seen_root_domains = set()
+
+ print("Retrieving (unique) Root Domain Information:")
+
+ runqueues = prog['runqueues']
+ def_root_domain = prog['def_root_domain']
+
+ for cpu_id in for_each_possible_cpu(prog):
+ try:
+ rq = per_cpu(runqueues, cpu_id)
+
+ root_domain = rq.rd
+
+ # Check if we've already processed this root domain to avoid duplicates
+ # Use the memory address of the root_domain as a unique identifier
+ root_domain_cast = int(root_domain)
+ if root_domain_cast in seen_root_domains:
+ continue
+ seen_root_domains.add(root_domain_cast)
+
+ if root_domain_cast == int(def_root_domain.address_):
+ print(f"\n--- Root Domain @ def_root_domain ---")
+ else:
+ print(f"\n--- Root Domain @ 0x{root_domain_cast:x} ---")
+
+ print(f" From CPU: {cpu_id}") # This CPU belongs to this root domain
+
+ # Access and print relevant fields from struct root_domain
+ print(f" Span : {cpumask_to_cpulist(root_domain.span[0])}")
+ print(f" Online : {cpumask_to_cpulist(root_domain.span[0])}")
+
+ except drgn.FaultError as fe:
+ print(f" (CPU {cpu_id}: Fault accessing kernel memory: {fe})")
+ except AttributeError as ae:
+ print(f" (CPU {cpu_id}: Missing attribute for root_domain (kernel struct change?): {ae})")
+ except Exception as e:
+ print(f" (CPU {cpu_id}: An unexpected error occurred: {e})")
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description=desc,
+ formatter_class=argparse.RawTextHelpFormatter)
+ args = parser.parse_args()
+
+ print_root_domains_info()
--
2.49.0
next prev parent reply other threads:[~2025-06-27 11:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 11:51 [PATCH 0/5] sched/deadline: Fix GRUB accounting Juri Lelli
2025-06-27 11:51 ` [PATCH 1/5] sched/deadline: Initialize dl_servers after SMP Juri Lelli
[not found] ` <1e39c473-d161-4ad0-bfdc-8a306f57135f@redhat.com>
2025-06-29 23:08 ` Waiman Long
2025-06-30 10:21 ` Juri Lelli
2025-06-30 17:04 ` Waiman Long
2025-07-14 9:10 ` [tip: sched/core] " tip-bot2 for Juri Lelli
2025-06-27 11:51 ` [PATCH 2/5] sched/deadline: Reset extra_bw to max_bw when clearing root domains Juri Lelli
2025-07-14 9:10 ` [tip: sched/core] " tip-bot2 for Juri Lelli
2025-06-27 11:51 ` [PATCH 3/5] sched/deadline: Fix accounting after global limits change Juri Lelli
2025-07-14 8:59 ` Peter Zijlstra
2025-07-15 10:07 ` Juri Lelli
2025-07-14 9:10 ` [tip: sched/core] " tip-bot2 for Juri Lelli
2025-06-27 11:51 ` Juri Lelli [this message]
2025-07-14 9:10 ` [tip: sched/core] tools/sched: Add root_domains_dump.py which dumps root domains info tip-bot2 for Juri Lelli
2025-06-27 11:51 ` [PATCH 5/5] tools/sched: Add dl_bw_dump.py for printing bandwidth accounting info Juri Lelli
2025-07-14 9:10 ` [tip: sched/core] " tip-bot2 for Juri Lelli
2025-06-30 6:01 ` [PATCH 0/5] sched/deadline: Fix GRUB accounting Marcel Ziswiler
2025-07-11 10:05 ` Marcel Ziswiler
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=20250627115118.438797-5-juri.lelli@redhat.com \
--to=juri.lelli@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llong@redhat.com \
--cc=luca.abeni@santannapisa.it \
--cc=marcel.ziswiler@codethink.co.uk \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/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®