opencontainers / runtime-tools

OCI Runtime Tools
https://www.opencontainers.org/
Apache License 2.0
434 stars 141 forks source link

Fix cgroup hugetlb size prefix for kB #696

Closed odinuge closed 5 years ago

odinuge commented 5 years ago

This is ~a cherry-pick of https://github.com/opencontainers/runc/pull/2065.

The hugetlb cgroup control files (introduced here in 2012: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=abb8206cb0773) use "KB" and not "kB" (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/hugetlb_cgroup.c\?h\=v5.0\#n349).

The behavior in the kernel has not changed since the introduction, and the current code using "kB" will therefore fail on devices with small amounts of ram (see kubernetes/kubernetes#77169) running a kernel with config flag CONFIG_HUGETLBFS=y

As seen from the code in "mem_fmt" inside hugetlb_cgroup.c, only "KB", "MB" and "GB" are used, so the others may be removed as well.

Here is a real world example of the files inside the "/sys/kernel/mm/hugepages/" directory:

And the corresponding cgroup files:

odinuge commented 5 years ago

cc @vbatts

vbatts commented 5 years ago

LGTM

Approved with PullApprove

vbatts commented 5 years ago

ping @opencontainers/runtime-tools-maintainers

hqhq commented 5 years ago

LGTM

Approved with PullApprove