Alexey Ivanov | cc01a9c | 2019-01-16 09:50:46 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 2 | # @lint-avoid-python-3-compatibility-imports |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 3 | # |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 4 | # biolatency Summarize block device I/O latency as a histogram. |
| 5 | # For Linux, uses BCC, eBPF. |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 6 | # |
xingfeng2510 | 3d07ee8 | 2022-03-10 09:38:16 +0800 | [diff] [blame] | 7 | # USAGE: biolatency [-h] [-T] [-Q] [-m] [-D] [-F] [-e] [-j] [interval] [count] |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 8 | # |
| 9 | # Copyright (c) 2015 Brendan Gregg. |
| 10 | # Licensed under the Apache License, Version 2.0 (the "License") |
| 11 | # |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 12 | # 20-Sep-2015 Brendan Gregg Created this. |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 13 | |
| 14 | from __future__ import print_function |
| 15 | from bcc import BPF |
| 16 | from time import sleep, strftime |
| 17 | import argparse |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 18 | import ctypes as ct |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 19 | |
| 20 | # arguments |
| 21 | examples = """examples: |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 22 | ./biolatency # summarize block I/O latency as a histogram |
| 23 | ./biolatency 1 10 # print 1 second summaries, 10 times |
| 24 | ./biolatency -mT 1 # 1s summaries, milliseconds, and timestamps |
| 25 | ./biolatency -Q # include OS queued time in I/O time |
| 26 | ./biolatency -D # show each disk device separately |
| 27 | ./biolatency -F # show I/O flags separately |
| 28 | ./biolatency -j # print a dictionary |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 29 | ./biolatency -e # show extension summary(total, average) |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 30 | """ |
| 31 | parser = argparse.ArgumentParser( |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 32 | description="Summarize block device I/O latency as a histogram", |
| 33 | formatter_class=argparse.RawDescriptionHelpFormatter, |
Nathan Scott | 1a197db | 2018-01-21 09:14:27 +1100 | [diff] [blame] | 34 | epilog=examples) |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 35 | parser.add_argument("-T", "--timestamp", action="store_true", |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 36 | help="include timestamp on output") |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 37 | parser.add_argument("-Q", "--queued", action="store_true", |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 38 | help="include OS queued time in I/O time") |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 39 | parser.add_argument("-m", "--milliseconds", action="store_true", |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 40 | help="millisecond histogram") |
Brendan Gregg | 44e6877 | 2015-09-25 13:20:16 -0700 | [diff] [blame] | 41 | parser.add_argument("-D", "--disks", action="store_true", |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 42 | help="print a histogram per disk device") |
Brendan Gregg | c6cded4 | 2019-03-20 09:32:20 -0700 | [diff] [blame] | 43 | parser.add_argument("-F", "--flags", action="store_true", |
| 44 | help="print a histogram per set of I/O flags") |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 45 | parser.add_argument("-e", "--extension", action="store_true", |
| 46 | help="summarize average/total value") |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 47 | parser.add_argument("interval", nargs="?", default=99999999, |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 48 | help="output interval, in seconds") |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 49 | parser.add_argument("count", nargs="?", default=99999999, |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 50 | help="number of outputs") |
Nathan Scott | f5fb9af | 2018-01-17 09:39:59 +1100 | [diff] [blame] | 51 | parser.add_argument("--ebpf", action="store_true", |
| 52 | help=argparse.SUPPRESS) |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 53 | parser.add_argument("-j", "--json", action="store_true", |
| 54 | help="json output") |
| 55 | |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 56 | args = parser.parse_args() |
| 57 | countdown = int(args.count) |
| 58 | debug = 0 |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 59 | |
Brendan Gregg | c6cded4 | 2019-03-20 09:32:20 -0700 | [diff] [blame] | 60 | if args.flags and args.disks: |
| 61 | print("ERROR: can only use -D or -F. Exiting.") |
| 62 | exit() |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 63 | |
Brendan Gregg | 44e6877 | 2015-09-25 13:20:16 -0700 | [diff] [blame] | 64 | # define BPF program |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 65 | bpf_text = """ |
| 66 | #include <uapi/linux/ptrace.h> |
Jerome Marchand | ee81072 | 2022-02-23 16:04:30 +0100 | [diff] [blame] | 67 | #include <linux/blk-mq.h> |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 68 | |
Brendan Gregg | 44e6877 | 2015-09-25 13:20:16 -0700 | [diff] [blame] | 69 | typedef struct disk_key { |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 70 | char disk[DISK_NAME_LEN]; |
| 71 | u64 slot; |
Brendan Gregg | 44e6877 | 2015-09-25 13:20:16 -0700 | [diff] [blame] | 72 | } disk_key_t; |
Brendan Gregg | c6cded4 | 2019-03-20 09:32:20 -0700 | [diff] [blame] | 73 | |
| 74 | typedef struct flag_key { |
| 75 | u64 flags; |
| 76 | u64 slot; |
| 77 | } flag_key_t; |
| 78 | |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 79 | typedef struct ext_val { |
| 80 | u64 total; |
| 81 | u64 count; |
| 82 | } ext_val_t; |
| 83 | |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 84 | BPF_HASH(start, struct request *); |
Brendan Gregg | 44e6877 | 2015-09-25 13:20:16 -0700 | [diff] [blame] | 85 | STORAGE |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 86 | |
| 87 | // time block I/O |
| 88 | int trace_req_start(struct pt_regs *ctx, struct request *req) |
| 89 | { |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 90 | u64 ts = bpf_ktime_get_ns(); |
| 91 | start.update(&req, &ts); |
| 92 | return 0; |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | // output |
gurugio | c5a448a | 2019-01-04 17:54:39 +0100 | [diff] [blame] | 96 | int trace_req_done(struct pt_regs *ctx, struct request *req) |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 97 | { |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 98 | u64 *tsp, delta; |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 99 | |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 100 | // fetch timestamp and calculate delta |
| 101 | tsp = start.lookup(&req); |
| 102 | if (tsp == 0) { |
| 103 | return 0; // missed issue |
| 104 | } |
| 105 | delta = bpf_ktime_get_ns() - *tsp; |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 106 | |
| 107 | EXTENSION |
| 108 | |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 109 | FACTOR |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 110 | |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 111 | // store as histogram |
| 112 | STORE |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 113 | |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 114 | start.delete(&req); |
| 115 | return 0; |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 116 | } |
| 117 | """ |
Brendan Gregg | 44e6877 | 2015-09-25 13:20:16 -0700 | [diff] [blame] | 118 | |
| 119 | # code substitutions |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 120 | if args.milliseconds: |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 121 | bpf_text = bpf_text.replace('FACTOR', 'delta /= 1000000;') |
| 122 | label = "msecs" |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 123 | else: |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 124 | bpf_text = bpf_text.replace('FACTOR', 'delta /= 1000;') |
| 125 | label = "usecs" |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 126 | |
| 127 | storage_str = "" |
| 128 | store_str = "" |
Brendan Gregg | 44e6877 | 2015-09-25 13:20:16 -0700 | [diff] [blame] | 129 | if args.disks: |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 130 | storage_str += "BPF_HISTOGRAM(dist, disk_key_t);" |
Tejun Heo | ddfcc29 | 2022-03-10 08:37:21 -1000 | [diff] [blame] | 131 | disks_str = """ |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 132 | disk_key_t key = {.slot = bpf_log2l(delta)}; |
Tejun Heo | ddfcc29 | 2022-03-10 08:37:21 -1000 | [diff] [blame] | 133 | void *__tmp = (void *)req->__RQ_DISK__->disk_name; |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 134 | bpf_probe_read(&key.disk, sizeof(key.disk), __tmp); |
zcy | 80242fb | 2021-07-02 00:12:32 +0800 | [diff] [blame] | 135 | dist.atomic_increment(key); |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 136 | """ |
Tejun Heo | ddfcc29 | 2022-03-10 08:37:21 -1000 | [diff] [blame] | 137 | if BPF.kernel_struct_has_field(b'request', b'rq_disk'): |
| 138 | store_str += disks_str.replace('__RQ_DISK__', 'rq_disk') |
| 139 | else: |
| 140 | store_str += disks_str.replace('__RQ_DISK__', 'q->disk') |
Brendan Gregg | c6cded4 | 2019-03-20 09:32:20 -0700 | [diff] [blame] | 141 | elif args.flags: |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 142 | storage_str += "BPF_HISTOGRAM(dist, flag_key_t);" |
| 143 | store_str += """ |
| 144 | flag_key_t key = {.slot = bpf_log2l(delta)}; |
| 145 | key.flags = req->cmd_flags; |
zcy | 80242fb | 2021-07-02 00:12:32 +0800 | [diff] [blame] | 146 | dist.atomic_increment(key); |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 147 | """ |
Brendan Gregg | 44e6877 | 2015-09-25 13:20:16 -0700 | [diff] [blame] | 148 | else: |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 149 | storage_str += "BPF_HISTOGRAM(dist);" |
zcy | 80242fb | 2021-07-02 00:12:32 +0800 | [diff] [blame] | 150 | store_str += "dist.atomic_increment(bpf_log2l(delta));" |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 151 | |
| 152 | if args.extension: |
| 153 | storage_str += "BPF_ARRAY(extension, ext_val_t, 1);" |
| 154 | bpf_text = bpf_text.replace('EXTENSION', """ |
| 155 | u32 index = 0; |
| 156 | ext_val_t *ext_val = extension.lookup(&index); |
| 157 | if (ext_val) { |
| 158 | lock_xadd(&ext_val->total, delta); |
| 159 | lock_xadd(&ext_val->count, 1); |
| 160 | } |
| 161 | """) |
| 162 | else: |
| 163 | bpf_text = bpf_text.replace('EXTENSION', '') |
| 164 | bpf_text = bpf_text.replace("STORAGE", storage_str) |
| 165 | bpf_text = bpf_text.replace("STORE", store_str) |
| 166 | |
Nathan Scott | ca4ba55 | 2018-01-16 11:02:58 +1100 | [diff] [blame] | 167 | if debug or args.ebpf: |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 168 | print(bpf_text) |
Nathan Scott | ca4ba55 | 2018-01-16 11:02:58 +1100 | [diff] [blame] | 169 | if args.ebpf: |
| 170 | exit() |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 171 | |
| 172 | # load BPF program |
| 173 | b = BPF(text=bpf_text) |
| 174 | if args.queued: |
Hengqi Chen | 8c80b29 | 2021-12-11 17:36:17 +0800 | [diff] [blame] | 175 | if BPF.get_kprobe_functions(b'__blk_account_io_start'): |
| 176 | b.attach_kprobe(event="__blk_account_io_start", fn_name="trace_req_start") |
| 177 | else: |
| 178 | b.attach_kprobe(event="blk_account_io_start", fn_name="trace_req_start") |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 179 | else: |
Jerome Marchand | 74e25ed | 2018-12-10 08:54:50 +0100 | [diff] [blame] | 180 | if BPF.get_kprobe_functions(b'blk_start_request'): |
| 181 | b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start") |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 182 | b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start") |
Hengqi Chen | 8c80b29 | 2021-12-11 17:36:17 +0800 | [diff] [blame] | 183 | if BPF.get_kprobe_functions(b'__blk_account_io_done'): |
| 184 | b.attach_kprobe(event="__blk_account_io_done", fn_name="trace_req_done") |
| 185 | else: |
| 186 | b.attach_kprobe(event="blk_account_io_done", fn_name="trace_req_done") |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 187 | |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 188 | if not args.json: |
| 189 | print("Tracing block device I/O... Hit Ctrl-C to end.") |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 190 | |
xingfeng2510 | 3d07ee8 | 2022-03-10 09:38:16 +0800 | [diff] [blame] | 191 | def disk_print(s): |
| 192 | disk = s.decode('utf-8', 'replace') |
| 193 | if not disk: |
| 194 | disk = "<unknown>" |
| 195 | return disk |
| 196 | |
Brendan Gregg | c6cded4 | 2019-03-20 09:32:20 -0700 | [diff] [blame] | 197 | # see blk_fill_rwbs(): |
| 198 | req_opf = { |
| 199 | 0: "Read", |
| 200 | 1: "Write", |
| 201 | 2: "Flush", |
| 202 | 3: "Discard", |
| 203 | 5: "SecureErase", |
| 204 | 6: "ZoneReset", |
| 205 | 7: "WriteSame", |
| 206 | 9: "WriteZeros" |
| 207 | } |
| 208 | REQ_OP_BITS = 8 |
| 209 | REQ_OP_MASK = ((1 << REQ_OP_BITS) - 1) |
| 210 | REQ_SYNC = 1 << (REQ_OP_BITS + 3) |
| 211 | REQ_META = 1 << (REQ_OP_BITS + 4) |
| 212 | REQ_PRIO = 1 << (REQ_OP_BITS + 5) |
| 213 | REQ_NOMERGE = 1 << (REQ_OP_BITS + 6) |
| 214 | REQ_IDLE = 1 << (REQ_OP_BITS + 7) |
| 215 | REQ_FUA = 1 << (REQ_OP_BITS + 9) |
| 216 | REQ_RAHEAD = 1 << (REQ_OP_BITS + 11) |
| 217 | REQ_BACKGROUND = 1 << (REQ_OP_BITS + 12) |
| 218 | REQ_NOWAIT = 1 << (REQ_OP_BITS + 13) |
| 219 | def flags_print(flags): |
| 220 | desc = "" |
| 221 | # operation |
| 222 | if flags & REQ_OP_MASK in req_opf: |
| 223 | desc = req_opf[flags & REQ_OP_MASK] |
| 224 | else: |
| 225 | desc = "Unknown" |
| 226 | # flags |
| 227 | if flags & REQ_SYNC: |
| 228 | desc = "Sync-" + desc |
| 229 | if flags & REQ_META: |
| 230 | desc = "Metadata-" + desc |
| 231 | if flags & REQ_FUA: |
| 232 | desc = "ForcedUnitAccess-" + desc |
| 233 | if flags & REQ_PRIO: |
| 234 | desc = "Priority-" + desc |
| 235 | if flags & REQ_NOMERGE: |
| 236 | desc = "NoMerge-" + desc |
| 237 | if flags & REQ_IDLE: |
| 238 | desc = "Idle-" + desc |
| 239 | if flags & REQ_RAHEAD: |
| 240 | desc = "ReadAhead-" + desc |
| 241 | if flags & REQ_BACKGROUND: |
| 242 | desc = "Background-" + desc |
| 243 | if flags & REQ_NOWAIT: |
| 244 | desc = "NoWait-" + desc |
| 245 | return desc |
| 246 | |
Yonghong Song | 17e14ef | 2020-10-01 13:34:43 -0700 | [diff] [blame] | 247 | # output |
| 248 | exiting = 0 if args.interval else 1 |
| 249 | dist = b.get_table("dist") |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 250 | if args.extension: |
| 251 | extension = b.get_table("extension") |
Yonghong Song | 17e14ef | 2020-10-01 13:34:43 -0700 | [diff] [blame] | 252 | while (1): |
| 253 | try: |
| 254 | sleep(int(args.interval)) |
| 255 | except KeyboardInterrupt: |
| 256 | exiting = 1 |
| 257 | |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 258 | print() |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 259 | if args.json: |
| 260 | if args.timestamp: |
| 261 | print("%-8s\n" % strftime("%H:%M:%S"), end="") |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 262 | |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 263 | if args.flags: |
Omkar Desai | bb6e931 | 2021-01-04 15:16:39 -0500 | [diff] [blame] | 264 | dist.print_json_hist(label, "flags", flags_print) |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 265 | else: |
xingfeng2510 | 3d07ee8 | 2022-03-10 09:38:16 +0800 | [diff] [blame] | 266 | dist.print_json_hist(label, "disk", disk_print) |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 267 | |
Brendan Gregg | c6cded4 | 2019-03-20 09:32:20 -0700 | [diff] [blame] | 268 | else: |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 269 | if args.timestamp: |
| 270 | print("%-8s\n" % strftime("%H:%M:%S"), end="") |
zcy | 80242fb | 2021-07-02 00:12:32 +0800 | [diff] [blame] | 271 | |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 272 | if args.flags: |
| 273 | dist.print_log2_hist(label, "flags", flags_print) |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 274 | else: |
xingfeng2510 | 3d07ee8 | 2022-03-10 09:38:16 +0800 | [diff] [blame] | 275 | dist.print_log2_hist(label, "disk", disk_print) |
edwardwu | f41f378 | 2021-04-28 18:22:48 +0800 | [diff] [blame] | 276 | if args.extension: |
| 277 | total = extension[0].total |
| 278 | counts = extension[0].count |
| 279 | if counts > 0: |
| 280 | if label == 'msecs': |
| 281 | total /= 1000000 |
| 282 | elif label == 'usecs': |
| 283 | total /= 1000 |
| 284 | avg = total / counts |
| 285 | print("\navg = %ld %s, total: %ld %s, count: %ld\n" % |
| 286 | (total / counts, label, total, label, counts)) |
| 287 | extension.clear() |
Omkar Desai | aec53a8 | 2020-12-31 11:30:31 -0500 | [diff] [blame] | 288 | |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 289 | dist.clear() |
Brendan Gregg | 9fa1562 | 2015-09-21 15:51:11 -0700 | [diff] [blame] | 290 | |
Alexei Starovoitov | a79da0a | 2016-01-09 12:06:40 -0800 | [diff] [blame] | 291 | countdown -= 1 |
| 292 | if exiting or countdown == 0: |
Yonghong Song | 17e14ef | 2020-10-01 13:34:43 -0700 | [diff] [blame] | 293 | exit() |