Skip to content

Conversation

@odinuge
Copy link
Contributor

@odinuge odinuge commented Jun 23, 2019

This is ~a cherry-pick of opencontainers/runc#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:

  • "hugepages-64kB"
  • "hugepages-2048kB"
  • "hugepages-32768kB"
  • "hugepages-1048576kB"

And the corresponding cgroup files:

  • "hugetlb.64KB._____"
  • "hugetlb.2MB._____"
  • "hugetlb.32MB._____"
  • "hugetlb.1GB._____"

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:
- "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 <odin@ugedal.com>
Not all arches/setups supports all page sizes. Should only
use the ones supported on the current platform

Signed-off-by: Odin Ugedal <odin@ugedal.com>
@odinuge
Copy link
Contributor Author

odinuge commented Aug 21, 2019

cc @vbatts

@vbatts
Copy link
Member

vbatts commented Aug 21, 2019

LGTM

Approved with PullApprove

@vbatts
Copy link
Member

vbatts commented Aug 21, 2019

ping @opencontainers/runtime-tools-maintainers

@hqhq
Copy link
Contributor

hqhq commented Aug 22, 2019

LGTM

Approved with PullApprove

@hqhq hqhq merged commit fdf411e into opencontainers:master Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants