libbpf / bpftool

Automated upstream mirror for bpftool stand-alone build.
Other
377 stars 69 forks source link

BPFTool Prog Loadall command Deletes /sys/fs/cgroup virtual file system directory #127

Closed ndejaco2 closed 9 months ago

ndejaco2 commented 9 months ago

I am using the following BPFTool version:

bpftool v7.3.0 using libbpf v1.3 Linux version: 4.14.328-248.540.amzn2.aarch64

I am running a command to load my BPF program like so:

sudo ./bpftool prog loadall myProgram.o /sys/fs/bpf/ pinmaps /sys/fs/bpf/

The strange behavior I am seeing is that the result of this command is that the /sys/fs/cgroup directory is deleted when it existed prior to calling this command:

$ sudo ls -l /sys/fs/cgroup
ls: cannot access /sys/fs/cgroup: No such file or directory

This causes issues for initialization of systemd services which are using cgroup to limit memory consumption which I am trying to initialize after loading the BPF program. Is this behavior expected and is there some workaround I can apply?

qmonnet commented 9 months ago

Hi, thanks for the report!

This looks like a consequence of https://github.com/libbpf/bpftool/issues/100, with bpftool mistakenly re-mounting the bpffs on top of the parent directory of your path (/sys/fs/) and masking the previous contents of the directory.

This needs to be fixed, but in the meantime, you can probably work around it by passing another path to pin your programs? bpftool prog loadall ... pinmaps /sys/fs/bpf/myProgram?

ndejaco2 commented 9 months ago

Thanks! I found this command properly loaded the program without deleting /sys/fs/cgroup:

sudo ./bpftool prog loadall myProgram.o /sys/fs/bpf/myProgram/ pinmaps /sys/fs/bpf/myProgram/
qmonnet commented 9 months ago

OK, great! I'll try to work on a proper fix when I find a moment.