From df88838635d994adabe85238e0675a93edbdf523 Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Thu, 20 Feb 2025 16:01:17 +0200 Subject: [PATCH 1/4] balloons: add rdtClass balloon type option Signed-off-by: Antti Kervinen --- config/crd/bases/config.nri_balloonspolicies.yaml | 7 +++++++ .../helm/balloons/crds/config.nri_balloonspolicies.yaml | 7 +++++++ pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/config/crd/bases/config.nri_balloonspolicies.yaml b/config/crd/bases/config.nri_balloonspolicies.yaml index 619b5d423..0676f1e9d 100644 --- a/config/crd/bases/config.nri_balloonspolicies.yaml +++ b/config/crd/bases/config.nri_balloonspolicies.yaml @@ -268,6 +268,13 @@ spec: placed on separate balloons. The default is false: prefer placing containers of a pod to the same balloon(s). type: boolean + rdtClass: + description: |- + RdtClass controls RDT class of processes in the containers + of a balloon. The default is empty: no RDT class is set. If + defined, processes will be added to the directory + corresponding the class in the resctrl file system. + type: string shareIdleCPUsInSame: description: |- ShareIdleCpusInSame : if there are idle diff --git a/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml b/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml index 619b5d423..0676f1e9d 100644 --- a/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml +++ b/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml @@ -268,6 +268,13 @@ spec: placed on separate balloons. The default is false: prefer placing containers of a pod to the same balloon(s). type: boolean + rdtClass: + description: |- + RdtClass controls RDT class of processes in the containers + of a balloon. The default is empty: no RDT class is set. If + defined, processes will be added to the directory + corresponding the class in the resctrl file system. + type: string shareIdleCPUsInSame: description: |- ShareIdleCpusInSame : if there are idle diff --git a/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go b/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go index a14f07d06..481ea6f58 100644 --- a/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go +++ b/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go @@ -202,6 +202,11 @@ type BalloonDef struct { // CpuClass controls how CPUs of a balloon are (re)configured // whenever a balloon is created, inflated or deflated. CpuClass string `json:"cpuClass,omitempty"` + // RdtClass controls RDT class of processes in the containers + // of a balloon. The default is empty: no RDT class is set. If + // defined, processes will be added to the directory + // corresponding the class in the resctrl file system. + RdtClass string `json:"rdtClass,omitempty"` // MinBalloons is the number of balloon instances that always // exist even if they would become empty. At init this number // of instances will be created before assigning any From 75961e141d9c51df1275296c0bb0491d009c505b Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Thu, 20 Feb 2025 16:01:48 +0200 Subject: [PATCH 2/4] balloons: implement rdtClass balloons option Signed-off-by: Antti Kervinen --- cmd/plugins/balloons/policy/balloons-policy.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/plugins/balloons/policy/balloons-policy.go b/cmd/plugins/balloons/policy/balloons-policy.go index 9bf41540a..c0cc6b163 100644 --- a/cmd/plugins/balloons/policy/balloons-policy.go +++ b/cmd/plugins/balloons/policy/balloons-policy.go @@ -1679,6 +1679,9 @@ func (p *balloons) assignContainer(c cache.Container, bln *Balloon) { bln.PodIDs[podID] = append(bln.PodIDs[podID], c.GetID()) bln.updateGroups(c, 1) p.updatePinning(bln) + if bln.Def.RdtClass != "" { + c.SetRDTClass(bln.Def.RdtClass) + } } // dismissContainer removes a container from a balloon From 2c6812a8214203fcdf6e1e5d9f75d479f61a4a93 Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Thu, 20 Feb 2025 16:02:20 +0200 Subject: [PATCH 3/4] WIP: DO NOT MERGE: e2e: test balloons rdtClass option Signed-off-by: Antti Kervinen --- .../n4c16/test14-rdt/balloons-rdt.cfg | 23 +++++++++++++++++++ .../balloons/n4c16/test14-rdt/code.var.sh | 20 ++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/e2e/policies.test-suite/balloons/n4c16/test14-rdt/balloons-rdt.cfg create mode 100644 test/e2e/policies.test-suite/balloons/n4c16/test14-rdt/code.var.sh diff --git a/test/e2e/policies.test-suite/balloons/n4c16/test14-rdt/balloons-rdt.cfg b/test/e2e/policies.test-suite/balloons/n4c16/test14-rdt/balloons-rdt.cfg new file mode 100644 index 000000000..d438f4778 --- /dev/null +++ b/test/e2e/policies.test-suite/balloons/n4c16/test14-rdt/balloons-rdt.cfg @@ -0,0 +1,23 @@ +config: + allocatorTopologyBalancing: true + reservedResources: + cpu: 750m + pinCPU: false + pinMemory: false + balloonTypes: + - name: balloon-gold + rdtClass: rdt-class-gold + matchExpressions: + - key: name + operator: In + values: + - container-gold + log: + debug: + - resource-manager + - cache + - policy + - sysfs + source: true + klog: + skip_headers: true diff --git a/test/e2e/policies.test-suite/balloons/n4c16/test14-rdt/code.var.sh b/test/e2e/policies.test-suite/balloons/n4c16/test14-rdt/code.var.sh new file mode 100644 index 000000000..40b722389 --- /dev/null +++ b/test/e2e/policies.test-suite/balloons/n4c16/test14-rdt/code.var.sh @@ -0,0 +1,20 @@ +helm-terminate +helm_config=$TEST_DIR/balloons-rdt.cfg helm-launch balloons + +cleanup() { + vm-command "kubectl delete pods --all --now" + helm-terminate + vm-command "rm -f /var/lib/nri-resource-policy/cache" || true +} +cleanup + +# pod0c{0,1,2}: one container per free L2 group +CPUREQ="1500m" MEMREQ="100M" CPULIM="1500m" MEMLIM="100M" +POD_ANNOTATION="balloon.balloons.resource-policy.nri.io/container.pod0c1: balloon-gold" CONTCOUNT=3 create balloons-busybox +report allowed + +breakpoint +echo "DELME: forced to fail to avoid cleanup +exit 1 + +cleanup From c5d6aaac62bf1852219794fa780cb389ae6326e2 Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Fri, 21 Feb 2025 12:38:34 +0200 Subject: [PATCH 4/4] doc: add balloons rdtClass documentation Signed-off-by: Antti Kervinen --- docs/resource-policy/policy/balloons.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/resource-policy/policy/balloons.md b/docs/resource-policy/policy/balloons.md index 54e14cdd8..595165f23 100644 --- a/docs/resource-policy/policy/balloons.md +++ b/docs/resource-policy/policy/balloons.md @@ -188,6 +188,10 @@ Balloons policy parameters: - `cpuClass` specifies the name of the CPU class according to which CPUs of balloons are configured. Class properties are defined in separate `cpu.classes` objects, see below. + - `rdtClass` specifies the name of the RDT class. Corresponding + class of service (COS) must exist in the resctrl file + system. Containers in the balloon are assigned to the class. Refer + to resctrl file system for configuring classes. - `pinMemory` overrides policy-level `pinMemory` in balloons of this type. - `memoryTypes` is a list of allowed memory types for containers in