Instructions to enable spin locks?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings:

I believe the way that this project is using EBPF hash maps in an EBPF program that processes received packets on the XDP receive hook, we need to acquire spin locks while updating map entries, or else we are subject to multiple packets being processed in parallel on multiple CPU cores, and causing incorrect updates to the map values.

https://github.com/intel/host-int

In particular, we should use spin locks at least for this map in the program intmd_xdp_ksink.c: https://github.com/intel/host-int/blob/main/src/xdp/intmd_xdp_ksink.c#L27-L31

I have made at least a few small code changes that seem like they might be correct, in this commit (on my personal fork of that Gitub repo above): https://github.com/jafingerhut/host-int/commit/55577a6efd9d2f5c067f7761aeae01d5669b57fc

While those modifications still allow me to compile the program intmd_xdp_ksink.c, the program fails to pass the kernel verifier when I attempt to load it.  The error messages I see from the verifier can be found at the end of this file: https://github.com/jafingerhut/host-int/blob/partial-spin-lock-implementation/README-verifier-error.txt

The last file I linked also shows steps to reproduce the error, at least on an Ubuntu 20.04 Linux system.  I have not tried reproducing it on other Linux distributions.  I am not aware of any part of that code that depends upon the Linux distribution, other than the Bash install scripts, which install particular Ubuntu packages for build dependencies.

As mentioned in that README, my best guess is that the main piece I am missing is a BTF description of the map, mentioned as a requirement for using spin locks in the bpf-helpers man page in the section describing the bpf_spin_lock function: https://man7.org/linux/man-pages/man7/bpf-helpers.7.html

I would greatly appreciate any steps or example code that would help me get to a working implementation of spin locks for this map.  Bonus points for me if the steps work on a freshly installed Ubuntu 20.04 Linux system, but hopefully an example working on a different Linux distribution would help me see what I'm missing, and lead me to a working EBPF program.

I have attempted to compile all of the EBPF programs in the samples/bpf directory of an Ubuntu-specific Linux kernel source tree, but so far have failed to determine the exact sequence of package installations and/or commands required to successfully compile them all.  I know there is at least one sample program there using spin locks.  I have heard that DWARF and/or pahole might be useful here, and I see pahole mentioned in the kernel samples/bpf/Makefile, but have not yet been able to see the pahole command ever executed by the Makefile (likely because I am missing some necessary setup steps before trying to use that Makefile).

Thanks,
Andy Fingerhut




[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux