Red Hat Training

A Red Hat training course is available for RHEL 8

26.9. 使用 systemd 配置 CPUSET 控制器

使用 systemd 资源管理 API,您可以对服务可以使用的一组 CPU 和 NUMA 节点配置限制。这个限制限制对进程使用的系统资源的访问。请求的配置写在 cpuset.cpuscpuset.mems 文件中。

但是,可能无法使用请求的配置,因为父 cgroup 限制 cpusmems。若要访问当前的配置,将 cpuset.cpus.effectivecpuset.mems.ff 文件导出到用户。

流程

  • 设置 AllowedCPUs

    # systemctl set-property <service name>.service AllowedCPUs=<value>

    例如:

    # systemctl set-property <service name>.service AllowedCPUs=0-5
  • 设置 AllowedMemoryNodes

    # systemctl set-property <service name>.service AllowedMemoryNodes=<value>

    例如:

    # systemctl set-property <service name>.service AllowedMemoryNodes=0