Kernel support for eBPF

Hi,
I want install BPF and BCC to develop debugging/monitoring applications in Nano. For example using Kprobes, etc… . I followed the installation procedure in BCC compiler collection. I also enabled below settings in kernel configuration:

CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
# [optional, for tc filters]
CONFIG_NET_CLS_BPF=m
# [optional, for tc actions]
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
# [for Linux kernel versions 4.1 through 4.6]
CONFIG_HAVE_BPF_JIT=y
# [for Linux kernel versions 4.7 and later]
CONFIG_HAVE_EBPF_JIT=y
# [optional, for kprobes]
CONFIG_BPF_EVENTS=y
# Need kernel headers through /sys/kernel/kheaders.tar.xz
CONFIG_IKHEADERS=y

But when running the sample tools provided by BCC. It cannot run it.

~/proj/javad/unitop$ sudo tcptop-bpfcc 
In file included from /virtual/main.c:3:
In file included from /lib/modules/4.9.140/build/include/net/sock.h:51:
In file included from /lib/modules/4.9.140/build/include/linux/netdevice.h:38:
In file included from /lib/modules/4.9.140/build/include/linux/dmaengine.h:20:
In file included from /lib/modules/4.9.140/build/include/linux/device.h:24:
In file included from /lib/modules/4.9.140/build/include/linux/pinctrl/devinfo.h:21:
In file included from /lib/modules/4.9.140/build/include/linux/pinctrl/consumer.h:17:
In file included from /lib/modules/4.9.140/build/include/linux/seq_file.h:10:
/lib/modules/4.9.140/build/include/linux/fs.h:2745:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
        if (id < 0 || id >= READING_MAX_ID)
            ~~ ^ ~
1 warning generated.
bpf: Failed to load program: Invalid argument

Traceback (most recent call last):
  File "/usr/sbin/tcptop-bpfcc", line 203, in <module>
    b = BPF(text=bpf_text)
  File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 308, in __init__
    self._trace_autoload()
  File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 916, in _trace_autoload
    fn = self.load_func(func_name, BPF.KPROBE)
  File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 348, in load_func
    (func_name, errstr))
Exception: Failed to load BPF program kprobe__tcp_cleanup_rbuf: Invalid argument

Does the Nano kernel support BPF/eBPF ? If yes, How we should use it in Nano?

You should probably start by finding out if the compile was correctly installed. Check this for the status of these features:
zcat /proc/config.gz | egrep '(_BPF|IKHEADERS)'

Also be sure modules are installed at:
/lib/modules/$(uname -r)/kernel

Keep in mind that this is just Linux running on arm64, and not something either “supported” or “unsupported” by NVIDIA. The first thing I’d always have to ask on something working on this low level is if this has actually been tested on arm64. Have you contacted the BPF maintainers about the errors and mentioned this is arm64? I mainly ask because it isn’t NVIDIA which provides “/lib/modules/4.9.140/build/include/linux/seq_file.h” (this would basically be a symbolic link to the headers, but exist mainly for reference and is not actively used).

Note that your “uname -r” must be “4.9.140”, and thus you’ve changed your module location (the default would be “4.9.140-tegra”, which is lost when compile does not set “CONFIG_LOCALVERSION”. If all modules were placed here (and it is actually good your “uname -r” changed when the modifications are invasive and not in module format), then so far things look right. The thing to remember though is that none of those kernel files are NVIDIA-provided and are part of the kernel itself.

It is likely that whoever developed this did so originally on a desktop PC architecture and this might not work with arm64.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.