Kernel support for eBPF

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:

# [optional, for tc filters]
# [optional, for tc actions]
# [for Linux kernel versions 4.1 through 4.6]
# [for Linux kernel versions 4.7 and later]
# [optional, for kprobes]
# Need kernel headers through /sys/kernel/kheaders.tar.xz

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/", line 308, in __init__
  File "/usr/lib/python2.7/dist-packages/bcc/", line 916, in _trace_autoload
    fn = self.load_func(func_name, BPF.KPROBE)
  File "/usr/lib/python2.7/dist-packages/bcc/", 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.