Commit 0031285f authored by Brenden Blanco's avatar Brenden Blanco

Some more minor updates to INSTALL and README

Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent 0d45b804
...@@ -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 bcc binary 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
......
...@@ -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.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment