Commit 8d70a881 authored by Brendan Gregg's avatar Brendan Gregg

use BPF_HISTOGRAM

parent 6ee90d08
......@@ -24,7 +24,7 @@ summary is returned to user-level.
# ./bitehist.py
Tracing... Hit Ctrl-C to end.
^C
value : count distribution
kbytes : count distribution
0 -> 1 : 3 | |
2 -> 3 : 0 | |
4 -> 7 : 211 |********** |
......
......@@ -13,13 +13,10 @@
#include <uapi/linux/ptrace.h>
#include <linux/blkdev.h>
BPF_TABLE("array", int, u64, dist, 64);
BPF_HISTOGRAM(dist);
int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
{
int index = bpf_log2l(req->__data_len / 1024);
u64 *leaf = dist.lookup(&index);
if (leaf) (*leaf)++;
dist.increment(bpf_log2l(req->__data_len / 1024));
return 0;
}
......@@ -13,7 +13,7 @@
#include <uapi/linux/ptrace.h>
BPF_HASH(start, u32);
BPF_TABLE("array", int, u64, dist, 64);
BPF_HISTOGRAM(dist);
int do_entry(struct pt_regs *ctx)
{
......@@ -36,9 +36,7 @@ int do_return(struct pt_regs *ctx)
if (tsp != 0) {
delta = bpf_ktime_get_ns() - *tsp;
int index = bpf_log2l(delta / 1000);
u64 *leaf = dist.lookup(&index);
if (leaf) (*leaf)++;
dist.increment(bpf_log2l(delta / 1000));
start.delete(&pid);
}
......
......@@ -62,8 +62,8 @@ bpf_text = """
#include <uapi/linux/ptrace.h>
#include <linux/blkdev.h>
BPF_TABLE(\"array\", int, u64, dist, 64);
BPF_HASH(start, u32);
BPF_HISTOGRAM(dist);
int trace_func_entry(struct pt_regs *ctx)
{
......@@ -91,9 +91,7 @@ int trace_func_return(struct pt_regs *ctx)
FACTOR
// store as histogram
int index = bpf_log2l(delta);
u64 *leaf = dist.lookup(&index);
if (leaf) (*leaf)++;
dist.increment(bpf_log2l(delta));
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment