linux/tools/lib
Wang Nan b580563e38 bpf tools: Load a program with different instances using preprocessor
This patch is a preparation for BPF prologue support which allows
generating a series of BPF bytecode for fetching kernel data before
calling program code. With the newly introduced multiple instances
support, perf is able to create different prologues for different kprobe
points.

Before this patch, a bpf_program can be loaded into kernel only once,
and get the only resulting fd. What this patch does is to allow creating
and loading different variants of one bpf_program, then fetching their
fds.

Here we describe the basic idea in this patch. The detailed description
of the newly introduced APIs can be found in comments in the patch body.

The key of this patch is the new mechanism in bpf_program__load().
Instead of loading BPF program into kernel directly, it calls a
'pre-processor' to generate program instances which would be finally
loaded into the kernel based on the original code. To enable the
generation of multiple instances, libbpf passes an index to the
pre-processor so it know which instance is being loaded.

Pre-processor should be called from libbpf's user (perf) using
bpf_program__set_prep(). The number of instances and the relationship
between indices and the target instance should be clear when calling
bpf_program__set_prep().

To retrieve a fd for a specific instance of a program,
bpf_program__nth_fd() is introduced. It returns the resulting fd
according to index.

Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1447675815-166222-8-git-send-email-wangnan0@huawei.com
Signed-off-by: Wang Nan <wangnan0@huawei.com>
[ Enclosed multi-line if/else blocks with {}, (*func_ptr)() -> func_ptr() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-18 17:51:03 -03:00
..
api tools lib api fs: No need to use PATH_MAX + 1 2015-10-05 16:12:09 -03:00
bpf bpf tools: Load a program with different instances using preprocessor 2015-11-18 17:51:03 -03:00
lockdep tools build: Build fixdep helper from perf and basic libs 2015-09-28 15:50:55 -03:00
symbol tools lib symbol: Introduce kallsyms2elf_type 2015-09-30 18:34:31 -03:00
traceevent tools lib traceevent: Support %ps/%pS 2015-10-22 15:39:42 -03:00
util tools lib: Move asm-generic/bitops/find.h code to tools/include and tools/lib 2014-12-17 11:14:48 -03:00
hweight.c tools: Copy lib/hweight.c from the kernel sources 2015-07-09 16:29:56 -03:00
rbtree.c tools: Copy lib/rbtree.c to tools/lib/ 2015-07-05 22:48:21 -03:00
string.c tools: Clone the kernel's strtobool function 2015-11-18 17:51:02 -03:00