cpupri_find_fitness(9)
π cpupri_find_fitness(9) β a whole Kernel API Manual moment
Okay bestie, grab your iced coffee because we're diving into the Kernel API Manual and this one is literally about finding the best (lowest-pri) CPU in the system. Yes, the whole system. Main character function behavior only. π
β¨ NAME β¨
cpupri_find_fitness β find the best (lowest-pri) CPU in the system π§
πΈ SYNOPSIS πΈ
int cpupri_find_fitness (struct cpupri *cp , struct task_struct *p ,
struct cpumask *lowest_mask , bool (*fitness_fn)(struct task_struct *p,
int cpu) );
That's the whole glow-up right there. Four args, one int, no cap. π
π¦ ARGUMENTS π¦
cpβ the cpupri context. It's giving "the vibes we're working with."pβ the task. The little guy we're trying to place. π«Άlowest_maskβ a mask to fill in with the selected CPUs. Heads up: this can also beNULL, so don't come for it if it's empty.fitness_fnβ a pointer to a function that does custom checks on whether a CPU fits a specific criteria, so we only return those CPUs. It's the vibe check, but as a function pointer:bool (*fitness_fn)(struct task_struct *p, int cpu). Only the ones that pass get to stay. π
β NOTE β
Okay so this part matters, lowkey. This function returns the recommended CPUs as calculated during the current invocation. Translation: by the time the call even returns, the CPUs may have in fact changed priorities any number of times. π
And no, that's not an issue of correctness β the normal rebalancer logic will correct any discrepancies created by racing against the uncertainty of the current priority configuration. So it's not ideal, but it's not broken either. It's giving "we live in a society" but make it scheduler internals. π₯
π RETURN π
(int)bool β CPUs were found. That's it, that's the tea. π
π SEE ALSO π
- Kernel file
./kernel/sched/cpupri.c cpupri_set(9)cpupri_init(9)cpupri_cleanup(9)
fr fr, read those before you start poking at priorities. iykyk. π
Okay that's the whole page bestie, and it lives in ./kernel/sched, stamped October 2026, filed under cpupri_find_fitness(9). Slay, go schedule something iconic. ππΈ
π¦ 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