6
6
"encoding/json"
7
7
"fmt"
8
8
"strconv"
9
- "strings"
10
9
"time"
11
10
12
11
. "github.com/onsi/ginkgo/v2"
@@ -79,7 +78,7 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
79
78
80
79
perfProfile , err = profiles .GetByNodeLabels (testutils .NodeSelectorLabels )
81
80
Expect (err ).ToNot (HaveOccurred ())
82
- initialProfile = perfProfile .DeepCopy ()
81
+ // initialProfile = perfProfile.DeepCopy()
83
82
84
83
getter , err = cgroup .BuildGetter (ctx , testclient .DataPlaneClient , testclient .K8sClient )
85
84
Expect (err ).ToNot (HaveOccurred ())
@@ -128,11 +127,11 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
128
127
}
129
128
})
130
129
131
- AfterAll (func () {
130
+ AfterAll (func (ctx context. Context ) {
132
131
133
132
// Delete machine config created to enable uncocre cache cpumanager policy option
134
133
// first make sure the profile doesn't have the annotation
135
- ctx := context . Background ( )
134
+ By ( "Reverting Performance Profile" )
136
135
perfProfile , err = profiles .GetByNodeLabels (testutils .NodeSelectorLabels )
137
136
perfProfile .Annotations = nil
138
137
By ("updating performance profile" )
@@ -218,9 +217,9 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
218
217
var L3CacheGroupSize int
219
218
BeforeAll (func () {
220
219
var (
221
- numaCoreSiblings map [int ]map [int ][]int
222
- reserved , isolated []string
220
+ reserved , isolated cpuset.CPUSet
223
221
policy = "single-numa-node"
222
+ onlineCPUSet cpuset.CPUSet
224
223
)
225
224
profile , err := profiles .GetByNodeLabels (testutils .NodeSelectorLabels )
226
225
Expect (err ).ToNot (HaveOccurred ())
@@ -233,36 +232,22 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
233
232
}
234
233
235
234
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 )
237
238
Expect (err ).ToNot (HaveOccurred ())
238
- L3CacheGroupSize = cpus .Size ()
239
+ L3CacheGroupSize = reserved .Size ()
239
240
if len (numaInfo [0 ]) == L3CacheGroupSize {
240
241
Skip ("This test requires systems where L3 cache is shared amount subset of cpus" )
241
242
}
242
243
}
244
+ testlog .Info ("Modifying profile with reserved cpus %s and isolated cpus %s" , reserved .String (), isolated .String ())
243
245
// Modify the profile such that we give 1 whole ccx to reserved cpus
244
246
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 ())
266
251
profile .Spec .CPU = & performancev2.CPU {
267
252
Reserved : & reservedSet ,
268
253
Isolated : & isolatedSet ,
@@ -287,7 +272,7 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
287
272
})
288
273
})
289
274
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 ) {
291
276
podLabel := make (map [string ]string )
292
277
targetNode := workerRTNodes [0 ]
293
278
cpusetCfg := & controller.CpuSet {}
@@ -502,18 +487,19 @@ var _ = Describe("[rfe_id:77446] LLC-aware cpu pinning", Label(string(label.Open
502
487
testlog .TaggedInfof ("L3 Cache Group" , "L3 Cache group associated with Pod %s using cpu %d is: %q" , testpod .Name , cgroupCpuset .List ()[0 ], cpus )
503
488
})
504
489
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 ) {
506
491
targetNode := workerRTNodes [0 ]
507
492
// create 2 deployments creating 2 gu pods asking for 8 cpus each
508
493
cpusetCfg := & controller.CpuSet {}
509
494
var cpusetList []cpuset.CPUSet
510
495
var dpList []* appsv1.Deployment
511
496
podLabel := make (map [string ]string )
497
+ podCpuSize := strconv .Itoa (L3CacheGroupSize / 2 )
512
498
getCCX := nodes .GetL3SharedCPUs (& targetNode )
513
499
for i := 0 ; i < 2 ; i ++ {
514
500
deploymentName := fmt .Sprintf ("test-deployment%d" , i )
515
501
rl := & corev1.ResourceList {
516
- corev1 .ResourceCPU : resource .MustParse ("8" ),
502
+ corev1 .ResourceCPU : resource .MustParse (podCpuSize ),
517
503
corev1 .ResourceMemory : resource .MustParse ("100Mi" ),
518
504
}
519
505
podLabel := make (map [string ]string )
0 commit comments