linux - 如何在不使用 grub 的情况下设置 Linux init 进程关联?

标签 linux systemd affinity

我们的应用程序可能会在各种架构上运行,所有架构都在 ramfs 机器上。 它需要设置核心隔离和亲和性以实现极快的处理。 根据架构,它可能需要固定到 numa 0 或 numa 1 上的超线程。在机器启动之前我们无法做出假设。

由于这种多样性,我们不能在grub中设置隔离参数。配置 grub 后重新启动也无济于事,因为这是一台 ramfs 机器。

我们如何在启动期间对 systemd 生成的所有用户态进程进行任务设置?我知道我可以在调用 systemd 时对其本身进行任务设置,但我无法找到它发生的位置。

最佳答案

How can we taskset all userland processes spawned by systemd during boot?

systemd.exec

Unit configuration files for services, sockets, mount points, and swap devices share a subset of configuration options which define the execution environment of spawned processes.

CPUAffinity=

Controls the CPU affinity of the executed processes. Takes a list of CPU indices or ranges separated by either whitespace or commas. CPU ranges are specified by the lower and upper CPU indices separated by a dash. This option may be specified more than once, in which case the specified CPU affinity masks are merged. If the empty string is assigned, the mask is reset, all assignments prior to this will have no effect


或者,创建一个 systemd 单元来创建拓扑配置文件并终止。让您的其他服务单元依赖于该单元,以便它们在创建拓扑配置后启动。然后让您的服务读取拓扑文件并在启动时相应地设置 cpusets 和亲缘关系(可以通过包装脚本完成)。

关于linux - 如何在不使用 grub 的情况下设置 Linux init 进程关联?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54287720/

相关文章:

c++ - 关于对 typedef 的 undefined reference 的 g++ 错误

python - 使用 Gunicorn 部署 Django 应用程序时出错?

multicore - 是否可以防止 child 继承 parent 的 CPU/核心亲缘关系?

macOS : how to set process affinity 上的 Python 3

windows-xp - 如何从Windows XP的批处理文件设置处理器关联性?

linux - 为什么 ((counter++)) 在 counter == 0 时失败?

linux - haproxy重启时出错

linux - 限制 incrond 生成的并发进程数

php - 如何在 systemd 服务中正确设置 php 脚本?

python - 每小时双倍通知 Python、Ubuntu、Telegram