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
6959dcf9
Commit
6959dcf9
authored
Feb 06, 2016
by
mcaleavya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bitesize tool
parent
4eb4137e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
219 additions
and
0 deletions
+219
-0
man/man8/bitesize.8
man/man8/bitesize.8
+52
-0
tools/bitesize.py
tools/bitesize.py
+75
-0
tools/bitesize_example.txt
tools/bitesize_example.txt
+92
-0
No files found.
man/man8/bitesize.8
0 → 100644
View file @
6959dcf9
.TH bitesize 8 "2016-02-05" "USER COMMANDS"
.SH NAME
bitesize \- Summarize block device I/O size as a histogram \- Linux eBPF/bcc.
.SH SYNOPSIS
.B bitesize
.SH DESCRIPTION
Show I/O distribution for requested block sizes, by process name.
This works by tracing block I/O kernel functions using dynamic
tracing and prints a historgram of I/O size.
Since this uses BPF, only the root user can use this tool.
.SH REQUIREMENTS
CONFIG_BPF and bcc.
.SH EXAMPLES
.TP
Count I/O size per process until Ctrl-C is hit:
#
.B bitesize
.SH FIELDS
.TP
Kbtes
Size in kilobytes of range
.TP
count
How many I/O fell into this range
.TP
distribution
An ASCII bar chart to visualize the distribution (count column)
.SH OVERHEAD
This traces kernel block I/O functions to update a histgroam, which are
asynchronously copied to user-space. This method is very efficient, and
the overhead for most storage I/O rates (< 10k IOPS) should be negligible.
If you have a higher IOPS storage environment, test and quantify the overhead
before use.
.SH SOURCE
This is from bcc.
.IP
https://github.com/iovisor/bcc
.PP
Also look in the bcc distribution for a companion _examples.txt file containing
example usage, output, and commentary for this tool.
.SH OS
Linux
.SH STABILITY
Unstable - in development.
.SH AUTHOR
Allan McAleavy
.SH SEE ALSO
https://github.com/brendangregg/systemtap-lwtools/blob/master/disk/bitesize-nd.stp
tools/bitesize.py
0 → 100644
View file @
6959dcf9
#!/usr/bin/python
#
# bitehist.py Block I/O size histogram.
# For Linux, uses BCC, eBPF. See .c file.
#
# USAGE: bitesize
# Ctrl-C will print the partially gathered histogram then exit.
#
#
# Copyright (c) 2016 Allan McAleavy
# Licensed under the Apache License, Version 2.0 (the "License")
#
# 05-Feb-2016 Allan McAleavy ran pep8 against file
from
bcc
import
BPF
from
time
import
sleep
bpf_text
=
"""
#include <uapi/linux/ptrace.h>
#include <linux/blkdev.h>
struct proc_key_t {
char name[TASK_COMM_LEN];
u64 slot;
};
struct val_t {
char name[TASK_COMM_LEN];
};
BPF_HISTOGRAM(dist, struct proc_key_t);
BPF_HASH(commbyreq, struct request *, struct val_t);
int trace_pid_start(struct pt_regs *ctx, struct request *req)
{
struct val_t val = {};
if (bpf_get_current_comm(&val.name, sizeof(val.name)) == 0) {
commbyreq.update(&req, &val);
}
return 0;
}
int do_count (struct pt_regs *ctx, struct request *req)
{
struct val_t *valp;
valp = commbyreq.lookup(&req);
if ( valp == 0) {
return 0;
}
if (req->__data_len > 0) {
struct proc_key_t key = {.slot = bpf_log2l(req->__data_len / 1024)};
bpf_probe_read(&key.name, sizeof(key.name),valp->name);
dist.increment(key);
}
return 0;
}
"""
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_kprobe
(
event
=
"blk_account_io_start"
,
fn_name
=
"trace_pid_start"
)
b
.
attach_kprobe
(
event
=
"blk_account_io_completion"
,
fn_name
=
"do_count"
)
print
(
"Tracing... Hit Ctrl-C to end."
)
# trace until Ctrl-C
dist
=
b
.
get_table
(
"dist"
)
try
:
sleep
(
99999999
)
except
KeyboardInterrupt
:
dist
.
print_log2_hist
(
"Kbytes"
,
"Process Name:"
)
tools/bitesize_example.txt
0 → 100644
View file @
6959dcf9
Example of BCC tool bitesize.py
The aim of this tool is to show I/O distribution for requested block sizes, by process name.
# ./bitesize.py
Tracing... Hit Ctrl-C to end.
^C
Process Name: = 'kworker/u128:1'
Kbytes : count distribution
0 -> 1 : 1 |******************** |
2 -> 3 : 0 | |
4 -> 7 : 2 |****************************************|
Process Name: = 'bitesize.py'
Kbytes : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 0 | |
8 -> 15 : 0 | |
16 -> 31 : 0 | |
32 -> 63 : 0 | |
64 -> 127 : 0 | |
128 -> 255 : 1 |****************************************|
Process Name: = 'dd'
Kbytes : count distribution
0 -> 1 : 3 | |
2 -> 3 : 0 | |
4 -> 7 : 6 | |
8 -> 15 : 0 | |
16 -> 31 : 1 | |
32 -> 63 : 1 | |
64 -> 127 : 0 | |
128 -> 255 : 0 | |
256 -> 511 : 1 | |
512 -> 1023 : 0 | |
1024 -> 2047 : 488 |****************************************|
Process Name: = 'jbd2/dm-1-8'
Kbytes : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 1 |****************************************|
Process Name: = 'cat'
Kbytes : count distribution
0 -> 1 : 1 | |
2 -> 3 : 0 | |
4 -> 7 : 0 | |
8 -> 15 : 0 | |
16 -> 31 : 0 | |
32 -> 63 : 1 | |
64 -> 127 : 0 | |
128 -> 255 : 0 | |
256 -> 511 : 1924 |****************************************|
Process Name: = 'ntpd'
Kbytes : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 104 |****************************************|
Process Name: = 'vmtoolsd'
Kbytes : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 1 |****************************************|
Process Name: = 'bash'
Kbytes : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 0 | |
8 -> 15 : 0 | |
16 -> 31 : 2 |****************************************|
Process Name: = 'jbd2/sdb-8'
Kbytes : count distribution
0 -> 1 : 0 | |
2 -> 3 : 0 | |
4 -> 7 : 1 |****************************************|
8 -> 15 : 0 | |
16 -> 31 : 0 | |
32 -> 63 : 1 |****************************************|
We can see from above that there was a dd command being run which generated 488 IOPS between 1MB and 2MB, we can also see the
cat command generating 1924 IOPS between 256Kb and 512Kb.
See also systemtap version:
https://github.com/brendangregg/systemtap-lwtools/blob/master/disk/bitesize-nd.stp
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