Chuyi Zhou <zhouchuyi@xxxxxxxxxxxxx> writes:
In the kubernetes production environment, we have observed a high
frequency of writes to cpu.max, approximately every 2~4 seconds for each
cgroup, with the same value being written each time. This can result in
unnecessary overhead, especially on machines with a large number of CPUs
and cgroups.
This is because kubelet and runc attempt to persist resource
configurations through frequent updates with same value in this manner.
While optimizations can be made to kubelet and runc to avoid such
overhead(e.g. check the current value of cpu request/limit before writing
to cpu.max), it is still worth to bail out from tg_set_cfs_bandwidth() if
we attempt to update with the same value.
Yeah, this is silly of userspace, but we also do the same sort of check
for shares, so sure.
We do need it to be inside of a lock though, multiple threads could
in theory write to the file at once. Just move it down inside of
cfs_constraints_mutex and that's fine.