scx_cmask_ref_init(9)
π 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 hostingsrc. Like, it's the venue andsrcis 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:
0on success π-EINVALif the range is out of bounds, or ifalloc_wordsdoesn't cover it π
Fr fr, check your bounds and check thatalloc_wordsactually covers the range, or you're getting-EINVALand you will know about it.
π SEE ALSO π
Kernel file ./kernel/sched/ext/cid.c β and the whole squad, all of them:
scx_cid_publish_tables(9)scx_cid_retire_tables(9)scx_cid_init(9)scx_cmask_clear(9)scx_cmask_fill(9)scx_bpf_cid_override(9)scx_bpf_cid_to_cpu(9)scx_bpf_cpu_to_cid(9)scx_cmask_subset(9)scx_cmask_empty(9)scx_bpf_cid_topo(9)scx_cmask_ref_init_kern(9)scx_cmask_ref_shard(9)scx_cmask_ref_or(9)scx_cmask_ref_copy(9)scx_cmask_ref_from_cpumask(9)
π 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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms