Skip to content

Commit b33e947

Browse files
committed
Export list of HugePageSizeUnits
This will allow others to import it instead of copying it. Signed-off-by: Odin Ugedal <odin@ugedal.com>
1 parent c6445b1 commit b33e947

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libcontainer/cgroups/utils.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ const (
2222
CgroupProcesses = "cgroup.procs"
2323
)
2424

25+
// HugePageSizeList is a list of the units used by the linux kernel when
26+
// naming the HugePage control files.
27+
// https://www.kernel.org/doc/Documentation/cgroup-v1/hugetlb.txt
28+
// TODO Since the kernel only use KB, MB and GB; TB and PB should be removed,
29+
// depends on https://github.com/docker/go-units/commit/a09cd47f892041a4fac473133d181f5aea6fa393
30+
var HugePageSizeUnitList = []string{"B", "KB", "MB", "GB", "TB", "PB"}
31+
2532
// https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt
2633
func FindCgroupMountpoint(cgroupPath, subsystem string) (string, error) {
2734
mnt, _, err := FindCgroupMountpointAndRoot(cgroupPath, subsystem)
@@ -422,14 +429,13 @@ func GetHugePageSize() ([]string, error) {
422429

423430
func getHugePageSizeFromFilenames(fileNames []string) ([]string, error) {
424431
var pageSizes []string
425-
sizeList := []string{"B", "KB", "MB", "GB", "TB", "PB"}
426432
for _, fileName := range fileNames {
427433
nameArray := strings.Split(fileName, "-")
428434
pageSize, err := units.RAMInBytes(nameArray[1])
429435
if err != nil {
430436
return []string{}, err
431437
}
432-
sizeString := units.CustomSize("%g%s", float64(pageSize), 1024.0, sizeList)
438+
sizeString := units.CustomSize("%g%s", float64(pageSize), 1024.0, HugePageSizeUnitList)
433439
pageSizes = append(pageSizes, sizeString)
434440
}
435441

0 commit comments

Comments
 (0)