1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (C) 2022 Intel Corporation 4# All rights reserved. 5# 6 7shopt -s nullglob extglob 8 9curdir=$(readlink -f "$(dirname "$0")") 10rootdir=$(readlink -f "$curdir/../../../") 11 12source "$rootdir/test/vhost/common.sh" 13 14# Allow for the fio_conf() to slurp extra config from the stdin. 15exec {fio_extra_conf}<&0 16 17fio_conf() { 18 cat <<- FIO 19 [global] 20 ioengine=${ioengine:-libaio} 21 thread=1 22 group_reporting=1 23 direct=1 24 verify=0 25 norandommap=1 26 FIO 27 28 if [[ $ioengine == io_uring ]]; then 29 cat <<- FIO_URING 30 fixedbufs=${fixedbufs:-1} 31 hipri=${hipri:-1} 32 registerfiles=${registerfiles:-1} 33 sqthread_poll=${sqthread_poll:-1} 34 FIO_URING 35 fi 36 37 if [[ -e $fio_extra_conf ]]; then 38 # Overridden through cmdline|env 39 cat "$fio_extra_conf" 40 elif [[ ! -t $fio_extra_conf ]]; then 41 # Attached to stdin 42 cat <&"$fio_extra_conf" 43 fi 44 45 cat <<- FIO 46 [perf_test] 47 stonewall 48 description="Vhost performance test for a given workload" 49 bs=${blksize:-4k} 50 rw=${rw:-randread} 51 rwmixread=${rwmixread:-70} 52 iodepth=${iodepth:-128} 53 time_based=1 54 ramp_time=${ramptime:-10} 55 runtime=${runtime:-10} 56 numjobs=${numjobs:-1} 57 # This option is meant to be sed'ed by the vhost's run_fio() 58 filename= 59 FIO 60} 61 62(($#)) && eval "$*" 63 64perf_args+=("--vm-image=${vm_image:-$VM_IMAGE}") 65perf_args+=("--ctrl-type=${ctrl_type:-spdk_vhost_scsi}") 66perf_args+=(${split:+--use-split}) 67perf_args+=(${disk_map:+--disk-map="$disk_map"}) 68perf_args+=(${cpu_cfg:+--custom-cpu-cfg="$cpu_cfg"}) 69 70if [[ $auto_cfg == yes || $auto_cfg_print == yes ]]; then 71 if [[ $auto_cfg_print == yes ]]; then 72 "$curdir/conf-generator" -p all || exit 1 73 exit 0 74 fi 75 cpu_out=$curdir/auto-cpu.conf disk_out=$curdir/auto-disk.conf \ 76 "$curdir/conf-generator" -s || exit 1 77 perf_args+=("--disk-map=$disk_out") 78 perf_args+=("--custom-cpu-cfg=$cpu_out") 79fi 80 81if [[ -n $extra_params ]]; then 82 perf_args+=($extra_params) 83fi 84 85out_fio_conf=${out_fio_conf:-$curdir/fio.conf} 86fio_conf > "$out_fio_conf" 87 88[[ -z $only_fio_conf ]] || exit 0 89 90trap 'rm -f "$out_fio_conf"' EXIT 91 92"$rootdir/test/vhost/perf_bench/vhost_perf.sh" \ 93 "${perf_args[@]}" --fio-jobs="$out_fio_conf"${fio_jobs:+",$fio_jobs"} 94