cpupri_find_fitness(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 be NULL, 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 🌈


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