__scx_bpf_dsq_insert_vtime(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __scx_bpf_dsq_insert_vtime β€” okay bestie, listen

Welcome to the Kernel API Manual, section 9, and honestly? This one is a little bit of a diva. Her whole thing is arg-wrapped vtime DSQ insertion β€” yes that's the NAME, yes we're keeping it, no we're not renaming her. πŸŽ€


✨ NAME ✨

__scx_bpf_dsq_insert_vtime β€” Arg-wrapped vtime DSQ insertion. That's it, that's the vibe. Put a task in a vtime-sorted queue, but with the arguments wrapped up in a struct because BPF said "five arguments max, bestie, I don't make the rules." πŸ’€


🌸 SYNOPSIS 🌸

__bpf_kfunc bool __scx_bpf_dsq_insert_vtime (struct task_struct *p ,
struct scx_bpf_dsq_insert_vtime_args *args , const struct bpf_prog_aux
*aux );

Like, look at her. Three arguments, one of which you literally cannot touch. Main character energy fr fr. πŸ”₯


πŸ¦‹ ARGUMENTS πŸ¦‹

  • p β€” the task_struct you're inserting. Your little guy. Your blorbo. 🫢
  • args β€” the struct holding the rest of the arguments, because we ran out of argument slots and had to get creative:
    • args->dsq_id β€” the DSQ you're inserting into. The destination, the venue, the location tag. πŸ“
    • args->slice β€” how long p can run for, in nsecs. Set it to 0 to keep the current value. Zero is giving "no thoughts, head empty, keep what's already there." πŸ™ˆ
    • args->vtime β€” p's ordering inside the vtime-sorted queue of the target DSQ. Her little place in line. ⭐
    • args->enq_flags β€” SCX_ENQ_* flags. You know the ones.
  • aux β€” the implicit BPF argument, so you can access bpf_prog_aux. She's hidden from BPF progs β€” you don't call her, she just shows up. Lowkey mysterious. πŸ’œ

πŸ’– DESCRIPTION πŸ’–

So. Wrapper kfunc. It takes its arguments via a struct to work around BPF's 5 argument limit β€” iconic workaround, no notes. πŸ’…

Real talk: BPF programs should not call this directly. Use scx_bpf_dsq_insert_vtime, which is provided as an inline wrapper in common.bpf.h. That's the one you actually want, bestie. This one is the plumbing.

Okay so what does she do? She inserts p into the vtime priority queue of the DSQ identified by args->dsq_id. Tasks queued into the priority queue get ordered by args->vtime. Everything else? Absolutely identical to scx_bpf_dsq_insert. Same girl, different queue. ✨

The args->vtime ordering goes according to time_before64, which considers wrapping. So a numerically larger vtime can actually mean an earlier position in the ordering, and vice-versa. Yes, that's real. Yes, it's a little mind-bending. No, you're not bugging. 😭

Careful though!! A DSQ can only be used as a FIFO or a priority queue at any given time. So you must not call this function on a DSQ which already has one or more FIFO tasks queued β€” and vice-versa. Don't mix, it's not a vibe. Also: the built-in DSQs (SCX_DSQ_LOCAL and SCX_DSQ_GLOBAL) cannot be used as priority queues. Periodt.

Returns true on successful insertion, false on failure. πŸŽ€ And here's the cute part β€” on the root scheduler, a false return triggers a scheduler abort, so the caller doesn't even need to check the return value. She handles it. She's got you. πŸ‘‘


🌈 SEE ALSO 🌈

Kernel file ./kernel/sched/ext/ext.c, plus literally her entire extended friend group. Not me listing all of them. Okay I'm listing all of them. πŸ’€


Okay that's the whole page, you ate that. πŸ’œ She lives in ./kernel/sched/ext, this is the October 2026 edition, and that's the whole manual-name-and-date situation handled β€” mwah, bye bestie! 🧚🌸

πŸ“¦ where this page comes from