在Linux内核3.11.0-13-generic
上,我无法为内核线程设置关联,如下例所示:
>ps -p 828
PID TTY TIME CMD
828 ? 00:00:00 nfsiod
>sudo taskset -pc 7 828
pid 828's current affinity list: 0-11
taskset: failed to set pid 828's affinity: Invalid argument
>sudo taskset -pc 7 17551
pid 17551's current affinity list: 7
pid 17551's new affinity list: 7
>
17551是用户进程,nfsiod是内核线程。如何更改作为内核线程运行的nfsiod守护程序的亲和力?
答案 0 :(得分:1)
许多内核线程设置标志PF_NO_SETAFFINITY
:
#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */
要更改亲和力,您必须更改内核。