On Tue, Sep 8, 2020 at 10:07 PM Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> wrote: > > On Mon, Sep 7, 2020 at 5:18 AM David Marcinkovic > <david.marcinkovic@xxxxxxxxxx> wrote: > > > > Hello everyone, > > > > I am trying to run a simple BPF example that uses the > > `__sync_fetch_and_add` built-in function for atomic memory access. It > > fails with `libbpf: load bpf program failed: ERROR: > > strerror_r(524)=22` error message. > > > > This error does not seem to occur on the amd64 architecture. I am > > using clang version 10 for both, compiling on amd64 and > > cross-compiling for arm32. > > > > I am aware that those built-in functions are available for arm32. [0]. > > Why is this error occurring? > > > > Seems like BPF JIT for arm32 doesn't yet support those atomic > operations, see [0] > > [0] https://github.com/torvalds/linux/blob/master/arch/arm/net/bpf_jit_32.c#L1627 > > You might want to try running in interpreted mode and see if that > works for you. You'll lose speed, but will get functionality you need. Thank you very much for your reply. The program is working just fine when I disable the BPF Just In Time compiler. > > > To demonstrate I have prepared one simple example program that uses > > that built-in function for atomic memory access. > > > > Any input is much appreciated, > > > > Best regards, > > David Marčinković > > > > [0] https://developer.arm.com/documentation/dui0491/c/compiler-specific-features/gnu-builtin-functions?lang=en > > > > [...] I am curious if there is any way to enable or disable the JIT compiler when starting the BPF program? I am aware that the BPF JIT can be enabled or disabled by using the `/proc/sys/net/core/bpf_jit_enable` file, but I would like to know whether there is a way to specify it programmatically when loading the program. Let's consider one use case where we want to run two different BPF programs: one with the JIT compiler, one without it.