Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runq: add prio and runtime #131

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 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 @@ -67,18 +69,26 @@ def _print_cfs_runq(runqueue: Object) -> None:

def run_queue(prog: Program) -> 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.
processes running more than x seconds.

:param prog: drgn program
"""

# _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_()
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