From b96f470e1c3c568df96a20ef5a7a63a05ef72795 Mon Sep 17 00:00:00 2001 From: Jaymes Mosher Date: Wed, 10 Dec 2025 18:43:09 +0000 Subject: [PATCH] [openvswitch] Add ability to override cgroup settings Add config options to override cpuset.mems and cpuset.cpus for the osh-openvswitch cgroup. Change-Id: Ia028659f9f0976a629eddd7de14505e329c4a01c Signed-off-by: Jaymes Mosher --- .../templates/bin/_openvswitch-vswitchd.sh.tpl | 16 ++++++++++++++++ openvswitch/values.yaml | 7 +++++++ .../notes/openvswitch-63f74f08815529dd.yaml | 6 ++++++ 3 files changed, 29 insertions(+) create mode 100644 releasenotes/notes/openvswitch-63f74f08815529dd.yaml diff --git a/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl b/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl index 89f882a321..95da320933 100644 --- a/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl +++ b/openvswitch/templates/bin/_openvswitch-vswitchd.sh.tpl @@ -89,8 +89,16 @@ function start () { # Ensure the write target for the for cpuset.mem for the pod exists if [[ -f "$target_mems" && -f "$target_cpus" ]]; then # Write cpuset.mem and cpuset.cpus for new cgroup and add current task to new cgroup +{{- if hasKey .Values.conf.ovs_dpdk "cgroup_cpuset_mems" }} + echo "{{ .Values.conf.ovs_dpdk.cgroup_cpuset_mems }}" > "$target_mems" +{{- else }} cat /sys/fs/cgroup/cpuset.mems.effective > "$target_mems" +{{- end }} +{{- if hasKey .Values.conf.ovs_dpdk "cgroup_cpuset_cpus" }} + echo "{{ .Values.conf.ovs_dpdk.cgroup_cpuset_cpus }}" > "$target_cpus" +{{- else }} cat /sys/fs/cgroup/cpuset.cpus.effective > "$target_cpus" +{{- end }} echo $$ > /sys/fs/cgroup/osh-openvswitch/cgroup.procs else echo "ERROR: Could not find write target for either cpuset.mems: $target_mems or cpuset.cpus: $target_cpus" @@ -104,8 +112,16 @@ function start () { # Ensure the write target for the for cpuset.mem for the pod exists if [[ -f "$target_mems" && -f "$target_cpus" ]]; then # Write cpuset.mem and cpuset.cpus for new cgroup and add current task to new cgroup +{{- if hasKey .Values.conf.ovs_dpdk "cgroup_cpuset_mems" }} + echo "{{ .Values.conf.ovs_dpdk.cgroup_cpuset_mems }}" > "$target_mems" +{{- else }} cat /sys/fs/cgroup/cpuset/cpuset.mems > "$target_mems" +{{- end }} +{{- if hasKey .Values.conf.ovs_dpdk "cgroup_cpuset_cpus" }} + echo "{{ .Values.conf.ovs_dpdk.cgroup_cpuset_cpus }}" > "$target_cpus" +{{- else }} cat /sys/fs/cgroup/cpuset/cpuset.cpus > "$target_cpus" +{{- end }} echo $$ > /sys/fs/cgroup/cpuset/osh-openvswitch/tasks else echo "ERROR: Could not find write target for either cpuset.mems: $target_mems or cpuset.cpus: $target_cpus" diff --git a/openvswitch/values.yaml b/openvswitch/values.yaml index 5c39ac49e4..d7e3f2ae17 100644 --- a/openvswitch/values.yaml +++ b/openvswitch/values.yaml @@ -241,6 +241,13 @@ conf: # vHost IOMMU feature restricts the vhost memory that a virtio device # access, available with DPDK v17.11 # vhost_iommu_support: true + # + ## Optional cgroups cpuset mems/cpus override + ## The default is to copy the values from root cgroup, cpuset.mems.effective + ## and cpuset.cpus.effective. + ## Note: cgroup only created if lcore_mask or pmd_cpu_mask is set + # cgroup_cpuset_mems: some_list_of_memory_nodes + # cgroup_cpuset_cpus: some_list_of_cpus ## OVS supports run in non-root for both OVS and OVS DPDK mode, the user # for OVS need to be added to container image with user id 42424. # useradd -u 42424 openvswitch; groupmod -g 42424 openvswitch diff --git a/releasenotes/notes/openvswitch-63f74f08815529dd.yaml b/releasenotes/notes/openvswitch-63f74f08815529dd.yaml new file mode 100644 index 0000000000..6dd3273b46 --- /dev/null +++ b/releasenotes/notes/openvswitch-63f74f08815529dd.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Add ability to override cpuset.mems and cpuset.cpus for osh-openvswitch + cgroup. +...