Skip to content

Commit 634c240

Browse files
jlelliPeter Zijlstra
authored andcommitted
tools/sched: Add dl_bw_dump.py for printing bandwidth accounting info
dl_rq bandwidth accounting information is crucial for the correct functioning of SCHED_DEADLINE. Add a drgn script for accessing that information at runtime, so that it's easier to check and debug issues related to it. Signed-off-by: Juri Lelli <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Marcel Ziswiler <[email protected]> # nuc & rock5b Link: https://lore.kernel.org/r/[email protected]
1 parent 9fdb12c commit 634c240

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tools/sched/dl_bw_dump.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env drgn
2+
# SPDX-License-Identifier: GPL-2.0
3+
# Copyright (C) 2025 Juri Lelli <[email protected]>
4+
# Copyright (C) 2025 Red Hat, Inc.
5+
6+
desc = """
7+
This is a drgn script to show dl_rq bandwidth accounting information. For more
8+
info on drgn, visit https://github.com/osandov/drgn.
9+
10+
Only online CPUs are reported.
11+
"""
12+
13+
import os
14+
import argparse
15+
16+
import drgn
17+
from drgn import FaultError
18+
from drgn.helpers.common import *
19+
from drgn.helpers.linux import *
20+
21+
def print_dl_bws_info():
22+
23+
print("Retrieving dl_rq bandwidth accounting information:")
24+
25+
runqueues = prog['runqueues']
26+
27+
for cpu_id in for_each_possible_cpu(prog):
28+
try:
29+
rq = per_cpu(runqueues, cpu_id)
30+
31+
if rq.online == 0:
32+
continue
33+
34+
dl_rq = rq.dl
35+
36+
print(f" From CPU: {cpu_id}")
37+
38+
# Access and print relevant fields from struct dl_rq
39+
print(f" running_bw : {dl_rq.running_bw}")
40+
print(f" this_bw : {dl_rq.this_bw}")
41+
print(f" extra_bw : {dl_rq.extra_bw}")
42+
print(f" max_bw : {dl_rq.max_bw}")
43+
print(f" bw_ratio : {dl_rq.bw_ratio}")
44+
45+
except drgn.FaultError as fe:
46+
print(f" (CPU {cpu_id}: Fault accessing kernel memory: {fe})")
47+
except AttributeError as ae:
48+
print(f" (CPU {cpu_id}: Missing attribute for root_domain (kernel struct change?): {ae})")
49+
except Exception as e:
50+
print(f" (CPU {cpu_id}: An unexpected error occurred: {e})")
51+
52+
if __name__ == "__main__":
53+
parser = argparse.ArgumentParser(description=desc,
54+
formatter_class=argparse.RawTextHelpFormatter)
55+
args = parser.parse_args()
56+
57+
print_dl_bws_info()

0 commit comments

Comments
 (0)