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
30abd81b
Commit
30abd81b
authored
Sep 21, 2015
by
Brendan Gregg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use bpf_log2l helper
parent
8f63810f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
48 deletions
+2
-48
examples/bitehist.c
examples/bitehist.c
+1
-24
examples/vfsreadlat.c
examples/vfsreadlat.c
+1
-24
No files found.
examples/bitehist.c
View file @
30abd81b
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
* bitehist.c Block I/O size histogram.
* bitehist.c Block I/O size histogram.
* For Linux, uses BCC, eBPF. See .py file.
* For Linux, uses BCC, eBPF. See .py file.
*
*
* Based on eBPF sample tracex2 by Alexi Starovoitov.
* Copyright (c) 2013-2015 PLUMgrid, http://plumgrid.com
* Copyright (c) 2013-2015 PLUMgrid, http://plumgrid.com
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* modify it under the terms of version 2 of the GNU General Public
...
@@ -16,31 +15,9 @@
...
@@ -16,31 +15,9 @@
BPF_TABLE
(
"array"
,
int
,
u64
,
dist
,
64
);
BPF_TABLE
(
"array"
,
int
,
u64
,
dist
,
64
);
static
unsigned
int
log2
(
unsigned
int
v
)
{
unsigned
int
r
;
unsigned
int
shift
;
r
=
(
v
>
0xFFFF
)
<<
4
;
v
>>=
r
;
shift
=
(
v
>
0xFF
)
<<
3
;
v
>>=
shift
;
r
|=
shift
;
shift
=
(
v
>
0xF
)
<<
2
;
v
>>=
shift
;
r
|=
shift
;
shift
=
(
v
>
0x3
)
<<
1
;
v
>>=
shift
;
r
|=
shift
;
r
|=
(
v
>>
1
);
return
r
;
}
static
unsigned
int
log2l
(
unsigned
long
v
)
{
unsigned
int
hi
=
v
>>
32
;
if
(
hi
)
return
log2
(
hi
)
+
32
+
1
;
else
return
log2
(
v
)
+
1
;
}
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
=
log2l
(
req
->
__data_len
/
1024
);
int
index
=
bpf_
log2l
(
req
->
__data_len
/
1024
);
u64
*
leaf
=
dist
.
lookup
(
&
index
);
u64
*
leaf
=
dist
.
lookup
(
&
index
);
if
(
leaf
)
(
*
leaf
)
++
;
if
(
leaf
)
(
*
leaf
)
++
;
...
...
examples/vfsreadlat.c
View file @
30abd81b
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
* vfsreadlat.c VFS read latency distribution.
* vfsreadlat.c VFS read latency distribution.
* For Linux, uses BCC, eBPF. See .py file.
* For Linux, uses BCC, eBPF. See .py file.
*
*
* Based on eBPF sample tracex2 by Alexi Starovoitov.
* Copyright (c) 2013-2015 PLUMgrid, http://plumgrid.com
* Copyright (c) 2013-2015 PLUMgrid, http://plumgrid.com
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* modify it under the terms of version 2 of the GNU General Public
...
@@ -16,28 +15,6 @@
...
@@ -16,28 +15,6 @@
BPF_HASH
(
start
,
u32
);
BPF_HASH
(
start
,
u32
);
BPF_TABLE
(
"array"
,
int
,
u64
,
dist
,
64
);
BPF_TABLE
(
"array"
,
int
,
u64
,
dist
,
64
);
static
unsigned
int
log2
(
unsigned
int
v
)
{
unsigned
int
r
;
unsigned
int
shift
;
r
=
(
v
>
0xFFFF
)
<<
4
;
v
>>=
r
;
shift
=
(
v
>
0xFF
)
<<
3
;
v
>>=
shift
;
r
|=
shift
;
shift
=
(
v
>
0xF
)
<<
2
;
v
>>=
shift
;
r
|=
shift
;
shift
=
(
v
>
0x3
)
<<
1
;
v
>>=
shift
;
r
|=
shift
;
r
|=
(
v
>>
1
);
return
r
;
}
static
unsigned
int
log2l
(
unsigned
long
v
)
{
unsigned
int
hi
=
v
>>
32
;
if
(
hi
)
return
log2
(
hi
)
+
32
+
1
;
else
return
log2
(
v
)
+
1
;
}
int
do_entry
(
struct
pt_regs
*
ctx
)
int
do_entry
(
struct
pt_regs
*
ctx
)
{
{
u32
pid
;
u32
pid
;
...
@@ -59,7 +36,7 @@ int do_return(struct pt_regs *ctx)
...
@@ -59,7 +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
=
log2l
(
delta
/
1000
);
int
index
=
bpf_
log2l
(
delta
/
1000
);
u64
*
leaf
=
dist
.
lookup
(
&
index
);
u64
*
leaf
=
dist
.
lookup
(
&
index
);
if
(
leaf
)
(
*
leaf
)
++
;
if
(
leaf
)
(
*
leaf
)
++
;
start
.
delete
(
&
pid
);
start
.
delete
(
&
pid
);
...
...
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