Skip to content

Commit 51dcf5f

Browse files
committed
Fix cgroup hugetlb size prefix for kB
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 (aarch64) inside the "/sys/kernel/mm/hugepages/" directory: - "hugepages-64kB" - "hugepages-2048kB" - "hugepages-32768kB" - "hugepages-1048576kB" And the corresponding cgroup files: - "hugetlb.64KB._____" - "hugetlb.2MB._____" - "hugetlb.32MB._____" - "hugetlb.1GB._____" Signed-off-by: Odin Ugedal <[email protected]>
1 parent fc51a4c commit 51dcf5f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func readTasksPids(path string, subsystem Name) ([]Task, error) {
168168
func hugePageSizes() ([]string, error) {
169169
var (
170170
pageSizes []string
171-
sizeList = []string{"B", "kB", "MB", "GB", "TB", "PB"}
171+
sizeList = []string{"B", "KB", "MB", "GB", "TB", "PB"}
172172
)
173173
files, err := ioutil.ReadDir("/sys/kernel/mm/hugepages")
174174
if err != nil {

0 commit comments

Comments
 (0)