test/vhost_perf: detect cgroups version

Detect which cgroups version is used to set IO
throttling in the guest system.

Change-Id: I4e7f482a8590dfe59da461cf5ef0a557b508fa98
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5981
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Karol Latecki 2021-01-19 08:47:19 +01:00 committed by Tomasz Zawadzki
parent 288805a00e
commit 0773af993a

View File

@ -395,10 +395,23 @@ for vm_num in $used_vms; do
fi
if [[ -n "$vm_throttle" ]]; then
# Check whether cgroups or cgroupsv2 is used on guest system
# Simple, naive & quick approach as it should do the trick for simple
# VMs used for performance tests
c_gr_ver=2
if vm_exec "$vm_num" "grep '^cgroup ' /proc/mounts"; then
c_gr_ver=1
fi
block=$(printf '%s' $SCSI_DISK)
major_minor=$(vm_exec "$vm_num" "cat /sys/block/$block/dev")
vm_exec "$vm_num" "echo \"$major_minor $vm_throttle\" > /sys/fs/cgroup/blkio/blkio.throttle.read_iops_device"
vm_exec "$vm_num" "echo \"$major_minor $vm_throttle\" > /sys/fs/cgroup/blkio/blkio.throttle.write_iops_device"
if [[ $c_gr_ver == 1 ]]; then
vm_exec "$vm_num" "echo \"$major_minor $vm_throttle\" > /sys/fs/cgroup/blkio/blkio.throttle.read_iops_device"
vm_exec "$vm_num" "echo \"$major_minor $vm_throttle\" > /sys/fs/cgroup/blkio/blkio.throttle.write_iops_device"
elif [[ $c_gr_ver == 2 ]]; then
vm_exec "$vm_num" "echo '+io' > /sys/fs/cgroup/cgroup.subtree_control"
vm_exec "$vm_num" "echo \"$major_minor riops=$vm_throttle wiops=$vm_throttle\" > /sys/fs/cgroup/user.slice/io.max"
fi
fi
fio_disks+=" --vm=${vm_num}$(printf ':/dev/%s' $SCSI_DISK)"