Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-5529: Fix updating numa core siblings map in GetCpuSiblings function #564

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1442,23 +1442,23 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
// Select the last core id
higherCoreIds := cores[len(cores)-1]
// Get cpu siblings from the selected cores and delete the selected cores from the map
cpusiblings := nodes.GetCpuSiblings(numaCoreSiblings, higherCoreIds)
cpusiblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, higherCoreIds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next time: Pop may be a shorter sinonym of GetAndRemove. I won't resubmit for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally agree with @ffromani Pop or eventExtract

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and noted

offline = append(offline, cpusiblings...)
}
offlineCpus := strings.Join(offline, ",")
// Get reserved core siblings from 0, 1
for reservedCores := 0; reservedCores < 2; reservedCores++ {
// Get the cpu siblings from the selected core and delete the siblings
// from the map. Selected siblings of cores are saved in reservedCpus
cpusiblings := nodes.GetCpuSiblings(numaCoreSiblings, reservedCores)
cpusiblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, reservedCores)
reserved = append(reserved, cpusiblings...)
}
reservedCpus := strings.Join(reserved, ",")
// Remaining core siblings available in the
// numaCoreSiblings map is used in isolatedCpus
for key := range numaCoreSiblings {
for k := range numaCoreSiblings[key] {
cpusiblings := nodes.GetCpuSiblings(numaCoreSiblings, k)
cpusiblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, k)
isolated = append(isolated, cpusiblings...)
}
}
Expand Down Expand Up @@ -1512,22 +1512,22 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
}
sort.Ints(cores)
middleCoreIds := cores[len(cores)/2]
siblings := nodes.GetCpuSiblings(numaCoreSiblings, middleCoreIds)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, middleCoreIds)
offline = append(offline, siblings...)
}
offlineCpus := strings.Join(offline, ",")
for reservedCores := 0; reservedCores < 2; reservedCores++ {
// Get the cpu siblings from the selected core and delete the siblings
// from the map. Selected siblings of cores are saved in reservedCpus
siblings := nodes.GetCpuSiblings(numaCoreSiblings, reservedCores)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, reservedCores)
reserved = append(reserved, siblings...)
}
reservedCpus := strings.Join(reserved, ",")
// Remaining core siblings available in the
// numaCoreSiblings map is used in isolatedCpus
for key := range numaCoreSiblings {
for k := range numaCoreSiblings[key] {
siblings := nodes.GetCpuSiblings(numaCoreSiblings, k)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, k)
isolated = append(isolated, siblings...)
}
}
Expand Down Expand Up @@ -1580,11 +1580,14 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
for _, node := range workerRTNodes {
numaCoreSiblings, err = nodes.GetCoreSiblings(&node)
}
if len(numaCoreSiblings[0]) < 20 {
Skip(fmt.Sprintf("This test needs systems with at least 20 cores per socket"))
}
// Get reserved core siblings from 0, 1
for reservedCores := 0; reservedCores < 2; reservedCores++ {
// Get the cpu siblings from the selected core and delete the siblings
// from the map. Selected siblings of cores are saved in reservedCpus
siblings := nodes.GetCpuSiblings(numaCoreSiblings, reservedCores)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, reservedCores)
reserved = append(reserved, siblings...)
}
reservedCpus := strings.Join(reserved, ",")
Expand All @@ -1596,11 +1599,8 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
cores = append(cores, k)
}
sort.Ints(cores)
if len(cores) < 20 {
Skip(fmt.Sprintf("This test needs systems with at least 20 cores per socket"))
}
for i := 0; i < len(cores)/2; i++ {
siblings := nodes.GetCpuSiblings(numaCoreSiblings, cores[i])
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, cores[i])
offlined = append(offlined, siblings...)
}
}
Expand All @@ -1609,7 +1609,7 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
// map is used in isolatedCpus
for key := range numaCoreSiblings {
for k := range numaCoreSiblings[key] {
siblings := nodes.GetCpuSiblings(numaCoreSiblings, k)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, k)
isolated = append(isolated, siblings...)
}
}
Expand Down Expand Up @@ -1666,15 +1666,15 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
for reservedCores := 0; reservedCores < 2; reservedCores++ {
// Get the cpu siblings from the selected core and delete the siblings
// from the map. Selected siblings of cores are saved in reservedCpus
siblings := nodes.GetCpuSiblings(numaCoreSiblings, reservedCores)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, reservedCores)
reserved = append(reserved, siblings...)
}
reservedCpus := strings.Join(reserved, ",")
// Remaining core siblings available in the
// numaCoreSiblings map is used in isolatedCpus
for key := range numaCoreSiblings {
for k := range numaCoreSiblings[key] {
siblings := nodes.GetCpuSiblings(numaCoreSiblings, k)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, k)
isolated = append(isolated, siblings...)
}
}
Expand Down Expand Up @@ -1729,20 +1729,20 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
for reservedCores := 0; reservedCores < 2; reservedCores++ {
// Get the cpu siblings from the selected core and delete the siblings
// from the map. Selected siblings of cores are saved in reservedCpus
siblings := nodes.GetCpuSiblings(numaCoreSiblings, reservedCores)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, reservedCores)
reserved = append(reserved, siblings...)
}
reservedCpus := strings.Join(reserved, ",")

discreteCores := []int{3, 13, 15, 24, 29}
for _, v := range discreteCores {
siblings := nodes.GetCpuSiblings(numaCoreSiblings, v)
siblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, v)
offlined = append(offlined, siblings...)
}
offlineCpus := strings.Join(offlined, ",")
for key := range numaCoreSiblings {
for k := range numaCoreSiblings[key] {
cpusiblings := nodes.GetCpuSiblings(numaCoreSiblings, k)
cpusiblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, k)
isolated = append(isolated, cpusiblings...)
}
}
Expand Down Expand Up @@ -1890,13 +1890,13 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
sort.Ints(coreids)
Expect(len(coreids)).ToNot(Equal(0))
middleCoreIds := coreids[len(coreids)/2]
coresiblings := nodes.GetCpuSiblings(numaCoreSiblings, middleCoreIds)
coresiblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, middleCoreIds)
reserved = append(reserved, coresiblings...)
}
reservedCpus := strings.Join(reserved, ",")
for numaNode := range numaCoreSiblings {
for coreids := range numaCoreSiblings[numaNode] {
coresiblings := nodes.GetCpuSiblings(numaCoreSiblings, coreids)
coresiblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, coreids)
isolated = append(isolated, coresiblings...)
}
}
Expand Down
19 changes: 13 additions & 6 deletions test/e2e/performanceprofile/functests/utils/nodes/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,21 @@ func GetByCpuCapacity(nodesList []corev1.Node, cpuQty int) []corev1.Node {
return nodesWithSufficientCpu
}

// GetCpuSiblings function returns the cpus siblings associated with core
// GetAndRemoveCpuSiblingsFromMap function returns the cpus siblings associated with core
// Also updates the map by deleting the cpu siblings returned
func GetCpuSiblings(numaCoreSiblings map[int]map[int][]int, coreKey int) []string {
func GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings map[int]map[int][]int, coreId int) []string {
var cpuSiblings []string
for key := range numaCoreSiblings {
for _, c := range numaCoreSiblings[key][coreKey] {
cpuSiblings = append(cpuSiblings, strconv.Itoa(c))
delete(numaCoreSiblings[key], coreKey)
// Iterate over the Numa node in the map
for node := range numaCoreSiblings {
// Check if the coreId exists in the Numa node
_, ok := numaCoreSiblings[node][coreId]
if ok {
// Iterate over the siblings of the coreId
for _, sibling := range numaCoreSiblings[node][coreId] {
cpuSiblings = append(cpuSiblings, strconv.Itoa(sibling))
}
// Delete the cpusiblings of that particular coreid
delete(numaCoreSiblings[node], coreId)
}
}
return cpuSiblings
Expand Down