sys_sched_getaffinity(9)
π sys_sched_getaffinity(9)
okay so bestie, welcome to the Kernel API Manual β¨ β this one's sys_sched_getaffinity, and it's literally the syscall that tells you which CPUs a process is allowed to run on. like, which ones it's vibing with. π¦
β¨ NAME β¨
sys_sched_getaffinity β get the CPU affinity of a process π
πΈ SYNOPSIS πΈ
long sys_sched_getaffinity (pid_t pid , unsigned int len , unsigned long
__user * user_mask_ptr );
π ARGUMENTS π
pidβ the pid of the process. like, which process are we checking on πlenβ length in bytes of the bitmask pointed to byuser_mask_ptr. so, how much room you're giving it π«Άuser_mask_ptrβ a user-space pointer to hold the current CPU mask. this is where the answer gets dropped off π
β RETURN β
on success, you get back the size of the CPU mask copied to user_mask_ptr. otherwise, an error code. that's it, that's the whole vibe check π
π SEE ALSO π
- Kernel file
./kernel/sched/syscalls.cβ the whole squad lives here π§ task_prio(9)idle_cpu(9)idle_task(9)find_process_by_pid(9)sched_setscheduler(9)sched_setscheduler_nocheck(9)sys_sched_setscheduler(9)sys_sched_setparam(9)sys_sched_setattr(9)sys_sched_getscheduler(9)sys_sched_getparam(9)sys_sched_getattr(9)sys_sched_setaffinity(9)sys_sched_yield(9)yield(9)yield_to(9)sys_sched_get_priority_max(9)sys_sched_get_priority_min(9)sys_sched_rr_get_interval(9)
ngl, that's the whole page β no plot twists, no secret options, just a syscall doing its little mask-copy thing π₯
and that's a wrap, bestie π«Ά this little love letter came from ./kernel/sched, dated October 2026, and it answers to the name sys_sched_getaffinity(9) β periodt πβ¨
π¦ 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