bcc icon indicating copy to clipboard operation
bcc copied to clipboard

Make clear the minimal kernel compile config for each ebpf functionalities

Open rainkin1993 opened this issue 4 years ago • 4 comments

Hi,

I usually see the question

everything is right (including kernel version, ebpf program, etc), but my ebpf programs still cannot work

Such kind of issues mostly caused by the kernel compile configurations.

However, bpf (at least now) does not provide a useful error message (yes, that's you load bpf program failed: Invalid argument) to indicate which kernel configuation is not enabled. Thus I try to make it clear and give a clear list of the minimal requirements of basic eBPF functionalities. Please correct me if I am wrong.

Index Functionalities Kernel Configuration Describtion
1 Basic CONFIG_BPF_SYSCALL Enable the bpf() system call
2 CONFIG_BPF_JIT BPF JIT support
3 CONFIG_HAVE_BPF_JIT the dependency of CONFIG_BPF_JIT
4 CONFIG_HAVE_EBPF_JIT the dependency of CONFIG_BPF_JIT
5 CONFIG_HAVE_CBPF_JIT the dependency of CONFIG_BPF_JIT
6 CONFIG_MODULES the dependency of CONFIG_BPF_JIT and CONFIG_KPROBES
7 CONFIG_BPF Enable BPF VM
8 CONFIG_BPF_EVENTS This allows the user to attach BPF programs to kprobe, uprobe, and tracepoint events.
9 CONFIG_PERF_EVENTS the dependency of CONFIG_BPF_EVENTS and CONFIG_UPROBE_EVENTS
10 CONFIG_HAVE_PERF_EVENTS the dependency of CONFIG_PERF_EVENTS
11 CONFIG_PROFILING the dependency of CONFIG_PERF_EVENTS
12 CGroup CONFIG_CGROUP_BPF Allow attaching eBPF programs to a cgroup
13 Kprobes CONFIG_KPROBE_EVENTS Allow attaching to kprobes
14 CONFIG_KPROBES the dependency of CONFIG_KPROBE_EVENTS
15 CONFIG_HAVE_KPROBES the dependency of CONFIG_KPROBES
16 CONFIG_HAVE_REGS_AND_STACK_ACCESS_API the dependency of CONFIG_KPROBE_EVENTS
17 Uprobes CONFIG_UPROBE_EVENTS Allow attaching to uprobes
18 CONFIG_ARCH_SUPPORTS_UPROBES the dependency of CONFIG_UPROBE_EVENTS
19 CONFIG_UPROBES the dependency of CONFIG_UPROBE_EVENTS
20 CONFIG_MMU the dependency of CONFIG_UPROBE_EVENTS
21 Tracepoints CONFIG_TRACEPOINTS realted to Tracepoints
22 CONFIG_HAVE_SYSCALL_TRACEPOINTS realted to Tracepoints
23 Raw Tracepoints Same as Tracepoints

rainkin1993 avatar Jun 11 '21 03:06 rainkin1993

This is a good idea. I think such information deserves a file like kernel_config.md under bcc/docs directory. Could you help with a pull request? For your information, kernel bpf selftests maintains a config file as well: linux:tools/testing/selftests/bpf/config, which contains some networking, security config as well. Thanks!

yonghong-song avatar Jun 11 '21 16:06 yonghong-song

Sure. I will take a look the selftest config file and polish the config table. If finished, I will send a PR.

rainkin1993 avatar Jun 15 '21 00:06 rainkin1993

@rainkin1993 We really need kernel_config.md to select only the settings we need. After your PR about the list of the minimal requirements is merged, we want to add items about additional functionalities like CONFIG_BPF_KPROBE_OVERRIDE. How is the progress on the PR?

KentaTada avatar Apr 20 '22 05:04 KentaTada

I'm investigating and summarizing the recent configuration. [WIP] https://github.com/KentaTada/bcc/blob/add-kernel-config/docs/kernel_config.md

KentaTada avatar Apr 22 '22 06:04 KentaTada

@chethanah

Thanks for the activity about https://github.com/iovisor/bcc/pull/4436

As of now, CONFIG_KPROBES_ON_FTRACE is not mandatory but for optimization. https://github.com/iovisor/bcc/pull/4436#discussion_r1073362452 Acutually, we don't use it because arm64 does not yet support it. So we may add the new functionalities kprobe optimization

When it comes to kprobe optimization, I forgot to consider kprobe muliti. In my understanding, kprobe multi depends on CONFIG_FPROBE.

Anyway, I'll increase items of kprobes when I have some time.

KentaTada avatar Jan 23 '23 05:01 KentaTada