Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei committed Feb 13, 2023
1 parent 43ce2d6 commit 32c7401
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions util/cgroup/cgroup_cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ var noCPUControllerDetected = errors.New("no cpu controller detected")

// Helper function for getCgroupCPU. Root is always "/", except in tests.
func getCgroupCPU(root string) (CPUUsage, error) {
path, err := detectControlPath(filepath.Join(root, procPathCGroup), "cpu,cpuacct")
cu, err := getCgroupCPUInternal(root, "cpu,cpuacct")
if err == nil {
return cu, nil
}
return getCgroupCPUInternal(root, "cpuacct,cpu")
}

// getCgroupCPUInternal is to deal with different control keyword
func getCgroupCPUInternal(root, controlKeyword string) (CPUUsage, error) {
path, err := detectControlPath(filepath.Join(root, procPathCGroup), controlKeyword)
if err != nil {
return CPUUsage{}, err
}
Expand All @@ -35,7 +44,7 @@ func getCgroupCPU(root string) (CPUUsage, error) {
return CPUUsage{}, noCPUControllerDetected
}

mount, ver, err := getCgroupDetails(filepath.Join(root, procPathMountInfo), path, "cpu,cpuacct")
mount, ver, err := getCgroupDetails(filepath.Join(root, procPathMountInfo), path, controlKeyword)
if err != nil {
return CPUUsage{}, err
}
Expand Down

0 comments on commit 32c7401

Please sign in to comment.