增加 cpu.shares cgroup 粒度

Increasing cpu.shares cgroup granularity

默认情况下,此值设置为 1024。我假设这意味着如果我将组的份额设置为 1024,它将是可用计算能力的 100%。

我有什么办法可以增加这个的粒度吗?例如,我不想在 1024 处达到最大值,而是希望在 2048 或 8196 处达到最大值。

IIRC,cpu.shares 已经非常精细了。

cpu.shares: The weight of each group living in the same hierarchy, that translates into the amount of CPU it is expected to get. Upon cgroup creation, each group gets assigned a default of 1024. The percentage of CPU assigned to the cgroup is the value of shares divided by the sum of all shares in all cgroups in the same level.

cpu.shares的值是用来和其他cgroup比较的。如果您在 cgroups 下有一个进程 运行,无论 cpu.shares 的值如何,它总是会获得主机可以空闲的 CPU。 cgroups 下的多个进程 运行 分配相同的值 cpu.shares 将平均分配可用的 CPU。

当您在 cgroups 下有多个进程时,它们的 cpu.shares 值会一起比较,数字越大的进程获得可用主机的百分比越高 CPU。如果您为两个 cgrouped 进程分配 cpu.shares=1024,然后为第三个进程分配 cpu.shares=2048,则前两个进程将获得相等数量的可用 CPU,而第三个进程将获得两倍的可用资源可用 CPU(大约 25%、25%、50%)。

实际数字可以是您想要的任何数字(现在是细粒度的),只有它们之间的百分比差异很重要。如果您使用 cpu.shares=5cpu.shares=10cpu.shares=50000cpu.shares=100000

,则上述示例的结果将被复制