Skip to content

Commit

Permalink
add RUNTIME to runq helper
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Li <[email protected]>
  • Loading branch information
richl9 committed Sep 11, 2024
1 parent 80e126e commit 9ba3ed0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions drgn_tools/runq.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from drgn.helpers.linux.percpu import per_cpu

from drgn_tools.corelens import CorelensModule
from drgn_tools.task import task_lastrun2now
from drgn_tools.util import timestamp_str

# List runqueus per cpu

Expand Down Expand Up @@ -65,20 +67,30 @@ def _print_cfs_runq(runqueue: Object) -> None:
print(" [no tasks queued]")


def run_queue(prog: Program) -> None:
def run_queue(prog: Program, min_run_time_seconds: int = 0) -> None:
"""
Print tasks which are in the RT and CFS runqueues on each CPU
Print tasks which are in the RT and CFS runqueues on each CPU. Specify min_run_time_seconds to x to only print
processes running more than x seconds.
:param prog: drgn program
:param min_run_time_seconds: int
"""

# _cpu = drgn.helpers.linux.cpumask.for_each_online_cpu(prog)
for cpus in for_each_online_cpu(prog):
runqueue = per_cpu(prog["runqueues"], cpus)
comm = escape_ascii_string(runqueue.curr.comm.string_())
pid = runqueue.curr.pid.value_()
curr_task_addr = runqueue.curr.value_()
curr_task = runqueue.curr[0]
comm = escape_ascii_string(curr_task.comm.string_())
pid = curr_task.pid.value_()
run_time = task_lastrun2now(curr_task)
if run_time < min_run_time_seconds * 1e9:
continue
print(f"CPU {cpus} RUNQUEUE: {runqueue.address_of_().value_():x}")
print(
f" CURRENT: PID: {pid:<6d} TASK: {runqueue.curr.value_():x}"
f" CURRENT: PID: {pid:<6d} TASK: {curr_task_addr:x}"
f' COMMAND: "{comm}"',
f" RUNTIME: {timestamp_str(run_time)}",
)
# RT PRIO_ARRAY
_print_rt_runq(runqueue)
Expand Down

0 comments on commit 9ba3ed0

Please sign in to comment.