Skip to content

SCX eBPF macro __COMPAT_scx_bpf_dsq_move

v6.13

The __COMPAT_scx_bpf_dsq_move macro handles both the renaming of scx_bpf_dispatch_from_dsq to scx_bpf_dsq_move, and the case where the kernel has neither of these kfuncs.

Definition

#define __COMPAT_scx_bpf_dsq_move(it__iter, p, dsq_id, enq_flags)       \
    (bpf_ksym_exists(scx_bpf_dsq_move) ?                   \
     scx_bpf_dsq_move((it__iter), (p), (dsq_id), (enq_flags)) :       \
     (bpf_ksym_exists(scx_bpf_dispatch_from_dsq___compat) ?            \
      scx_bpf_dispatch_from_dsq___compat((it__iter), (p), (dsq_id), (enq_flags)) : \
      false))

Usage

This macro checks at runtime if the kernel has the scx_bpf_dsq_move(../../linux/kfuncs/scx_bpf_dsq_move.md) kfunc, and if it does, it calls it. If it doesn't, it checks if the kernel has the scx_bpf_dispatch_from_dsq kfunc, and if it does, it calls it. If neither of these kfuncs are available, it return zero.

These two kfuncs are functionally equivalent, but a rename happened since the name dispatch was overloaded and confusing.

All of this logic makes sure your program can run on any kernel, no matter changes made to the kfuncs.

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome