Export list of HugePageSizeUnits
This will allow others to import it instead of copying it.
@@ -22,6 +22,13 @@ const (
CgroupProcesses = "cgroup.procs"
)
+// HugePageSizeUnitList is a list of the units used by the linux kernel when
+// naming the HugePage control files.
+// https://www.kernel.org/doc/Documentation/cgroup-v1/hugetlb.txt
+// TODO Since the kernel only use KB, MB and GB; TB and PB should be removed,
+// depends on https://github.com/docker/go-units/commit/a09cd47f892041a4fac473133d181f5aea6fa393
+var HugePageSizeUnitList = []string{"B", "KB", "MB", "GB", "TB", "PB"}
+
// https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt
func FindCgroupMountpoint(cgroupPath, subsystem string) (string, error) {
mnt, _, err := FindCgroupMountpointAndRoot(cgroupPath, subsystem)
@@ -422,14 +429,13 @@ func GetHugePageSize() ([]string, error) {
func getHugePageSizeFromFilenames(fileNames []string) ([]string, error) {
var pageSizes []string
- sizeList := []string{"B", "KB", "MB", "GB", "TB", "PB"}
for _, fileName := range fileNames {
nameArray := strings.Split(fileName, "-")
pageSize, err := units.RAMInBytes(nameArray[1])
if err != nil {
return []string{}, err
}
- sizeString := units.CustomSize("%g%s", float64(pageSize), 1024.0, sizeList)
+ sizeString := units.CustomSize("%g%s", float64(pageSize), 1024.0, HugePageSizeUnitList)
pageSizes = append(pageSizes, sizeString)
}
