@@ -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
2633func FindCgroupMountpoint (cgroupPath , subsystem string ) (string , error ) {
2734 mnt , _ , err := FindCgroupMountpointAndRoot (cgroupPath , subsystem )
@@ -422,14 +429,13 @@ func GetHugePageSize() ([]string, error) {
422429
423430func 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