Commit 06243cb0 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

scripts/perf/pm: Add minimal FreeBSD support to vmstat collector



Change-Id: If30ba474193c24c610bfc4619525726c46516dcc
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21548


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent fdea5c6d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -48,9 +48,10 @@ if [ $(uname -s) = Linux ]; then
		udevadm_pid=$!
	fi

	start_monitor_resources
fi

start_monitor_resources

trap "autotest_cleanup || :; exit 1" SIGINT SIGTERM EXIT

timing_enter autotest
+32 −13
Original line number Diff line number Diff line
@@ -30,38 +30,57 @@ help() {
	HELP
}

get_extra_meminfo() {
get_extra_info() {
	local match="" data

	case "$PM_OS" in
		Linux)
			match+="|MemAvailable"
			match+="|Shmem"
			match+="|HugePages_(Total|Free)"
			match+="|Hugepagesize"

			data=($(grep -E "^($match):" /proc/meminfo | awk '{print $2}'))
			;&
		*) data+=("$TEST_TAG") ;;
	esac
	echo "${data[*]}"
}

set_extra_info_header() {
	local -n header_ref=$1
	local _header

	# Keep the header ordered as in get_extra_info()
	case "$PM_OS" in
		Linux) _header="avail shmem hp_total hp_free hp_size test" ;;
		FreeBSD) _header="test" ;;
	esac

	header_ref[0]="${header_ref[0]} ----extra info----"
	header_ref[1]="${header_ref[1]} $_header"
}

_vmstat() {
	local count=$1 interval=$2 reprint_header=${3:-20} _count
	local vmstat _vmstat stat_idx header=()
	local vmstat vmstat_cmdline=() _vmstat stat_idx header=()

	[[ $PM_OS == Linux ]] && vmstat_cmdline+=(--timestamp)

	_count=$count
	while ((stat_idx = stat_idx == reprint_header ? 1 : ++stat_idx, count <= 0 ? 1 : _count--)); do
		mapfile -t vmstat < <(vmstat --timestamp)
		mapfile -t vmstat < <(vmstat "${vmstat_cmdline[@]}")
		# Enhance output to include stuff we are most interested in
		vmstat[2]="${vmstat[2]} $(get_extra_meminfo) (test:$TEST_TAG)"
		vmstat[2]="${vmstat[2]} $(get_extra_info)"
		if ((stat_idx == 1)); then
			header=("${vmstat[@]::2}")
			header[0]="${header[0]}     ----extra memory----"
			# Keep the header ordered as in get_extra_meminfo()
			header[1]="${header[1]}     avail shmem hp_total hp_free hp_size"
			set_extra_info_header header
			_vmstat=("${header[@]}" "${vmstat[2]}")
		else
			_vmstat=("${vmstat[2]}")
		fi
		printf '%s\n' "${_vmstat[@]}"
		sleep "${interval}s"
		sleep "${interval}"
	done
}

+4 −3
Original line number Diff line number Diff line
@@ -68,11 +68,12 @@ TEST_TAG=${TEST_TAG:-N/A}
TEST_TAG_FILE=${TEST_TAG_FILE:-"$_pmrootdir/.run_test_name"}
# autotest's $output_dir has a prio
PM_OUTPUTDIR=${output_dir:-/tmp}/power
PM_OS=$(uname -s)

MONITOR_RESOURCES=(collect-cpu-load collect-vmstat)
if [[ $(uname -s) != Linux ]]; then
	MONITOR_RESOURCES=()
elif [[ $(< /sys/class/dmi/id/chassis_vendor) != QEMU && ! -e /.dockerenv ]]; then
if [[ $PM_OS == FreeBSD ]]; then
	MONITOR_RESOURCES=(collect-vmstat)
elif [[ $PM_OS == Linux && $(< /sys/class/dmi/id/chassis_vendor) != QEMU && ! -e /.dockerenv ]]; then
	# These are dedicated for the PHY platforms. Skip VMs and systems which identifies as
	# a docker containers (latter is specific to our CI's use-case).
	MONITOR_RESOURCES+=(collect-cpu-temp)