Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <juri.lelli@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@codethink.co.uk> # nuc & rock5b
Link: https://lore.kernel.org/r/20250627115118.438797-6-juri.lelli@redhat.com

authored by

Juri Lelli and committed by
Peter Zijlstra
634c2406 9fdb12c8

+57
+57
tools/sched/dl_bw_dump.py
··· 1 + #!/usr/bin/env drgn 2 + # SPDX-License-Identifier: GPL-2.0 3 + # Copyright (C) 2025 Juri Lelli <juri.lelli@redhat.com> 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()