Skip to content

Commit ca5682e

Browse files
committed
Assuming that missing online file indicates CONFIG_HOTPLUG_CPU=n
Signed-off-by: Maciej "Iwan" Iwanowski <[email protected]>
1 parent ac63c56 commit ca5682e

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

utils/sysfs/sysfs.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"os"
2323
"path"
2424
"path/filepath"
25-
"regexp"
2625
"strconv"
2726
"strings"
2827

@@ -341,7 +340,7 @@ func (fs *realSysFs) IsCPUOnline(dir string) bool {
341340
if err != nil {
342341
pathErr, ok := err.(*os.PathError)
343342
if ok {
344-
if errors.Is(pathErr.Unwrap(), os.ErrNotExist) && isZeroCPU(dir) {
343+
if errors.Is(pathErr.Unwrap(), os.ErrNotExist) {
345344
return true
346345
}
347346
}
@@ -351,9 +350,3 @@ func (fs *realSysFs) IsCPUOnline(dir string) bool {
351350
trimmed := bytes.TrimSpace(content)
352351
return len(trimmed) == 1 && trimmed[0] == 49
353352
}
354-
355-
func isZeroCPU(dir string) bool {
356-
regex := regexp.MustCompile("cpu([0-9]*)")
357-
matches := regex.FindStringSubmatch(dir)
358-
return len(matches) == 2 && matches[1] == "0"
359-
}

utils/sysfs/sysfs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,5 @@ func TestIsCPUOnlineNoFileAndCPU0MustBeOnline(t *testing.T) {
139139
assert.True(t, online)
140140

141141
online = sysFs.IsCPUOnline("./testdata/missing_online/node0/cpu33")
142-
assert.False(t, online)
142+
assert.True(t, online)
143143
}

0 commit comments

Comments
 (0)