SCX eBPF function scx_bpf_dsq_insert
The scx_bpf_dsq_insert function handles the renaming of scx_bpf_dispatch to scx_bpf_dsq_insert and the migration to scx_bpf_dsq_insert___v2 gracefully.
Definition
Note
In v6.19 the signature of this function got changed to return a bool.
static inline bool
scx_bpf_dsq_insert(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags)
{
if (bpf_ksym_exists(scx_bpf_dsq_insert___v2___compat)) {
return scx_bpf_dsq_insert___v2___compat(p, dsq_id, slice, enq_flags);
} else if (bpf_ksym_exists(scx_bpf_dsq_insert___v1)) {
scx_bpf_dsq_insert___v1(p, dsq_id, slice, enq_flags);
return true;
} else {
scx_bpf_dispatch___compat(p, dsq_id, slice, enq_flags);
return true;
}
}
Usage
This function has the same name as the scx_bpf_dsq_insert kfunc, which will cause the pre-processor to emit this function instead of just the kfunc. It checks at runtime if the kernel has the scx_bpf_dsq_insert kfunc, and if it does, it calls it. If it doesn't, it calls the scx_bpf_dispatch___compat kfunc instead.
These two kfuncs are functionally equivalent, but a rename happened since the name dispatch was overloaded and confusing.
Since v6.19, the scx_bpf_dsq_insert kfunc is deprecated in favor of the V2 version which returns a boolean. This function was modified to return a boolean even when older kfuncs are in use and to call the v2 kfunc when available.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome