Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 2 | # @lint-avoid-python-3-compatibility-imports |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 3 | # |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 4 | # funclatency Time functions and print latency as a histogram. |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 5 | # For Linux, uses BCC, eBPF. |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 6 | # |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 7 | # USAGE: funclatency [-h] [-p PID] [-i INTERVAL] [-T] [-u] [-m] [-F] [-r] [-v] |
| 8 | # pattern |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 9 | # |
| 10 | # Run "funclatency -h" for full usage. |
| 11 | # |
Sasha Goldshtein | f41ae86 | 2016-10-19 01:14:30 +0300 | [diff] [blame] | 12 | # The pattern is a string with optional '*' wildcards, similar to file |
| 13 | # globbing. If you'd prefer to use regular expressions, use the -r option. |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 14 | # |
Brendan Gregg | 50bbca4 | 2015-09-25 12:47:53 -0700 | [diff] [blame] | 15 | # Currently nested or recursive functions are not supported properly, and |
| 16 | # timestamps will be overwritten, creating dubious output. Try to match single |
| 17 | # functions, or groups of functions that run at the same stack layer, and |
| 18 | # don't ultimately call each other. |
| 19 | # |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 20 | # Copyright (c) 2015 Brendan Gregg. |
| 21 | # Licensed under the Apache License, Version 2.0 (the "License") |
| 22 | # |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 23 | # 20-Sep-2015 Brendan Gregg Created this. |
| 24 | # 06-Oct-2016 Sasha Goldshtein Added user function support. |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 25 | |
| 26 | from __future__ import print_function |
| 27 | from bcc import BPF |
| 28 | from time import sleep, strftime |
| 29 | import argparse |
| 30 | import signal |
| 31 | |
| 32 | # arguments |
| 33 | examples = """examples: |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 34 | ./funclatency do_sys_open # time the do_sys_open() kernel function |
| 35 | ./funclatency c:read # time the read() C library function |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 36 | ./funclatency -u vfs_read # time vfs_read(), in microseconds |
| 37 | ./funclatency -m do_nanosleep # time do_nanosleep(), in milliseconds |
Akilesh Kailash | 8996719 | 2018-05-18 13:36:54 -0700 | [diff] [blame] | 38 | ./funclatency -i 2 -d 10 c:open # output every 2 seconds, for duration 10s |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 39 | ./funclatency -mTi 5 vfs_read # output every 5 seconds, with timestamps |
| 40 | ./funclatency -p 181 vfs_read # time process 181 only |
| 41 | ./funclatency 'vfs_fstat*' # time both vfs_fstat() and vfs_fstatat() |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 42 | ./funclatency 'c:*printf' # time the *printf family of functions |
Brendan Gregg | 50bbca4 | 2015-09-25 12:47:53 -0700 | [diff] [blame] | 43 | ./funclatency -F 'vfs_r*' # show one histogram per matched function |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 44 | """ |
| 45 | parser = argparse.ArgumentParser( |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 46 | description="Time functions and print latency as a histogram", |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 47 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 48 | epilog=examples) |
htbegin | 5ac5d6e | 2017-05-24 22:53:17 +0800 | [diff] [blame] | 49 | parser.add_argument("-p", "--pid", type=int, |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 50 | help="trace this PID only") |
Akilesh Kailash | 8996719 | 2018-05-18 13:36:54 -0700 | [diff] [blame] | 51 | parser.add_argument("-i", "--interval", type=int, |
| 52 | help="summary interval, in seconds") |
| 53 | parser.add_argument("-d", "--duration", type=int, |
| 54 | help="total duration of trace, in seconds") |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 55 | parser.add_argument("-T", "--timestamp", action="store_true", |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 56 | help="include timestamp on output") |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 57 | parser.add_argument("-u", "--microseconds", action="store_true", |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 58 | help="microsecond histogram") |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 59 | parser.add_argument("-m", "--milliseconds", action="store_true", |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 60 | help="millisecond histogram") |
Brendan Gregg | 50bbca4 | 2015-09-25 12:47:53 -0700 | [diff] [blame] | 61 | parser.add_argument("-F", "--function", action="store_true", |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 62 | help="show a separate histogram per function") |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 63 | parser.add_argument("-r", "--regexp", action="store_true", |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 64 | help="use regular expressions. Default is \"*\" wildcards only.") |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 65 | parser.add_argument("-v", "--verbose", action="store_true", |
| 66 | help="print the BPF program (for debugging purposes)") |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 67 | parser.add_argument("pattern", |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 68 | help="search expression for functions") |
Nathan Scott | cf0792f | 2018-02-02 16:56:50 +1100 | [diff] [blame] | 69 | parser.add_argument("--ebpf", action="store_true", |
| 70 | help=argparse.SUPPRESS) |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 71 | args = parser.parse_args() |
Akilesh Kailash | 8996719 | 2018-05-18 13:36:54 -0700 | [diff] [blame] | 72 | if args.duration and not args.interval: |
| 73 | args.interval = args.duration |
| 74 | if not args.interval: |
| 75 | args.interval = 99999999 |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 76 | |
| 77 | def bail(error): |
| 78 | print("Error: " + error) |
| 79 | exit(1) |
| 80 | |
| 81 | parts = args.pattern.split(':') |
| 82 | if len(parts) == 1: |
| 83 | library = None |
| 84 | pattern = args.pattern |
| 85 | elif len(parts) == 2: |
| 86 | library = parts[0] |
| 87 | libpath = BPF.find_library(library) or BPF.find_exe(library) |
| 88 | if not libpath: |
| 89 | bail("can't resolve library %s" % library) |
| 90 | library = libpath |
| 91 | pattern = parts[1] |
| 92 | else: |
| 93 | bail("unrecognized pattern format '%s'" % pattern) |
| 94 | |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 95 | if not args.regexp: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 96 | pattern = pattern.replace('*', '.*') |
| 97 | pattern = '^' + pattern + '$' |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 98 | |
| 99 | # define BPF program |
| 100 | bpf_text = """ |
| 101 | #include <uapi/linux/ptrace.h> |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 102 | |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 103 | typedef struct ip_pid { |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 104 | u64 ip; |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 105 | u64 pid; |
| 106 | } ip_pid_t; |
| 107 | |
| 108 | typedef struct hist_key { |
| 109 | ip_pid_t key; |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 110 | u64 slot; |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 111 | } hist_key_t; |
Brendan Gregg | 50bbca4 | 2015-09-25 12:47:53 -0700 | [diff] [blame] | 112 | |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 113 | BPF_HASH(start, u32); |
Brendan Gregg | 50bbca4 | 2015-09-25 12:47:53 -0700 | [diff] [blame] | 114 | STORAGE |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 115 | |
| 116 | int trace_func_entry(struct pt_regs *ctx) |
| 117 | { |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 118 | u64 pid_tgid = bpf_get_current_pid_tgid(); |
| 119 | u32 pid = pid_tgid; |
| 120 | u32 tgid = pid_tgid >> 32; |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 121 | u64 ts = bpf_ktime_get_ns(); |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 122 | |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 123 | FILTER |
| 124 | ENTRYSTORE |
| 125 | start.update(&pid, &ts); |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 126 | |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 127 | return 0; |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | int trace_func_return(struct pt_regs *ctx) |
| 131 | { |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 132 | u64 *tsp, delta; |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 133 | u64 pid_tgid = bpf_get_current_pid_tgid(); |
| 134 | u32 pid = pid_tgid; |
| 135 | u32 tgid = pid_tgid >> 32; |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 136 | |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 137 | // calculate delta time |
| 138 | tsp = start.lookup(&pid); |
| 139 | if (tsp == 0) { |
| 140 | return 0; // missed start |
| 141 | } |
| 142 | delta = bpf_ktime_get_ns() - *tsp; |
| 143 | start.delete(&pid); |
| 144 | FACTOR |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 145 | |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 146 | // store as histogram |
| 147 | STORE |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 148 | |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 149 | return 0; |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 150 | } |
| 151 | """ |
Brendan Gregg | 50bbca4 | 2015-09-25 12:47:53 -0700 | [diff] [blame] | 152 | |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 153 | # do we need to store the IP and pid for each invocation? |
| 154 | need_key = args.function or (library and not args.pid) |
| 155 | |
Brendan Gregg | 50bbca4 | 2015-09-25 12:47:53 -0700 | [diff] [blame] | 156 | # code substitutions |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 157 | if args.pid: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 158 | bpf_text = bpf_text.replace('FILTER', |
htbegin | 5ac5d6e | 2017-05-24 22:53:17 +0800 | [diff] [blame] | 159 | 'if (tgid != %d) { return 0; }' % args.pid) |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 160 | else: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 161 | bpf_text = bpf_text.replace('FILTER', '') |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 162 | if args.milliseconds: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 163 | bpf_text = bpf_text.replace('FACTOR', 'delta /= 1000000;') |
| 164 | label = "msecs" |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 165 | elif args.microseconds: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 166 | bpf_text = bpf_text.replace('FACTOR', 'delta /= 1000;') |
| 167 | label = "usecs" |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 168 | else: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 169 | bpf_text = bpf_text.replace('FACTOR', '') |
| 170 | label = "nsecs" |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 171 | if need_key: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 172 | bpf_text = bpf_text.replace('STORAGE', 'BPF_HASH(ipaddr, u32);\n' + |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 173 | 'BPF_HISTOGRAM(dist, hist_key_t);') |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 174 | # stash the IP on entry, as on return it's kretprobe_trampoline: |
| 175 | bpf_text = bpf_text.replace('ENTRYSTORE', |
Naveen N. Rao | 4afa96a | 2016-05-03 14:54:21 +0530 | [diff] [blame] | 176 | 'u64 ip = PT_REGS_IP(ctx); ipaddr.update(&pid, &ip);') |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 177 | pid = '-1' if not library else 'tgid' |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 178 | bpf_text = bpf_text.replace('STORE', |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 179 | """ |
| 180 | u64 ip, *ipp = ipaddr.lookup(&pid); |
| 181 | if (ipp) { |
| 182 | ip = *ipp; |
| 183 | hist_key_t key; |
| 184 | key.key.ip = ip; |
| 185 | key.key.pid = %s; |
| 186 | key.slot = bpf_log2l(delta); |
| 187 | dist.increment(key); |
| 188 | ipaddr.delete(&pid); |
| 189 | } |
| 190 | """ % pid) |
Brendan Gregg | 50bbca4 | 2015-09-25 12:47:53 -0700 | [diff] [blame] | 191 | else: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 192 | bpf_text = bpf_text.replace('STORAGE', 'BPF_HISTOGRAM(dist);') |
| 193 | bpf_text = bpf_text.replace('ENTRYSTORE', '') |
| 194 | bpf_text = bpf_text.replace('STORE', |
| 195 | 'dist.increment(bpf_log2l(delta));') |
Nathan Scott | cf0792f | 2018-02-02 16:56:50 +1100 | [diff] [blame] | 196 | if args.verbose or args.ebpf: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 197 | print(bpf_text) |
Nathan Scott | cf0792f | 2018-02-02 16:56:50 +1100 | [diff] [blame] | 198 | if args.ebpf: |
| 199 | exit() |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 200 | |
| 201 | # signal handler |
| 202 | def signal_ignore(signal, frame): |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 203 | print() |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 204 | |
| 205 | # load BPF program |
| 206 | b = BPF(text=bpf_text) |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 207 | |
| 208 | # attach probes |
| 209 | if not library: |
| 210 | b.attach_kprobe(event_re=pattern, fn_name="trace_func_entry") |
| 211 | b.attach_kretprobe(event_re=pattern, fn_name="trace_func_return") |
| 212 | matched = b.num_open_kprobes() |
| 213 | else: |
Paul Chaignon | d73c58f | 2017-01-21 14:25:41 +0100 | [diff] [blame] | 214 | b.attach_uprobe(name=library, sym_re=pattern, fn_name="trace_func_entry", |
| 215 | pid=args.pid or -1) |
Sasha Goldshtein | f41ae86 | 2016-10-19 01:14:30 +0300 | [diff] [blame] | 216 | b.attach_uretprobe(name=library, sym_re=pattern, |
Paul Chaignon | d73c58f | 2017-01-21 14:25:41 +0100 | [diff] [blame] | 217 | fn_name="trace_func_return", pid=args.pid or -1) |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 218 | matched = b.num_open_uprobes() |
| 219 | |
Brendan Gregg | 6b8add0 | 2015-09-25 11:16:33 -0700 | [diff] [blame] | 220 | if matched == 0: |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 221 | print("0 functions matched by \"%s\". Exiting." % args.pattern) |
| 222 | exit() |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 223 | |
| 224 | # header |
Brendan Gregg | 6b8add0 | 2015-09-25 11:16:33 -0700 | [diff] [blame] | 225 | print("Tracing %d functions for \"%s\"... Hit Ctrl-C to end." % |
| 226 | (matched / 2, args.pattern)) |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 227 | |
| 228 | # output |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 229 | def print_section(key): |
| 230 | if not library: |
| 231 | return BPF.sym(key[0], -1) |
| 232 | else: |
| 233 | return "%s [%d]" % (BPF.sym(key[0], key[1]), key[1]) |
| 234 | |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 235 | exiting = 0 if args.interval else 1 |
Akilesh Kailash | 8996719 | 2018-05-18 13:36:54 -0700 | [diff] [blame] | 236 | seconds = 0 |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 237 | dist = b.get_table("dist") |
| 238 | while (1): |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 239 | try: |
Akilesh Kailash | 8996719 | 2018-05-18 13:36:54 -0700 | [diff] [blame] | 240 | sleep(args.interval) |
| 241 | seconds += args.interval |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 242 | except KeyboardInterrupt: |
| 243 | exiting = 1 |
| 244 | # as cleanup can take many seconds, trap Ctrl-C: |
| 245 | signal.signal(signal.SIGINT, signal_ignore) |
Akilesh Kailash | 8996719 | 2018-05-18 13:36:54 -0700 | [diff] [blame] | 246 | if args.duration and seconds >= args.duration: |
| 247 | exiting = 1 |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 248 | |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 249 | print() |
| 250 | if args.timestamp: |
| 251 | print("%-8s\n" % strftime("%H:%M:%S"), end="") |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 252 | |
Sasha Goldshtein | a466c46 | 2016-10-06 21:17:59 +0300 | [diff] [blame] | 253 | if need_key: |
| 254 | dist.print_log2_hist(label, "Function", section_print_fn=print_section, |
| 255 | bucket_fn=lambda k: (k.ip, k.pid)) |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 256 | else: |
| 257 | dist.print_log2_hist(label) |
| 258 | dist.clear() |
Brendan Gregg | 74016c3 | 2015-09-21 15:49:21 -0700 | [diff] [blame] | 259 | |
Alexei Starovoitov | bdf0773 | 2016-01-14 10:09:20 -0800 | [diff] [blame] | 260 | if exiting: |
| 261 | print("Detaching...") |
| 262 | exit() |