Convert blkioWeight to io.weight properly

Signed-off-by: Boris Popovschi <zyqsempai@mail.ru>
This commit is contained in:
Boris Popovschi
2020-01-15 15:30:39 +02:00
parent 81ef5024f8
commit 4b8134f63b
2 changed files with 10 additions and 2 deletions
+8
View File
@@ -587,6 +587,14 @@ func isEINVAL(err error) bool {
}
}
// Since the OCI spec is designed for cgroup v1, in some cases
// there is need to convert from the cgroup v1 configuration to cgroup v2
// the formula for BlkIOWeight is y = (1 + (x - 10) * 9999 / 990)
// convert linearly from [10-1000] to [1-10000]
func ConvertBlkIOToCgroupV2Value(blkIoWeight uint16) uint64 {
return uint64(1 + (blkIoWeight-10)*9999/990)
}
// Since the OCI spec is designed for cgroup v1, in some cases
// there is need to convert from the cgroup v1 configuration to cgroup v2
// the formula for cpuShares is y = (1 + ((x - 2) * 9999) / 262142)