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
0031285f
Commit
0031285f
authored
Sep 04, 2015
by
Brenden Blanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some more minor updates to INSTALL and README
Signed-off-by:
Brenden Blanco
<
bblanco@plumgrid.com
>
parent
0d45b804
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
25 deletions
+14
-25
INSTALL.md
INSTALL.md
+3
-2
README.md
README.md
+11
-23
No files found.
INSTALL.md
View file @
0031285f
...
@@ -14,7 +14,7 @@ sudo dpkg -i linux-*${VER}.${REL}*.deb
...
@@ -14,7 +14,7 @@ sudo dpkg -i linux-*${VER}.${REL}*.deb
# reboot
# reboot
```
```
Tagged binary packages are built for Ubuntu Trusty (14.04) and hosted at
Tagged b
cc b
inary packages are built for Ubuntu Trusty (14.04) and hosted at
http://52.8.15.63/apt/.
http://52.8.15.63/apt/.
To install:
To install:
...
@@ -47,7 +47,8 @@ sudo dnf install -y kernel-core-4.2.0-1.fc24.x86_64 kernel-4.2.0-1.fc24.x86_64 k
...
@@ -47,7 +47,8 @@ sudo dnf install -y kernel-core-4.2.0-1.fc24.x86_64 kernel-4.2.0-1.fc24.x86_64 k
# reboot
# reboot
```
```
Tagged binary packages are built for Fedora 22 and hosted at http://52.8.15.63/yum/.
Tagged bcc binary packages are built for Fedora 22 and hosted at
http://52.8.15.63/yum/.
To install:
To install:
```
bash
```
bash
...
...
README.md
View file @
0031285f
...
@@ -94,6 +94,9 @@ bcc/examples$ sudo python hello_world.py
...
@@ -94,6 +94,9 @@ bcc/examples$ sudo python hello_world.py
python-7282 [002] d... 3757.488508: : Hello, World!
python-7282 [002] d... 3757.488508: : Hello, World!
```
```
For an explanation of the meaning of the printed fields, see the trace_pipe
section of the
[
kernel ftrace doc
](
https://www.kernel.org/doc/Documentation/trace/ftrace.txt
)
.
[
Source code listing
](
examples/hello_world.py
)
[
Source code listing
](
examples/hello_world.py
)
### Networking
### Networking
...
@@ -134,6 +137,9 @@ struct key_t {
...
@@ -134,6 +137,9 @@ struct key_t {
};
};
// map_type, key_type, leaf_type, table_name, num_entry
// map_type, key_type, leaf_type, table_name, num_entry
BPF_TABLE
(
"hash"
,
struct
key_t
,
u64
,
stats
,
1024
);
BPF_TABLE
(
"hash"
,
struct
key_t
,
u64
,
stats
,
1024
);
// attach to finish_task_switch in kernel/sched/core.c, which has the following
// prototype:
// struct rq *finish_task_switch(struct task_struct *prev)
int
count_sched
(
struct
pt_regs
*
ctx
,
struct
task_struct
*
prev
)
{
int
count_sched
(
struct
pt_regs
*
ctx
,
struct
task_struct
*
prev
)
{
struct
key_t
key
=
{};
struct
key_t
key
=
{};
u64
zero
=
0
,
*
val
;
u64
zero
=
0
,
*
val
;
...
@@ -149,10 +155,11 @@ int count_sched(struct pt_regs *ctx, struct task_struct *prev) {
...
@@ -149,10 +155,11 @@ int count_sched(struct pt_regs *ctx, struct task_struct *prev) {
[
Source code listing
](
examples/task_switch.c
)
[
Source code listing
](
examples/task_switch.c
)
The userspace component loads the file shown above, and attaches it to the
The userspace component loads the file shown above, and attaches it to the
`finish_task_switch`
kernel function (which takes one
`struct task_struct *`
`finish_task_switch`
kernel function.
argument). The
`get_table`
API returns an object that gives dict-style access
The [] operator of the BPF object gives access to each BPF_TABLE in the
to the stats BPF map. The python program could use that handle to modify the
program, allowing pass-through access to the values residing in the kernel. Use
kernel table as well.
the object as you would any other python dict object: read, update, and deletes
are all allowed.
```
python
```
python
from
bcc
import
BPF
from
bcc
import
BPF
from
time
import
sleep
from
time
import
sleep
...
@@ -168,25 +175,6 @@ for k, v in b["stats"].items():
...
@@ -168,25 +175,6 @@ for k, v in b["stats"].items():
```
```
[
Source code listing
](
examples/task_switch.py
)
[
Source code listing
](
examples/task_switch.py
)
## Requirements
To get started using this toolchain in binary format, one needs:
*
Linux kernel 4.1 or newer, with these flags enabled:
*
`CONFIG_BPF=y`
*
`CONFIG_BPF_SYSCALL=y`
*
`CONFIG_NET_CLS_BPF=m`
[optional, for tc filters]
*
`CONFIG_NET_ACT_BPF=m`
[optional, for tc actions]
*
`CONFIG_BPF_JIT=y`
*
`CONFIG_HAVE_BPF_JIT=y`
*
`CONFIG_BPF_EVENTS=y`
[optional, for kprobes]
*
Headers for the above kernel
*
gcc, make, python
*
python-pyroute2 (for some networking features only)
## Getting started
## Getting started
As of this writing, binary packages for the above requirements are available
in unstable formats. Both Ubuntu and Fedora have 4.2-rcX builds with the above
flags defaulted to on. LLVM provides 3.7 Ubuntu packages (but not Fedora yet).
See
[
INSTALL.md
](
INSTALL.md
)
for installation steps on your platform.
See
[
INSTALL.md
](
INSTALL.md
)
for installation steps on your platform.
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