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. ...@@ -24,7 +24,7 @@ summary is returned to user-level.
# ./bitehist.py # ./bitehist.py
Tracing... Hit Ctrl-C to end. Tracing... Hit Ctrl-C to end.
^C ^C
value : count distribution kbytes : count distribution
0 -> 1 : 3 | | 0 -> 1 : 3 | |
2 -> 3 : 0 | | 2 -> 3 : 0 | |
4 -> 7 : 211 |********** | 4 -> 7 : 211 |********** |
......
...@@ -13,13 +13,10 @@ ...@@ -13,13 +13,10 @@
#include <uapi/linux/ptrace.h> #include <uapi/linux/ptrace.h>
#include <linux/blkdev.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 kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
{ {
int index = bpf_log2l(req->__data_len / 1024); dist.increment(bpf_log2l(req->__data_len / 1024));
u64 *leaf = dist.lookup(&index);
if (leaf) (*leaf)++;
return 0; return 0;
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <uapi/linux/ptrace.h> #include <uapi/linux/ptrace.h>
BPF_HASH(start, u32); BPF_HASH(start, u32);
BPF_TABLE("array", int, u64, dist, 64); BPF_HISTOGRAM(dist);
int do_entry(struct pt_regs *ctx) int do_entry(struct pt_regs *ctx)
{ {
...@@ -36,9 +36,7 @@ int do_return(struct pt_regs *ctx) ...@@ -36,9 +36,7 @@ int do_return(struct pt_regs *ctx)
if (tsp != 0) { if (tsp != 0) {
delta = bpf_ktime_get_ns() - *tsp; delta = bpf_ktime_get_ns() - *tsp;
int index = bpf_log2l(delta / 1000); dist.increment(bpf_log2l(delta / 1000));
u64 *leaf = dist.lookup(&index);
if (leaf) (*leaf)++;
start.delete(&pid); start.delete(&pid);
} }
......
...@@ -62,8 +62,8 @@ bpf_text = """ ...@@ -62,8 +62,8 @@ bpf_text = """
#include <uapi/linux/ptrace.h> #include <uapi/linux/ptrace.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
BPF_TABLE(\"array\", int, u64, dist, 64);
BPF_HASH(start, u32); BPF_HASH(start, u32);
BPF_HISTOGRAM(dist);
int trace_func_entry(struct pt_regs *ctx) int trace_func_entry(struct pt_regs *ctx)
{ {
...@@ -91,9 +91,7 @@ int trace_func_return(struct pt_regs *ctx) ...@@ -91,9 +91,7 @@ int trace_func_return(struct pt_regs *ctx)
FACTOR FACTOR
// store as histogram // store as histogram
int index = bpf_log2l(delta); dist.increment(bpf_log2l(delta));
u64 *leaf = dist.lookup(&index);
if (leaf) (*leaf)++;
return 0; 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