30.10. 使用 TuneD cpu-partitioning 配置文件进行低延迟调整
这个步骤描述了如何使用 TuneD 的 cpu-partitioning
配置文件为低延迟调整系统。它使用了低延迟应用的示例,它可以使用 cpu-partitioning
和 CPU 布局,如 cpu-partitioning 图中所述。
本例中的应用程序使用了:
- 从网络读取数据的专用的 reader 线程将固定到 CPU 2。
- 处理此网络数据的大量线程将固定到 CPU 4-23。
- 将处理的数据写入网络的专用写入器线程将固定到 CPU 3。
先决条件
-
您已以 root 用户身份,使用
dnf install tuned-profiles-cpu-partitioning
命令安装cpu-partitioning
TuneD 配置文件。
流程
使用以下更改编辑
/etc/tuned/cpu-partitioning-variables.conf
文件:注释掉
isolated_cores=${f:calc_isolated_cores:1}
行:# isolated_cores=${f:calc_isolated_cores:1}
为隔离的 CPUS 添加以下信息:
# All isolated CPUs: isolated_cores=2-23 # Isolated CPUs without the kernel’s scheduler load balancing: no_balance_cores=2,3
设置
cpu-partitioning
TuneD 配置文件:# tuned-adm profile cpu-partitioning
重启系统。
重新引导后,将根据 cpu-partitioning 图中的隔离,为低延迟调优。该应用可以使用 taskset 将读取器和写入器线程固定到 CPU 2 和 3,以及 CPU 4-23 上剩余的应用程序线程。
验证
验证隔离的 CPU 是否没有在
Cpus_allowed_list
字段中反映:# cat /proc/self/status | grep Cpu Cpus_allowed: 003 Cpus_allowed_list: 0-1
要查看所有进程的关联性,请输入:
# ps -ae -o pid= | xargs -n 1 taskset -cp pid 1's current affinity list: 0,1 pid 2's current affinity list: 0,1 pid 3's current affinity list: 0,1 pid 4's current affinity list: 0-5 pid 5's current affinity list: 0,1 pid 6's current affinity list: 0,1 pid 7's current affinity list: 0,1 pid 9's current affinity list: 0 ...
注意TuneD 无法更改某些进程的关联性,主要是内核进程。在本例中,PID 为 4 和 9 的进程保持不变。
其他资源
-
tuned-profiles-cpu-partitioning (7)
man page