From: Semir Sionek Date: Thu, 6 Feb 2025 12:44:05 +0000 (-0500) Subject: hs-test: fix numa node core retrieval X-Git-Tag: v25.02-rc2~1 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=a88b1d7e2dc77fdacef5f0cf4cf6794a9b86ffe0;p=vpp.git 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 (cherry picked from commit 119ae0a10a990c0c4212c043f0a446b0af362652) --- 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)