Skip to content

SCX eBPF function scx_bpf_dsq_insert_vtime

v6.13

The scx_bpf_dsq_insert_vtime function handles the renaming of scx_bpf_dispatch_vtime to scx_bpf_dsq_insert_vtime and the later transition to __scx_bpf_dsq_insert_vtime gracefully.

Definition

static inline bool
scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id, u64 slice, u64 vtime,
             u64 enq_flags)
{
    if (bpf_core_type_exists(struct scx_bpf_dsq_insert_vtime_args)) {
        struct scx_bpf_dsq_insert_vtime_args args = {
            .dsq_id = dsq_id,
            .slice = slice,
            .vtime = vtime,
            .enq_flags = enq_flags,
        };

        return __scx_bpf_dsq_insert_vtime(p, &args);
    } else if (bpf_ksym_exists(scx_bpf_dsq_insert_vtime___compat))) {
        scx_bpf_dsq_insert_vtime___compat(p, dsq_id, slice, vtime,
                          enq_flags);
        return true;
    } else {
        scx_bpf_dispatch_vtime___compat(p, dsq_id, slice, vtime,
                        enq_flags);
        return true;
    }
}

Usage

This function has the same name as the scx_bpf_dsq_insert_vtime kfunc. The kfunc was named scx_bpf_dispatch_vtime in older kernels. And in more recent kernels the __scx_bpf_dsq_insert_vtime kfunc was introduced, which receives the arguments as a structure, allowing for more then 5 function arguments (a BPF instruction set limitation). This compatibility function used CO-RE to pick the correct kfunc to use depending on the version of the kernel the program is being loaded on.

Example

Docs could be improved

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