cgroups、cpuset 更改某些进程的 cpuset 失败

cgroups、cpuset 更改某些进程的 cpuset 失败

我正在尝试“保留”CPU 上的核心以进行性能测量。我已经安装了 cpuset cgroups vfs。我创建了两个这样的子组:

/cpuset.cpu_exclusive    1
/cpuset.cpus             0-3
/cpuset.mems             0

# Everything on the PC except what I want to measure
/All/cpuset.cpu_exclusive    1
/All/cpuset.cpus             1-3
/All/cpuset.mems             0

# The measurement processes only (i.e. the shell + a binary to test)
/Timing/cpuset.cpu_exclusive    1
/Timing/cpuset.cpus             0
/Timing/cpuset.mems             0

我能够将许多进程移至“全部”组,但对于某些进程(那些看起来像内核进程的进程)我无法这样做。例如,ksoftirqd 的 pid 为 3:

[root@Io:/vfsroot]# echo 3 > All/tasks 
echo: write error: invalid argument

此外,对于某些进程,我可以在“所有/任务”中看到它们,但它们仍然会在错误的 cpu 上运行(此处为 cpu #0,带有 shell)。

[root@Io:/vfsroot]# echo 28362 > All/tasks 
[root@Io:/vfsroot]# ps -eo pid,psr | grep "0$"
...
28362   0

对于那些我想知道这是否是因为自从我更改了他们的 cpuset 以来他们还没有醒来并且 ps 显示了他们运行的最后一个 cpu...

我可以非常有效地改变我当前的 shell cpu。 (让它在/Timing/tasks中出现和消失,并用ps查看它改变CPU)

如果有必要的话,我正在使用最新版本的 Ubuntu,并使用 apt-get 安装了 cgroups。

答案1

联机cset-shield帮助页有这样的注释:

如果为shield命令提供了可选的--kthread=on选项,则所有内核线程(每个CPU绑定的中断内核线程除外)也将移至系统集。

我将此解释为“(某些)中断内核线程受 CPU 限制”。从它的名字来看,ksoftirqd(内核软IRQ守护进程)似乎是一个可能的候选者! (顺便说一句,我认为这些内核线程不会影响性能测量。)

相关内容