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