Recently, I've been trying to work with BPF_ARENA. My objective is to use it on XDP programs. However, the following error appears when I try to use bpf_arena_alloc_pages:
program must be sleepable to call sleepable kfunc bpf_arena_alloc_pages
From what I understand about XDP, at least currently, XDP programs aren't sleepable. If so, I'm confused as to why the eBPF documentation lists XDP programs as a type that can use this kfunc.
There is a flag BPF_F_SLEEPABLE that can be used to load the eBPF program as sleepable, but does that also apply to XDP? This older post has a similar question, but it's probably outdated and I couldn't find more information about sleepable programs and, more specifically, how this kfunc could be used in XDP.
If so, I'm confused as to why the eBPF documentation lists XDP programs as a type that can use this kfunc.
The reason why its there is because the list is generated based on the program types it is registered for. BPF_PROG_TYPE_UNSPEC
meaning all program types that support kfuncs.
The sleepable limitation originates from the KF_SLEEPABLE
kfuncs flag it is registered with. And as you said, XDP programs cannot be sleepable.
Unfortunately, the eBPF docs are not sophisticated enough (yet) to remove sleepable kfuncs from the list of supported kfuncs of non-sleepable program types.