From 4fba111ecabf5e8b40f9fc9dc1b89d7f0c7f87e6 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Wed, 22 Jul 2015 19:59:35 +0200 Subject: [PATCH] bpf.2: Improvements after comments from Alexei Starovoitov Reported-by: Alexei Starovoitov Signed-off-by: Michael Kerrisk --- man2/bpf.2 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/man2/bpf.2 b/man2/bpf.2 index 146247e4d..31b28d39a 100644 --- a/man2/bpf.2 +++ b/man2/bpf.2 @@ -852,8 +852,6 @@ ioctl(event_fd, PERF_EVENT_IOC_SET_BPF, prog_fd); .fi .in .\" -.\" FIXME -.\" .\" .SH EXAMPLES .\" FIXME It would be nice if this was a complete working example @@ -895,8 +893,8 @@ main(int argc, char **argv) /* if (r0 == 0) goto pc+2 */ BPF_MOV64_IMM(BPF_REG_1, 1), /* r1 = 1 */ BPF_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0), -.\" FIXME What does 'lock' in the line below mean? /* lock *(u64 *) r0 += r1 */ +.\" == atomic64_add BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */ BPF_EXIT_INSN(), /* return r0 */ }; @@ -1054,13 +1052,16 @@ and similar calls. An eBPF object is deallocated only after all file descriptors referring to the object have been closed. -eBPF programs can be written in a restricted C that is compiled into -eBPF bytecode and executed on the in-kernel virtual machine or +eBPF programs can be written in a restricted C that is compiled (using the +.B clang +compiler) into eBPF bytecode and executed on the in-kernel virtual machine or just-in-time compiled into native code. (Various features are omitted from this restricted C, such as loops, global variables, variadic functions, floating-point numbers, and passing structures as function arguments.) -.\" FIXME Add pointers to examples +Some examples can be found in the +.I samples/bpf/*_kern.c +files in the kernel source tree. .\" samples/bpf/*_kern.c + samples/bpf/Makefile ? .\" There are also examples for the tc classifier, in the iproute2 .\" project, in examples/bpf