Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
919d30a0
Commit
919d30a0
authored
Sep 25, 2015
by
Brenden Blanco
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #249 from brendangregg/master
use BPF_HISTOGRAM and num_open_kprobes
parents
6ee90d08
3736885c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
18 deletions
+22
-18
README.md
README.md
+1
-1
examples/bitehist.c
examples/bitehist.c
+2
-5
examples/bitehist.py
examples/bitehist.py
+2
-1
examples/vfsreadlat.c
examples/vfsreadlat.c
+2
-4
tools/funccount
tools/funccount
+6
-1
tools/funclatency
tools/funclatency
+9
-6
No files found.
README.md
View file @
919d30a0
...
...
@@ -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 |********** |
...
...
examples/bitehist.c
View file @
919d30a0
...
...
@@ -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
;
}
examples/bitehist.py
View file @
919d30a0
...
...
@@ -22,10 +22,11 @@ b = BPF(src_file = "bitehist.c")
# header
print
(
"Tracing... Hit Ctrl-C to end."
)
#
output
#
trace until Ctrl-C
try
:
sleep
(
99999999
)
except
KeyboardInterrupt
:
print
# output
b
[
"dist"
].
print_log2_hist
(
"kbytes"
)
examples/vfsreadlat.c
View file @
919d30a0
...
...
@@ -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
);
}
...
...
tools/funccount
View file @
919d30a0
...
...
@@ -81,9 +81,14 @@ if debug:
print
(
bpf_text
)
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_kprobe
(
event_re
=
pattern
,
fn_name
=
"trace_count"
)
matched
=
b
.
num_open_kprobes
()
if
matched
==
0
:
print
(
"0 functions matched by
\
"
%s
\
"
. Exiting."
%
args
.
pattern
)
exit
()
# header
print
(
"Tracing... Ctrl-C to end."
)
print
(
"Tracing %d functions for
\
"
%s
\
"
... Hit Ctrl-C to end."
%
(
matched
,
args
.
pattern
))
# output
exiting
=
0
if
args
.
interval
else
1
...
...
tools/funclatency
View file @
919d30a0
...
...
@@ -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)
{
...
...
@@ -86,14 +86,12 @@ int trace_func_return(struct pt_regs *ctx)
if (tsp == 0) {
return 0; // missed start
}
start.delete(&pid);
delta = bpf_ktime_get_ns() - *tsp;
start.delete(&pid);
FACTOR
// store as histogram
int index = bpf_log2l(delta);
u64 *leaf = dist.lookup(&index);
if (leaf) (*leaf)++;
dist.increment(bpf_log2l(delta));
return 0;
}
...
...
@@ -123,9 +121,14 @@ def signal_ignore(signal, frame):
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_kprobe
(
event_re
=
pattern
,
fn_name
=
"trace_func_entry"
)
b
.
attach_kretprobe
(
event_re
=
pattern
,
fn_name
=
"trace_func_return"
)
matched
=
b
.
num_open_kprobes
()
if
matched
==
0
:
print
(
"0 functions matched by
\
"
%s
\
"
. Exiting."
%
args
.
pattern
)
exit
()
# header
print
(
"Tracing %s... Hit Ctrl-C to end."
%
args
.
pattern
)
print
(
"Tracing %d functions for
\
"
%s
\
"
... Hit Ctrl-C to end."
%
(
matched
/
2
,
args
.
pattern
))
# output
exiting
=
0
if
args
.
interval
else
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment