How does Linux kernel migrate the process among multiple cores?
问题 Context: Process-1 is executing on core-0. Core-1 is idle. Now, process-1 uses sched_setaffinity() to change its CPU affinity as core-1. Question: Which kernel function(s) migrate the process-1 to execute on core-1? 回答1: Here is the call sequence starting from the sched_setaffinity system call entry point in the kernel: sys_sched_setaffinity. sched_setaffinity. __set_cpus_allowed_ptr. In the last function, there are two cases as shown in the code at line 1101: if (task_running(rq, p) || p-