From 548ef43ca22715ce3a710d8d175da08efa2f756c Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 13 Feb 2020 14:32:24 +0000 Subject: [PATCH] tests: Use hugepages for test_vfio Using hugepages with VFIO and virtiofs can improve the performance of the test_vfio test. Signed-off-by: Rob Bradford (cherry picked from commit 5c9828a34ca128610939c6fc89bbb36c99034cff) --- scripts/run_integration_tests.sh | 4 ++++ src/main.rs | 2 +- test_data/cloud-init/clear/openstack/latest/user_data | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index bb5236666..f5d7d8154 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -173,6 +173,10 @@ sudo bash -c "echo 1 > /sys/kernel/mm/ksm/run" time cargo test --no-run --features "integration_tests" -- --nocapture ls target/debug/deps/cloud_hypervisor-* | xargs -n 1 sudo setcap cap_net_admin+ep +# test_vfio relies on hugepages +echo 4096 | sudo tee /proc/sys/vm/nr_hugepages +sudo chmod a+rwX /dev/hugepages + sudo adduser $USER kvm newgrp kvm << EOF export RUST_BACKTRACE=1 diff --git a/src/main.rs b/src/main.rs index 44f61c4d2..93d058330 100755 --- a/src/main.rs +++ b/src/main.rs @@ -3830,7 +3830,7 @@ mod tests { let mut child = Command::new("target/release/cloud-hypervisor") .args(&["--cpus", "boot=4"]) - .args(&["--memory", "size=1G,file=/dev/shm"]) + .args(&["--memory", "size=1G,file=/dev/hugepages"]) .args(&["--kernel", kernel_path.to_str().unwrap()]) .args(&[ "--disk", diff --git a/test_data/cloud-init/clear/openstack/latest/user_data b/test_data/cloud-init/clear/openstack/latest/user_data index e53352c63..c2c07ca1a 100644 --- a/test_data/cloud-init/clear/openstack/latest/user_data +++ b/test_data/cloud-init/clear/openstack/latest/user_data @@ -63,5 +63,7 @@ write_files: bash -c "echo 1af4 1041 > /sys/bus/pci/drivers/vfio-pci/new_id" bash -c "echo 0000:00:06.0 > /sys/bus/pci/devices/0000\:00\:06.0/driver/unbind" bash -c "echo 1af4 1041 > /sys/bus/pci/drivers/vfio-pci/new_id" - - /mnt/cloud-hypervisor --kernel /mnt/vmlinux --cmdline "console=hvc0 reboot=k panic=1 nomodules i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd root=/dev/vda2 VFIOTAG" --disk path=/mnt/clear-31310-cloudguest.img path=/mnt/cloudinit.img --cpus boot=1 --memory size=512M --device path=/sys/bus/pci/devices/0000:00:05.0/ path=/sys/bus/pci/devices/0000:00:06.0/ + # 512M ram requires 256 pages + echo 256 | sudo tee /proc/sys/vm/nr_hugepages + sudo chmod a+rwX /dev/hugepages + /mnt/cloud-hypervisor --kernel /mnt/vmlinux --cmdline "console=hvc0 reboot=k panic=1 nomodules i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd root=/dev/vda2 VFIOTAG" --disk path=/mnt/clear-31310-cloudguest.img path=/mnt/cloudinit.img --cpus boot=1 --memory size=512M,file=/dev/hugepages --device path=/sys/bus/pci/devices/0000:00:05.0/ path=/sys/bus/pci/devices/0000:00:06.0/