diff options
author | 2025-02-06 07:44:05 -0500 | |
---|---|---|
committer | 2025-02-07 15:12:37 +0000 | |
commit | a88b1d7e2dc77fdacef5f0cf4cf6794a9b86ffe0 (patch) | |
tree | 86c31e279252ec8920bf4fa6c570f01622e46c4f | |
parent | f5d3a8e1737455da4113a25a6d1455dcc7934327 (diff) |
hs-test: fix numa node core retrieval
In CpuAllocator, the default assumption of two node core ranges
seems to not be fully correct. Added handling of multiple ranges
and singular cores.
Type: fix
Change-Id: Id50147c5360baa4035fcd87e3717b0d6c9ea7e5f
Signed-off-by: Semir Sionek <ssionek@cisco.com>
(cherry picked from commit 119ae0a10a990c0c4212c043f0a446b0af362652)
-rw-r--r-- | extras/hs-test/infra/cpu.go | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/extras/hs-test/infra/cpu.go b/extras/hs-test/infra/cpu.go index e871c60af80..743a4eddc67 100644 --- a/extras/hs-test/infra/cpu.go +++ b/extras/hs-test/infra/cpu.go @@ -93,7 +93,7 @@ func (c *CpuAllocatorT) readCpus() error { c.cpus = iterateAndAppend(first, second, c.cpus) c.cpus = iterateAndAppend(third, fourth, c.cpus) } else if NumaAwareCpuAlloc { - var fifth, sixth int + var range1, range2 int var tmpCpus []int file, err := os.Open("/sys/devices/system/node/online") @@ -122,22 +122,28 @@ func (c *CpuAllocatorT) readCpus() error { sc := bufio.NewScanner(file) sc.Scan() line := sc.Text() - _, err = fmt.Sscanf(line, "%d-%d,%d-%d", &third, &fourth, &fifth, &sixth) - if err != nil { - return err - } - // get numa node cores from first range - tmpCpus = iterateAndAppend(third, fourth, tmpCpus) + for _, coreRange := range strings.Split(line, ",") { + if strings.IndexRune(coreRange, '-') != -1 { + _, err = fmt.Sscanf(coreRange, "%d-%d", &range1, &range2) + if err != nil { + return err + } + tmpCpus = iterateAndAppend(range1, range2, tmpCpus) + } else { + _, err = fmt.Sscanf(coreRange, "%d", &range1) + if err != nil { + return err + } + tmpCpus = append(tmpCpus, range1) + } + } // discard cpu 0 if tmpCpus[0] == 0 && !*UseCpu0 { tmpCpus = tmpCpus[1:] } - // get numa node cores from second range - tmpCpus = iterateAndAppend(fifth, sixth, tmpCpus) - // make c.cpus divisible by maxContainerCount * nCpus, so we don't have to check which numa will be used // and we can use offsets countToRemove := len(tmpCpus) % (c.maxContainerCount * *NConfiguredCpus) |