Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # |
| 3 | # offwaketime Summarize blocked time by kernel off-CPU stack + waker stack |
| 4 | # For Linux, uses BCC, eBPF. |
| 5 | # |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 6 | # USAGE: offwaketime [-h] [-p PID | -u | -k] [-U | -K] [-f] [duration] |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 7 | # |
| 8 | # Copyright 2016 Netflix, Inc. |
| 9 | # Licensed under the Apache License, Version 2.0 (the "License") |
| 10 | # |
Alexei Starovoitov | 7583a4e | 2016-02-03 21:25:43 -0800 | [diff] [blame] | 11 | # 20-Jan-2016 Brendan Gregg Created this. |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 12 | |
| 13 | from __future__ import print_function |
| 14 | from bcc import BPF |
Alexei Starovoitov | 7583a4e | 2016-02-03 21:25:43 -0800 | [diff] [blame] | 15 | from time import sleep |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 16 | import argparse |
| 17 | import signal |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 18 | import errno |
| 19 | from sys import stderr |
| 20 | |
| 21 | # arg validation |
| 22 | def positive_int(val): |
| 23 | try: |
| 24 | ival = int(val) |
| 25 | except ValueError: |
| 26 | raise argparse.ArgumentTypeError("must be an integer") |
| 27 | |
| 28 | if ival < 0: |
| 29 | raise argparse.ArgumentTypeError("must be positive") |
| 30 | return ival |
| 31 | |
| 32 | def positive_nonzero_int(val): |
| 33 | ival = positive_int(val) |
| 34 | if ival == 0: |
| 35 | raise argparse.ArgumentTypeError("must be nonzero") |
| 36 | return ival |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 37 | |
| 38 | # arguments |
| 39 | examples = """examples: |
| 40 | ./offwaketime # trace off-CPU + waker stack time until Ctrl-C |
| 41 | ./offwaketime 5 # trace for 5 seconds only |
| 42 | ./offwaketime -f 5 # 5 seconds, and output in folded format |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 43 | ./offwaketime -m 1000 # trace only events that last more than 1000 usec |
| 44 | ./offwaketime -M 9000 # trace only events that last less than 9000 usec |
| 45 | ./offwaketime -p 185 # only trace threads for PID 185 |
| 46 | ./offwaketime -t 188 # only trace thread 188 |
| 47 | ./offwaketime -u # only trace user threads (no kernel) |
| 48 | ./offwaketime -k # only trace kernel threads (no user) |
| 49 | ./offwaketime -U # only show user space stacks (no kernel) |
| 50 | ./offwaketime -K # only show kernel space stacks (no user) |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 51 | """ |
| 52 | parser = argparse.ArgumentParser( |
| 53 | description="Summarize blocked time by kernel stack trace + waker stack", |
| 54 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 55 | epilog=examples) |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 56 | thread_group = parser.add_mutually_exclusive_group() |
| 57 | # Note: this script provides --pid and --tid flags but their arguments are |
| 58 | # referred to internally using kernel nomenclature: TGID and PID. |
| 59 | thread_group.add_argument("-p", "--pid", metavar="PID", dest="tgid", |
| 60 | help="trace this PID only", type=positive_int) |
| 61 | thread_group.add_argument("-t", "--tid", metavar="TID", dest="pid", |
| 62 | help="trace this TID only", type=positive_int) |
| 63 | thread_group.add_argument("-u", "--user-threads-only", action="store_true", |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 64 | help="user threads only (no kernel threads)") |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 65 | thread_group.add_argument("-k", "--kernel-threads-only", action="store_true", |
| 66 | help="kernel threads only (no user threads)") |
| 67 | stack_group = parser.add_mutually_exclusive_group() |
| 68 | stack_group.add_argument("-U", "--user-stacks-only", action="store_true", |
| 69 | help="show stacks from user space only (no kernel space stacks)") |
| 70 | stack_group.add_argument("-K", "--kernel-stacks-only", action="store_true", |
| 71 | help="show stacks from kernel space only (no user space stacks)") |
| 72 | parser.add_argument("-d", "--delimited", action="store_true", |
| 73 | help="insert delimiter between kernel/user stacks") |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 74 | parser.add_argument("-f", "--folded", action="store_true", |
| 75 | help="output folded format") |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 76 | parser.add_argument("--stack-storage-size", default=1024, |
| 77 | type=positive_nonzero_int, |
| 78 | help="the number of unique stack traces that can be stored and " |
| 79 | "displayed (default 1024)") |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 80 | parser.add_argument("duration", nargs="?", default=99999999, |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 81 | type=positive_nonzero_int, |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 82 | help="duration of trace, in seconds") |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 83 | parser.add_argument("-m", "--min-block-time", default=1, |
| 84 | type=positive_nonzero_int, |
| 85 | help="the amount of time in microseconds over which we " + |
| 86 | "store traces (default 1)") |
| 87 | parser.add_argument("-M", "--max-block-time", default=(1 << 64) - 1, |
| 88 | type=positive_nonzero_int, |
| 89 | help="the amount of time in microseconds under which we " + |
| 90 | "store traces (default U64_MAX)") |
Nathan Scott | cf0792f | 2018-02-02 16:56:50 +1100 | [diff] [blame] | 91 | parser.add_argument("--ebpf", action="store_true", |
| 92 | help=argparse.SUPPRESS) |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 93 | args = parser.parse_args() |
| 94 | folded = args.folded |
| 95 | duration = int(args.duration) |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 96 | |
| 97 | # signal handler |
| 98 | def signal_ignore(signal, frame): |
| 99 | print() |
| 100 | |
| 101 | # define BPF program |
| 102 | bpf_text = """ |
| 103 | #include <uapi/linux/ptrace.h> |
| 104 | #include <linux/sched.h> |
| 105 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 106 | #define MINBLOCK_US MINBLOCK_US_VALUEULL |
| 107 | #define MAXBLOCK_US MAXBLOCK_US_VALUEULL |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 108 | |
| 109 | struct key_t { |
| 110 | char waker[TASK_COMM_LEN]; |
| 111 | char target[TASK_COMM_LEN]; |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 112 | int w_k_stack_id; |
| 113 | int w_u_stack_id; |
| 114 | int t_k_stack_id; |
| 115 | int t_u_stack_id; |
| 116 | u32 t_pid; |
| 117 | u32 w_pid; |
| 118 | u32 tgid; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 119 | }; |
| 120 | BPF_HASH(counts, struct key_t); |
| 121 | BPF_HASH(start, u32); |
| 122 | struct wokeby_t { |
| 123 | char name[TASK_COMM_LEN]; |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 124 | int k_stack_id; |
| 125 | int u_stack_id; |
| 126 | int w_pid; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 127 | }; |
| 128 | BPF_HASH(wokeby, u32, struct wokeby_t); |
| 129 | |
Song Liu | 67ae605 | 2018-02-01 14:59:24 -0800 | [diff] [blame] | 130 | BPF_STACK_TRACE(stack_traces, STACK_STORAGE_SIZE); |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 131 | |
| 132 | int waker(struct pt_regs *ctx, struct task_struct *p) { |
| 133 | u32 pid = p->pid; |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 134 | u32 tgid = p->tgid; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 135 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 136 | if (!(THREAD_FILTER)) { |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 137 | return 0; |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 138 | } |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 139 | |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 140 | struct wokeby_t woke = {}; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 141 | bpf_get_current_comm(&woke.name, sizeof(woke.name)); |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 142 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 143 | woke.k_stack_id = KERNEL_STACK_GET; |
| 144 | woke.u_stack_id = USER_STACK_GET; |
| 145 | woke.w_pid = pid; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 146 | wokeby.update(&pid, &woke); |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | int oncpu(struct pt_regs *ctx, struct task_struct *p) { |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 151 | u32 pid = p->pid, t_pid=pid; |
| 152 | u32 tgid = p->tgid; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 153 | u64 ts, *tsp; |
| 154 | |
| 155 | // record previous thread sleep time |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 156 | if (THREAD_FILTER) { |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 157 | ts = bpf_ktime_get_ns(); |
| 158 | start.update(&pid, &ts); |
| 159 | } |
| 160 | |
| 161 | // calculate current thread's delta time |
| 162 | pid = bpf_get_current_pid_tgid(); |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 163 | tgid = bpf_get_current_pid_tgid() >> 32; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 164 | tsp = start.lookup(&pid); |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 165 | if (tsp == 0) { |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 166 | return 0; // missed start or filtered |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 167 | } |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 168 | u64 delta = bpf_ktime_get_ns() - *tsp; |
| 169 | start.delete(&pid); |
| 170 | delta = delta / 1000; |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 171 | if ((delta < MINBLOCK_US) || (delta > MAXBLOCK_US)) { |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 172 | return 0; |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 173 | } |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 174 | |
| 175 | // create map key |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 176 | u64 zero = 0, *val; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 177 | struct key_t key = {}; |
| 178 | struct wokeby_t *woke; |
| 179 | bpf_get_current_comm(&key.target, sizeof(key.target)); |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 180 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 181 | key.t_k_stack_id = KERNEL_STACK_GET; |
| 182 | key.t_u_stack_id = USER_STACK_GET; |
| 183 | key.t_pid = t_pid; |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 184 | |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 185 | woke = wokeby.lookup(&pid); |
| 186 | if (woke) { |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 187 | key.w_k_stack_id = woke->k_stack_id; |
| 188 | key.w_u_stack_id = woke->u_stack_id; |
| 189 | key.w_pid = woke->w_pid; |
| 190 | key.tgid = tgid; |
Alexei Starovoitov | 7583a4e | 2016-02-03 21:25:43 -0800 | [diff] [blame] | 191 | __builtin_memcpy(&key.waker, woke->name, TASK_COMM_LEN); |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 192 | wokeby.delete(&pid); |
| 193 | } |
| 194 | |
| 195 | val = counts.lookup_or_init(&key, &zero); |
| 196 | (*val) += delta; |
| 197 | return 0; |
| 198 | } |
| 199 | """ |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 200 | |
| 201 | # set thread filter |
| 202 | thread_context = "" |
| 203 | if args.tgid is not None: |
| 204 | thread_context = "PID %d" % args.tgid |
| 205 | thread_filter = 'tgid == %d' % args.tgid |
| 206 | elif args.pid is not None: |
| 207 | thread_context = "TID %d" % args.pid |
| 208 | thread_filter = 'pid == %d' % args.pid |
| 209 | elif args.user_threads_only: |
| 210 | thread_context = "user threads" |
| 211 | thread_filter = '!(p->flags & PF_KTHREAD)' |
| 212 | elif args.kernel_threads_only: |
| 213 | thread_context = "kernel threads" |
| 214 | thread_filter = 'p->flags & PF_KTHREAD' |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 215 | else: |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 216 | thread_context = "all threads" |
| 217 | thread_filter = '1' |
| 218 | bpf_text = bpf_text.replace('THREAD_FILTER', thread_filter) |
| 219 | |
| 220 | # set stack storage size |
| 221 | bpf_text = bpf_text.replace('STACK_STORAGE_SIZE', str(args.stack_storage_size)) |
| 222 | bpf_text = bpf_text.replace('MINBLOCK_US_VALUE', str(args.min_block_time)) |
| 223 | bpf_text = bpf_text.replace('MAXBLOCK_US_VALUE', str(args.max_block_time)) |
| 224 | |
| 225 | # handle stack args |
| 226 | kernel_stack_get = "stack_traces.get_stackid(ctx, BPF_F_REUSE_STACKID)" |
| 227 | user_stack_get = \ |
| 228 | "stack_traces.get_stackid(ctx, BPF_F_REUSE_STACKID | BPF_F_USER_STACK)" |
| 229 | stack_context = "" |
| 230 | if args.user_stacks_only: |
| 231 | stack_context = "user" |
| 232 | kernel_stack_get = "-1" |
| 233 | elif args.kernel_stacks_only: |
| 234 | stack_context = "kernel" |
| 235 | user_stack_get = "-1" |
| 236 | else: |
| 237 | stack_context = "user + kernel" |
| 238 | bpf_text = bpf_text.replace('USER_STACK_GET', user_stack_get) |
| 239 | bpf_text = bpf_text.replace('KERNEL_STACK_GET', kernel_stack_get) |
Nathan Scott | cf0792f | 2018-02-02 16:56:50 +1100 | [diff] [blame] | 240 | if args.ebpf: |
| 241 | print(bpf_text) |
| 242 | exit() |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 243 | |
| 244 | # initialize BPF |
| 245 | b = BPF(text=bpf_text) |
| 246 | b.attach_kprobe(event="finish_task_switch", fn_name="oncpu") |
| 247 | b.attach_kprobe(event="try_to_wake_up", fn_name="waker") |
| 248 | matched = b.num_open_kprobes() |
| 249 | if matched == 0: |
| 250 | print("0 functions traced. Exiting.") |
| 251 | exit() |
| 252 | |
| 253 | # header |
| 254 | if not folded: |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 255 | print("Tracing blocked time (us) by %s off-CPU and waker stack" % |
| 256 | stack_context, end="") |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 257 | if duration < 99999999: |
| 258 | print(" for %d secs." % duration) |
| 259 | else: |
| 260 | print("... Hit Ctrl-C to end.") |
| 261 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 262 | # as cleanup can take many seconds, trap Ctrl-C: |
| 263 | # print a newline for folded output on Ctrl-C |
| 264 | signal.signal(signal.SIGINT, signal_ignore) |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 265 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 266 | sleep(duration) |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 267 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 268 | if not folded: |
| 269 | print() |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 270 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 271 | missing_stacks = 0 |
| 272 | has_enomem = False |
| 273 | counts = b.get_table("counts") |
| 274 | stack_traces = b.get_table("stack_traces") |
| 275 | for k, v in sorted(counts.items(), key=lambda counts: counts[1].value): |
| 276 | # handle get_stackid errors |
| 277 | # check for an ENOMEM error |
| 278 | if k.w_k_stack_id == -errno.ENOMEM or \ |
| 279 | k.t_k_stack_id == -errno.ENOMEM or \ |
| 280 | k.w_u_stack_id == -errno.ENOMEM or \ |
| 281 | k.t_u_stack_id == -errno.ENOMEM: |
| 282 | missing_stacks += 1 |
| 283 | continue |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 284 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 285 | waker_user_stack = [] if k.w_u_stack_id < 1 else \ |
| 286 | reversed(list(stack_traces.walk(k.w_u_stack_id))[1:]) |
| 287 | waker_kernel_stack = [] if k.w_k_stack_id < 1 else \ |
| 288 | reversed(list(stack_traces.walk(k.w_k_stack_id))[1:]) |
| 289 | target_user_stack = [] if k.t_u_stack_id < 1 else \ |
| 290 | stack_traces.walk(k.t_u_stack_id) |
| 291 | target_kernel_stack = [] if k.t_k_stack_id < 1 else \ |
| 292 | stack_traces.walk(k.t_k_stack_id) |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 293 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 294 | if folded: |
| 295 | # print folded stack output |
| 296 | line = \ |
Linuxraptor | fabd9a1 | 2018-01-19 00:21:17 -0800 | [diff] [blame] | 297 | [k.target.decode()] + \ |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 298 | [b.sym(addr, k.tgid) |
| 299 | for addr in reversed(list(target_user_stack)[1:])] + \ |
| 300 | (["-"] if args.delimited else [""]) + \ |
| 301 | [b.ksym(addr) |
| 302 | for addr in reversed(list(target_kernel_stack)[1:])] + \ |
| 303 | ["--"] + \ |
| 304 | [b.ksym(addr) |
| 305 | for addr in reversed(list(waker_kernel_stack))] + \ |
| 306 | (["-"] if args.delimited else [""]) + \ |
| 307 | [b.sym(addr, k.tgid) |
| 308 | for addr in reversed(list(waker_user_stack))] + \ |
Linuxraptor | fabd9a1 | 2018-01-19 00:21:17 -0800 | [diff] [blame] | 309 | [k.waker.decode()] |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 310 | print("%s %d" % (";".join(line), v.value)) |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 311 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 312 | else: |
| 313 | # print wakeup name then stack in reverse order |
Rafael F | 78948e4 | 2017-03-26 14:54:25 +0200 | [diff] [blame] | 314 | print(" %-16s %s %s" % ("waker:", k.waker.decode(), k.t_pid)) |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 315 | for addr in waker_user_stack: |
Sasha Goldshtein | 2f78068 | 2017-02-09 00:20:56 -0500 | [diff] [blame] | 316 | print(" %s" % b.sym(addr, k.tgid)) |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 317 | if args.delimited: |
| 318 | print(" -") |
| 319 | for addr in waker_kernel_stack: |
Sasha Goldshtein | 2f78068 | 2017-02-09 00:20:56 -0500 | [diff] [blame] | 320 | print(" %s" % b.ksym(addr)) |
Brendan Gregg | af2b46a | 2016-01-30 11:02:29 -0800 | [diff] [blame] | 321 | |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 322 | # print waker/wakee delimiter |
| 323 | print(" %-16s %s" % ("--", "--")) |
| 324 | |
| 325 | # print default multi-line stack output |
| 326 | for addr in target_kernel_stack: |
Sasha Goldshtein | 2f78068 | 2017-02-09 00:20:56 -0500 | [diff] [blame] | 327 | print(" %s" % b.ksym(addr)) |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 328 | if args.delimited: |
| 329 | print(" -") |
| 330 | for addr in target_user_stack: |
Sasha Goldshtein | 2f78068 | 2017-02-09 00:20:56 -0500 | [diff] [blame] | 331 | print(" %s" % b.sym(addr, k.tgid)) |
Rafael F | 78948e4 | 2017-03-26 14:54:25 +0200 | [diff] [blame] | 332 | print(" %-16s %s %s" % ("target:", k.target.decode(), k.w_pid)) |
ceeaspb | 47cecb6 | 2016-11-26 22:36:10 +0000 | [diff] [blame] | 333 | print(" %d\n" % v.value) |
| 334 | |
| 335 | if missing_stacks > 0: |
| 336 | enomem_str = " Consider increasing --stack-storage-size." |
| 337 | print("WARNING: %d stack traces could not be displayed.%s" % |
| 338 | (missing_stacks, enomem_str), |
| 339 | file=stderr) |