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
4cbdef74
Commit
4cbdef74
authored
Aug 29, 2015
by
Brendan Gregg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use new event_re option to improve vfscount
parent
ab4ca4cb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
25 deletions
+35
-25
man/man8/vfscount.8
man/man8/vfscount.8
+9
-7
tools/vfscount
tools/vfscount
+10
-11
tools/vfscount_example.txt
tools/vfscount_example.txt
+16
-7
No files found.
man/man8/vfscount.8
View file @
4cbdef74
.TH vfscount 8 "2015-08-18" "USER COMMANDS"
.TH vfscount 8 "2015-08-18" "USER COMMANDS"
.SH NAME
.SH NAME
vfscount \- Count
some common VFS calls
. Uses Linux eBPF/bcc.
vfscount \- Count
VFS calls ("vfs_*")
. Uses Linux eBPF/bcc.
.SH SYNOPSIS
.SH SYNOPSIS
.B vfscount
.B vfscount
.SH DESCRIPTION
.SH DESCRIPTION
This counts
common
VFS calls. This can be useful for general workload
This counts VFS calls. This can be useful for general workload
characterization of these operations.
characterization of these operations.
This works by tracing
some kernel vfs functions using dynamic tracing, and will
This works by tracing
all kernel functions beginning with "vfs_" using dynamic
need updating to match any changes to these functions. Edit the script to
tracing. This may match more functions than you are interested in measuring:
customize and add functions to trace, which is easy to do
.
Edit the script to customize which functions to trace
.
Since this uses BPF, only the root user can use this tool.
Since this uses BPF, only the root user can use this tool.
.SH REQUIREMENTS
.SH REQUIREMENTS
...
@@ -30,11 +30,13 @@ Kernel function name
...
@@ -30,11 +30,13 @@ Kernel function name
COUNT
COUNT
Number of calls while tracing
Number of calls while tracing
.SH OVERHEAD
.SH OVERHEAD
This traces
various
kernel vfs functions and maintains in-kernel counts, which
This traces kernel vfs functions and maintains in-kernel counts, which
are asynchronously copied to user-space. While the rate of VFS operations can
are asynchronously copied to user-space. While the rate of VFS operations can
be very high (>1M/sec), this is a relatively efficient way to trace these
be very high (>1M/sec), this is a relatively efficient way to trace these
events, and so the overhead is expected to be small for normal workloads.
events, and so the overhead is expected to be small for normal workloads.
Measure in a test environment.
Measure in a test environment, and if overheads are an issue, edit the script
to reduce the types of vfs functions traced (currently all beginning with
"vfs_").
.SH SOURCE
.SH SOURCE
This is from bcc.
This is from bcc.
.IP
.IP
...
...
tools/vfscount
View file @
4cbdef74
#!/usr/bin/python
#!/usr/bin/python
#
#
# vfscount Count
some VFS calls
.
# vfscount Count
VFS calls ("vfs_*")
.
# For Linux, uses BCC, eBPF. See .c file.
# For Linux, uses BCC, eBPF. See .c file.
#
#
# Written as a basic example of counting functions.
# Written as a basic example of counting functions.
...
@@ -36,7 +36,7 @@ def load_kallsyms():
...
@@ -36,7 +36,7 @@ def load_kallsyms():
ksym_addrs
.
append
(
addr
)
ksym_addrs
.
append
(
addr
)
ksym_names
.
append
(
name
)
ksym_names
.
append
(
name
)
syms
.
close
()
syms
.
close
()
def
ksym
(
addr
):
def
_ksym_addr2index
(
addr
):
start
=
-
1
start
=
-
1
end
=
len
(
ksym_addrs
)
end
=
len
(
ksym_addrs
)
while
end
!=
start
+
1
:
while
end
!=
start
+
1
:
...
@@ -45,18 +45,17 @@ def ksym(addr):
...
@@ -45,18 +45,17 @@ def ksym(addr):
end
=
mid
end
=
mid
else
:
else
:
start
=
mid
start
=
mid
if
start
==
-
1
:
return
start
def
ksym
(
addr
):
idx
=
_ksym_addr2index
(
addr
)
if
idx
==
-
1
:
return
"[unknown]"
return
"[unknown]"
return
ksym_names
[
start
]
return
ksym_names
[
idx
]
load_kallsyms
()
load_kallsyms
()
# load BPF program
# load BPF program
b
=
BPF
(
src_file
=
"vfscount.c"
)
b
=
BPF
(
src_file
=
"vfscount.c"
)
b
.
attach_kprobe
(
event
=
"vfs_read"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event_re
=
"^vfs_.*"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_write"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_fsync"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_open"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_create"
,
fn_name
=
"do_count"
)
# header
# header
print
(
"Tracing... Ctrl-C to end."
)
print
(
"Tracing... Ctrl-C to end."
)
...
@@ -67,7 +66,7 @@ try:
...
@@ -67,7 +66,7 @@ try:
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
pass
pass
print
(
"
\
n
%-16s %-
12
s %8s"
%
(
"ADDR"
,
"FUNC"
,
"COUNT"
))
print
(
"
\
n
%-16s %-
26
s %8s"
%
(
"ADDR"
,
"FUNC"
,
"COUNT"
))
counts
=
b
.
get_table
(
"counts"
)
counts
=
b
.
get_table
(
"counts"
)
for
k
,
v
in
sorted
(
counts
.
items
(),
key
=
lambda
counts
:
counts
[
1
].
value
):
for
k
,
v
in
sorted
(
counts
.
items
(),
key
=
lambda
counts
:
counts
[
1
].
value
):
print
(
"%-16x %-
12
s %8d"
%
(
k
.
ip
,
ksym
(
k
.
ip
),
v
.
value
))
print
(
"%-16x %-
26
s %8d"
%
(
k
.
ip
,
ksym
(
k
.
ip
),
v
.
value
))
tools/vfscount_example.txt
View file @
4cbdef74
Demonstrations of vfscount, the Linux eBPF/bcc version.
Demonstrations of vfscount, the Linux eBPF/bcc version.
This counts VFS calls, by tracing various kernel calls beginning with "vfs_"
This counts VFS calls, by tracing all kernel functions beginning with "vfs_":
(edit the script to customize):
# ./vfscount
# ./vfscount
Tracing... Ctrl-C to end.
Tracing... Ctrl-C to end.
^C
^C
ADDR FUNC COUNT
ADDR FUNC COUNT
ffffffff811f2cc1 vfs_create 24
ffffffff811f3c01 vfs_create 1
ffffffff811e71c1 vfs_write 203
ffffffff8120be71 vfs_getxattr 2
ffffffff811e6061 vfs_open 765
ffffffff811f5f61 vfs_unlink 2
ffffffff811e7091 vfs_read 1852
ffffffff81236ca1 vfs_lock_file 6
ffffffff81218fb1 vfs_fsync_range 6
ffffffff811ecaf1 vfs_fstat 319
ffffffff811e6f01 vfs_open 475
ffffffff811ecb51 vfs_fstatat 488
ffffffff811ecac1 vfs_getattr 704
ffffffff811ec9f1 vfs_getattr_nosec 704
ffffffff811e80a1 vfs_write 1764
ffffffff811e7f71 vfs_read 2283
This can be useful for workload characterization, to see what types of
This can be useful for workload characterization, to see what types of
operations are in use.
operations are in use.
You can edit the script to customize what kernel functions are matched.
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