[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 <jmosher@mirantis.com>
This commit is contained in:
Jaymes Mosher
2025-12-10 18:43:09 +00:00
parent 2221cc2b32
commit b96f470e1c
3 changed files with 29 additions and 0 deletions

View File

@@ -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"

View File

@@ -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

View File

@@ -0,0 +1,6 @@
---
features:
- |
Add ability to override cpuset.mems and cpuset.cpus for osh-openvswitch
cgroup.
...