Skip to content

Commit

Permalink
runq: add prio and runtime
Browse files Browse the repository at this point in the history
Orabug: 37187104
Signed-off-by: Richard Li <[email protected]>
  • Loading branch information
richl9 authored and biger410 committed Nov 25, 2024
1 parent 61704f2 commit bc95543
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 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,31 @@ 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)
prio = curr_task.prio.value_()
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' COMMAND: "{comm}"',
f" CURRENT: PID: {pid:<6d} TASK: {curr_task_addr:x} PRIO: {prio}"
f' COMMAND: "{comm}"'
f" RUNTIME: {timestamp_str(run_time)}",
)
# RT PRIO_ARRAY
_print_rt_runq(runqueue)
Expand Down

0 comments on commit bc95543

Please sign in to comment.