Skip to content

Commit

Permalink
tools/biolatency: Simplify extension summary redundant logic (iovisor…
Browse files Browse the repository at this point in the history
…#4145)

Extension summary logic seems a bit redundant, try to simplify it (total already be calculated by FACTOR replacement).
  • Loading branch information
xingfeng2510 committed Aug 4, 2022
1 parent f6c4b4c commit 0e29f70
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions tools/biolatency.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@
}
delta = bpf_ktime_get_ns() - *tsp;
EXTENSION
FACTOR
// store as histogram
Expand Down Expand Up @@ -185,16 +183,15 @@

if args.extension:
storage_str += "BPF_ARRAY(extension, ext_val_t, 1);"
bpf_text = bpf_text.replace('EXTENSION', """
store_str += """
u32 index = 0;
ext_val_t *ext_val = extension.lookup(&index);
if (ext_val) {
lock_xadd(&ext_val->total, delta);
lock_xadd(&ext_val->count, 1);
}
""")
else:
bpf_text = bpf_text.replace('EXTENSION', '')
"""

bpf_text = bpf_text.replace("STORAGE", storage_str)
bpf_text = bpf_text.replace("STORE", store_str)

Expand Down Expand Up @@ -309,15 +306,10 @@ def flags_print(flags):
dist.print_log2_hist(label, "disk", disk_print)
if args.extension:
total = extension[0].total
counts = extension[0].count
if counts > 0:
if label == 'msecs':
total /= 1000000
elif label == 'usecs':
total /= 1000
avg = total / counts
count = extension[0].count
if count > 0:
print("\navg = %ld %s, total: %ld %s, count: %ld\n" %
(total / counts, label, total, label, counts))
(total / count, label, total, label, count))
extension.clear()

dist.clear()
Expand Down

0 comments on commit 0e29f70

Please sign in to comment.