scx_cmask_ref_init(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… scx_cmask_ref_init β€” the Kernel API Manual, bestie edition ✨

Okay so picture this: you're in the Kernel API Manual, section 9, and today's main character is scx_cmask_ref_init. This is the page that explains it, and yes I'm gonna walk you through every bit of it 🫢


🌸 NAME 🌸

scx_cmask_ref_init β€” bind a scx_cmask_ref to a BPF-arena cmask πŸŽ€

Like, it's the little gluing ceremony where your ref gets attached to a cmask living in the BPF arena. Iconic.


✨ SYNOPSIS ✨

int scx_cmask_ref_init (struct scx_sched *sch , const struct scx_cmask
*src , struct scx_cmask_ref *ref );

Three args in, one int out. She's a function, she returns int, that's the whole vibe πŸ”₯


πŸ¦‹ ARGUMENTS πŸ¦‹

  • sch β€” the scheduler whose arena is hosting src. Like, it's the venue and src is the guest of honour, you know? πŸ‘‘
  • src β€” the BPF-supplied cmask, already rebased to its kernel address. Very demure, very rebased πŸ’œ
  • ref β€” the output ref. This is where the result goes. It's giving "you had one job and it's to be the out-param" πŸ’€

🧚 DESCRIPTION 🧚

So what she actually does is take a snapshot of src's base, nr_cids, and alloc_words πŸ“

And the reason the snapshot is literally necessary? Because BPF may mutate the live header asynchronously 😭 So you can't just keep staring at the original header and hoping it stays still β€” it won't, she moves. Snapshot it, freeze the moment, move on. Main character energy 🌈

Return values, no cap:

  • 0 on success πŸŽ‰
  • -EINVAL if the range is out of bounds, or if alloc_words doesn't cover it πŸ™ˆ
Fr fr, check your bounds and check that alloc_words actually covers the range, or you're getting -EINVAL and you will know about it.

πŸŽ€ SEE ALSO πŸŽ€

Kernel file ./kernel/sched/ext/cid.c β€” and the whole squad, all of them:


πŸ’– That's the whole page, bestie. Source lives at ./kernel/sched/ext, dated October 2026 β€” so go forth, snapshot your headers, respect the async mutation, and slay βœ¨πŸ’…

πŸ“¦ where this page comes from