mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 07:21:15 +00:00
On Arm64, the fio binary that comes from ubuntu distribution cannot support io_uring, which is a required engine for the block performance tests in performance metrics. Therefore this commit build the fio from a relatively new version, and replace the native ubuntu fio with the newly build one. Signed-off-by: Henry Wang <Henry.Wang@arm.com>
151 lines
4.5 KiB
Bash
Executable File
151 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -x
|
|
|
|
source $HOME/.cargo/env
|
|
source $(dirname "$0")/test-util.sh
|
|
|
|
export TEST_ARCH=$(uname -m)
|
|
export BUILD_TARGET=${BUILD_TARGET-${TEST_ARCH}-unknown-linux-gnu}
|
|
|
|
|
|
WORKLOADS_DIR="$HOME/workloads"
|
|
mkdir -p "$WORKLOADS_DIR"
|
|
|
|
build_fio() {
|
|
FIO_DIR="$WORKLOADS_DIR/fio_build"
|
|
FIO_REPO="https://github.com/axboe/fio.git"
|
|
|
|
checkout_repo "$FIO_DIR" "$FIO_REPO" master "1953e1adb5a28ed21370e85991d7f5c3cdc699f3"
|
|
if [ ! -f "$FIO_DIR/.built" ]; then
|
|
pushd $FIO_DIR
|
|
./configure
|
|
make -j `nproc`
|
|
cp fio "$WORKLOADS_DIR/fio"
|
|
touch .built
|
|
popd
|
|
fi
|
|
}
|
|
|
|
process_common_args "$@"
|
|
|
|
# For now these values are default for kvm
|
|
features=""
|
|
|
|
if [ "$hypervisor" = "mshv" ]; then
|
|
features="--no-default-features --features mshv,common"
|
|
fi
|
|
|
|
cp scripts/sha1sums-${TEST_ARCH} $WORKLOADS_DIR
|
|
|
|
if [ ${TEST_ARCH} == "aarch64" ]; then
|
|
FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-arm64-custom-20210929-0.qcow2"
|
|
else
|
|
FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.qcow2"
|
|
fi
|
|
|
|
FOCAL_OS_IMAGE_URL="https://cloud-hypervisor.azureedge.net/$FOCAL_OS_IMAGE_NAME"
|
|
FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME"
|
|
if [ ! -f "$FOCAL_OS_IMAGE" ]; then
|
|
pushd $WORKLOADS_DIR
|
|
time wget --quiet $FOCAL_OS_IMAGE_URL || exit 1
|
|
popd
|
|
fi
|
|
|
|
if [ ${TEST_ARCH} == "aarch64" ]; then
|
|
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-arm64-custom-20210929-0.raw"
|
|
else
|
|
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.raw"
|
|
fi
|
|
|
|
FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
|
|
if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then
|
|
pushd $WORKLOADS_DIR
|
|
time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1
|
|
popd
|
|
fi
|
|
|
|
pushd $WORKLOADS_DIR
|
|
grep focal sha1sums-${TEST_ARCH} | sha1sum --check
|
|
if [ $? -ne 0 ]; then
|
|
echo "sha1sum validation of images failed, remove invalid images to fix the issue."
|
|
exit 1
|
|
fi
|
|
popd
|
|
|
|
if [ ${TEST_ARCH} == "aarch64" ]; then
|
|
build_fio
|
|
|
|
# Update the fio in the cloud image to use io_uring on AArch64
|
|
FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME="focal-server-cloudimg-arm64-custom-20210929-0-update-tool.raw"
|
|
cp "$FOCAL_OS_RAW_IMAGE" "$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME"
|
|
FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR="$WORKLOADS_DIR/focal-server-cloudimg-root"
|
|
if [ ! -d "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR" ]; then
|
|
mkdir -p "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR"
|
|
fi
|
|
# Mount the 'raw' image, replace the fio and umount the working folder
|
|
guestmount -a "$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME" -m /dev/sda1 "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR" || exit 1
|
|
cp "$WORKLOADS_DIR"/fio "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR"/usr/bin/fio
|
|
guestunmount "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR"
|
|
fi
|
|
|
|
# Build custom kernel based on virtio-pmem and virtio-fs upstream patches
|
|
if [ ${TEST_ARCH} == "aarch64" ]; then
|
|
VMLINUX_IMAGE="$WORKLOADS_DIR/Image"
|
|
else
|
|
VMLINUX_IMAGE="$WORKLOADS_DIR/vmlinux"
|
|
fi
|
|
|
|
LINUX_CUSTOM_DIR="$WORKLOADS_DIR/linux-custom"
|
|
|
|
if [ ! -f "$VMLINUX_IMAGE" ]; then
|
|
SRCDIR=$PWD
|
|
pushd $WORKLOADS_DIR
|
|
time git clone --depth 1 "https://github.com/cloud-hypervisor/linux.git" -b "ch-5.15.12" $LINUX_CUSTOM_DIR
|
|
cp $SRCDIR/resources/linux-config-${TEST_ARCH} $LINUX_CUSTOM_DIR/.config
|
|
popd
|
|
fi
|
|
|
|
if [ ! -f "$VMLINUX_IMAGE" ]; then
|
|
pushd $LINUX_CUSTOM_DIR
|
|
if [ ${TEST_ARCH} == "x86_64" ]; then
|
|
make bzImage -j `nproc`
|
|
cp vmlinux $VMLINUX_IMAGE || exit 1
|
|
elif [ ${TEST_ARCH} == "aarch64" ]; then
|
|
make Image -j `nproc`
|
|
cp arch/arm64/boot/Image $VMLINUX_IMAGE || exit 1
|
|
fi
|
|
popd
|
|
fi
|
|
|
|
if [ -d "$LINUX_CUSTOM_DIR" ]; then
|
|
rm -rf $LINUX_CUSTOM_DIR
|
|
fi
|
|
|
|
BUILD_TARGET="${TEST_ARCH}-unknown-linux-${CH_LIBC}"
|
|
CFLAGS=""
|
|
TARGET_CC=""
|
|
if [[ "${BUILD_TARGET}" == "${TEST_ARCH}-unknown-linux-musl" ]]; then
|
|
TARGET_CC="musl-gcc"
|
|
CFLAGS="-I /usr/include/${TEST_ARCH}-linux-musl/ -idirafter /usr/include/"
|
|
fi
|
|
|
|
cargo build --all --release $features --target $BUILD_TARGET
|
|
strip target/$BUILD_TARGET/release/cloud-hypervisor
|
|
strip target/$BUILD_TARGET/release/vhost_user_net
|
|
strip target/$BUILD_TARGET/release/ch-remote
|
|
strip target/$BUILD_TARGET/release/performance-metrics
|
|
|
|
# setup hugepages
|
|
echo 6144 | sudo tee /proc/sys/vm/nr_hugepages
|
|
sudo chmod a+rwX /dev/hugepages
|
|
|
|
if [ -n "$test_filter" ]; then
|
|
test_binary_args+=("--test-filter $test_filter")
|
|
fi
|
|
|
|
export RUST_BACKTRACE=1
|
|
time target/$BUILD_TARGET/release/performance-metrics ${test_binary_args[*]}
|
|
RES=$?
|
|
|
|
exit $RES
|