Skip to content

Commit 5d38638

Browse files
committed
bt: skip idle tasks in print_online_bt()
This just makes sense, idle tasks aren't terribly interesting. That said, make this a kwarg just so users can still look at them if they want. Signed-off-by: Stephen Brennan <[email protected]>
1 parent 6839391 commit 5d38638

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drgn_tools/bt.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,27 @@ def bt_has(
570570
return bt_has_any(prog, [funcname], task)
571571

572572

573-
def print_online_bt(prog: Program, **kwargs: t.Any) -> None:
573+
def print_online_bt(
574+
prog: Program, skip_idle: bool = True, **kwargs: t.Any
575+
) -> None:
574576
"""
575577
Prints the stack trace of all on-CPU tasks
576578
577579
:kwargs: passed to bt() to control backtrace format
578580
"""
579581
for cpu in for_each_online_cpu(prog):
582+
task = cpu_curr(prog, cpu)
583+
if skip_idle and task.comm.string_().decode() == f"swapper/{cpu}":
584+
# Just because it's the swapper task, does not mean it is idling.
585+
# Check the symbol at the top of the stack to ensure it's the
586+
# architecture idle function.
587+
trace = prog.stack_trace(task)
588+
try:
589+
sym = trace[0].symbol().name
590+
if sym in ("intel_idle",):
591+
continue
592+
except (IndexError, LookupError):
593+
pass
580594
bt(prog, cpu=cpu, **kwargs)
581595
print()
582596

0 commit comments

Comments
 (0)