Export list of HugePageSizeUnits
This will allow others to import it instead of copying it. Signed-off-by: Odin Ugedal <odin@ugedal.com>
This commit is contained in:
parent
c6445b1c1c
commit
6f77e35daf
|
@ -22,6 +22,13 @@ const (
|
||||||
CgroupProcesses = "cgroup.procs"
|
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
|
// https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt
|
||||||
func FindCgroupMountpoint(cgroupPath, subsystem string) (string, error) {
|
func FindCgroupMountpoint(cgroupPath, subsystem string) (string, error) {
|
||||||
mnt, _, err := FindCgroupMountpointAndRoot(cgroupPath, subsystem)
|
mnt, _, err := FindCgroupMountpointAndRoot(cgroupPath, subsystem)
|
||||||
|
@ -422,14 +429,13 @@ func GetHugePageSize() ([]string, error) {
|
||||||
|
|
||||||
func getHugePageSizeFromFilenames(fileNames []string) ([]string, error) {
|
func getHugePageSizeFromFilenames(fileNames []string) ([]string, error) {
|
||||||
var pageSizes []string
|
var pageSizes []string
|
||||||
sizeList := []string{"B", "KB", "MB", "GB", "TB", "PB"}
|
|
||||||
for _, fileName := range fileNames {
|
for _, fileName := range fileNames {
|
||||||
nameArray := strings.Split(fileName, "-")
|
nameArray := strings.Split(fileName, "-")
|
||||||
pageSize, err := units.RAMInBytes(nameArray[1])
|
pageSize, err := units.RAMInBytes(nameArray[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []string{}, err
|
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)
|
pageSizes = append(pageSizes, sizeString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue