Skip to content

Commit 3f74812

Browse files
author
Niranjan M.R
committed
Use L3 Cache group associated with cpu 0 as reserved
Use cpuset.CPUSet type for all reserved, isolated variables when modifying performance profile Signed-off-by: Niranjan M.R <[email protected]>
1 parent 102789c commit 3f74812

File tree

1 file changed

+18
-32
lines changed
  • test/e2e/performanceprofile/functests/13_llc

1 file changed

+18
-32
lines changed

test/e2e/performanceprofile/functests/13_llc/llc.go

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"encoding/json"
77
"fmt"
88
"strconv"
9-
"strings"
109
"time"
1110

1211
. "github.com/onsi/ginkgo/v2"
@@ -79,7 +78,7 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
7978

8079
perfProfile, err = profiles.GetByNodeLabels(testutils.NodeSelectorLabels)
8180
Expect(err).ToNot(HaveOccurred())
82-
initialProfile = perfProfile.DeepCopy()
81+
//initialProfile = perfProfile.DeepCopy()
8382

8483
getter, err = cgroup.BuildGetter(ctx, testclient.DataPlaneClient, testclient.K8sClient)
8584
Expect(err).ToNot(HaveOccurred())
@@ -128,11 +127,11 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
128127
}
129128
})
130129

131-
AfterAll(func() {
130+
AfterAll(func(ctx context.Context) {
132131

133132
// Delete machine config created to enable uncocre cache cpumanager policy option
134133
// first make sure the profile doesn't have the annotation
135-
ctx := context.Background()
134+
By("Reverting Performance Profile")
136135
perfProfile, err = profiles.GetByNodeLabels(testutils.NodeSelectorLabels)
137136
perfProfile.Annotations = nil
138137
By("updating performance profile")
@@ -218,9 +217,9 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
218217
var L3CacheGroupSize int
219218
BeforeAll(func() {
220219
var (
221-
numaCoreSiblings map[int]map[int][]int
222-
reserved, isolated []string
220+
reserved, isolated cpuset.CPUSet
223221
policy = "single-numa-node"
222+
onlineCPUSet cpuset.CPUSet
224223
)
225224
profile, err := profiles.GetByNodeLabels(testutils.NodeSelectorLabels)
226225
Expect(err).ToNot(HaveOccurred())
@@ -233,36 +232,22 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
233232
}
234233

235234
getCCX := nodes.GetL3SharedCPUs(&cnfnode)
236-
cpus, err := getCCX(0)
235+
reserved, err = getCCX(0)
236+
Expect(err).ToNot(HaveOccurred())
237+
onlineCPUSet, err = nodes.GetOnlineCPUsSet(context.TODO(), &cnfnode)
237238
Expect(err).ToNot(HaveOccurred())
238-
L3CacheGroupSize = cpus.Size()
239+
L3CacheGroupSize = reserved.Size()
239240
if len(numaInfo[0]) == L3CacheGroupSize {
240241
Skip("This test requires systems where L3 cache is shared amount subset of cpus")
241242
}
242243
}
244+
testlog.Info("Modifying profile with reserved cpus %s and isolated cpus %s", reserved.String(), isolated.String())
243245
// Modify the profile such that we give 1 whole ccx to reserved cpus
244246
By("Modifying the profile")
245-
for _, node := range workerRTNodes {
246-
numaCoreSiblings, err = nodes.GetCoreSiblings(ctx, &node)
247-
Expect(err).ToNot(HaveOccurred())
248-
}
249-
250-
// Get cpu siblings from core 0-7
251-
// Assign one whole L3 Cache group for reserved cpus.
252-
for reservedCores := 0; reservedCores < 8; reservedCores++ {
253-
cpusiblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, reservedCores)
254-
reserved = append(reserved, cpusiblings...)
255-
}
256-
reservedCpus := strings.Join(reserved, ",")
257-
for key := range numaCoreSiblings {
258-
for k := range numaCoreSiblings[key] {
259-
cpusiblings := nodes.GetAndRemoveCpuSiblingsFromMap(numaCoreSiblings, k)
260-
isolated = append(isolated, cpusiblings...)
261-
}
262-
}
263-
isolatedCpus := strings.Join(isolated, ",")
264-
reservedSet := performancev2.CPUSet(reservedCpus)
265-
isolatedSet := performancev2.CPUSet(isolatedCpus)
247+
isolated = onlineCPUSet.Difference(reserved)
248+
reservedSet := performancev2.CPUSet(reserved.String())
249+
isolatedSet := performancev2.CPUSet(isolated.String())
250+
testlog.Info("Modifying profile with reserved cpus %s and isolated cpus %s", reserved.String(), isolated.String())
266251
profile.Spec.CPU = &performancev2.CPU{
267252
Reserved: &reservedSet,
268253
Isolated: &isolatedSet,
@@ -287,7 +272,7 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
287272
})
288273
})
289274

290-
It("[test_id:77725] Align Guaranteed pod requesting 16 cpus to the whole CCX if available", func(ctx context.Context) {
275+
It("[test_id:77725] Align Guaranteed pod requesting L3Cache group size cpus", Label("llc1"), func(ctx context.Context) {
291276
podLabel := make(map[string]string)
292277
targetNode := workerRTNodes[0]
293278
cpusetCfg := &controller.CpuSet{}
@@ -502,18 +487,19 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
502487
testlog.TaggedInfof("L3 Cache Group", "L3 Cache group associated with Pod %s using cpu %d is: %q", testpod.Name, cgroupCpuset.List()[0], cpus)
503488
})
504489

505-
It("[test_id:77726] Multiple Pods are not sharing same L3 cache", func(ctx context.Context) {
490+
It("[test_id:77726] Multiple Pods can share same L3 cache", func(ctx context.Context) {
506491
targetNode := workerRTNodes[0]
507492
// create 2 deployments creating 2 gu pods asking for 8 cpus each
508493
cpusetCfg := &controller.CpuSet{}
509494
var cpusetList []cpuset.CPUSet
510495
var dpList []*appsv1.Deployment
511496
podLabel := make(map[string]string)
497+
podCpuSize := strconv.Itoa(L3CacheGroupSize / 2)
512498
getCCX := nodes.GetL3SharedCPUs(&targetNode)
513499
for i := 0; i < 2; i++ {
514500
deploymentName := fmt.Sprintf("test-deployment%d", i)
515501
rl := &corev1.ResourceList{
516-
corev1.ResourceCPU: resource.MustParse("8"),
502+
corev1.ResourceCPU: resource.MustParse(podCpuSize),
517503
corev1.ResourceMemory: resource.MustParse("100Mi"),
518504
}
519505
podLabel := make(map[string]string)

0 commit comments

Comments
 (0)