我正在努力为基准测试创造一个稳定的环境
所以我需要隔离cpu(没有其他进程使用隔离的cpu)
我无法使用 cset(仅适用于 cgroup v1),也无法使用 isolcpus(安全策略禁止)。
据我所知 - 唯一的选择是使用独立的 cpu 制作 cgroup v2。
我阅读了 cgroup v2 文档:https://docs.kernel.org/admin-guide/cgroup-v2.html
它在“cpuset.cpus.partition”部分告诉以下内容:
When set to "isolated", the CPUs in that partition
root will be in an isolated state without any load balancing from the scheduler.
Tasks placed in such a partition with multiple CPUs
should be carefully distributed and bound
to each of the individual CPUs for optimal performance.
但是当我尝试将 cpuset.cpus.partition 设置为“隔离”时,我收到无效参数错误。
详情:
操作系统:Ubuntu 22.04
群组创建:
sudo cgcreate -g cpu:benchmark -g cpuset:benchmark
cpuset.cpus:0
cpuset.cpus.有效:0
cpuset.mems:0
cpuset.mems.有效:0
错误:
sudo cgset -r cpuset.cpus.partition=isolated benchmark
cgset: cgroup modify error: Invalid argument
sudo bash -c 'echo 'isolated' > cpuset.cpus.partition'
bash: line 1: echo: write error: Invalid argument
我将不胜感激任何帮助
Ubuntu 22.04,那么你的内核很可能是旧的。该功能是后来添加的:https://github.com/torvalds/linux/commit/f28e22441f353aa2c954a1b1e29144f8841f1e8a
我遇到了同样的问题,已升级(见下文),现在它可以工作了:
sudo apt install linux-generic-hwe-22.04