linuxmultithreadinglinux-kernelschedulingcpuset

Could the affinity of thread created by kernel be set by "cpuset"?


The affinity of user processes could be set by cpuset(7).

Could the affinity of thread created by kernel be set through the cpuset(7)?

I found that the affinity of some kthreads could be set by cpuset indeed([rcu_sched],[rcu_bh]),some kthreads couldn't([nvme-delete-wq],[kthreadd],i got the error: " echo: write error: Invalid argument").

If you have a better solution, please let me know.


Solution

  • cpuset(7) is a manual page that describes a Linux userspace API in general. As the page states, you can use the sched_setaffinity(2) syscall to restrict a task to a specific set of CPUs.

    The fact that sched_setaffinity(2) is a syscall should already make you notice that the functionality is intended for userspace usage. If you are writing kernel code, kernel threads have different internal APIs for this purpose (see kthread.h):