Commit 4e4b993a authored by SeungYeon Shin's avatar SeungYeon Shin Committed by Jim Harris
Browse files

test/scheduler: Add a system level test for the scheduler_set_option RPC



Change-Id: Ie9896285b7a037d6f17b18854485dea59d894729
Signed-off-by: default avatarSeungYeon Shin <syeon.shin@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23145


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 462fd69e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -419,6 +419,16 @@ exec_under_dynamic_scheduler() {
	"$rootdir/scripts/rpc.py" framework_start_init
}

exec_under_static_scheduler() {
	if [[ -e /proc/$spdk_pid/status ]]; then
		killprocess "$spdk_pid"
	fi
	"$@" --wait-for-rpc &
	spdk_pid=$!
	# Give some time for the app to init itself
	waitforlisten "$spdk_pid"
}

# Gather busy/idle stats since this function was last called
get_thread_stats_current() {
	xtrace_disable
+85 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
#  SPDX-License-Identifier: BSD-3-Clause
#  Copyright (C) 2021 Intel Corporation
#  Copyright (c) 2024 Samsung Electronics Corporation
#  All rights reserved.
#
testdir=$(readlink -f "$(dirname "$0")")
rootdir=$(readlink -f "$testdir/../../")

source "$rootdir/test/common/autotest_common.sh"
source "$testdir/common.sh"

trap 'killprocess "$spdk_pid"' EXIT

fold_list_onto_array cpus $(parse_cpu_list <(echo "$spdk_cpus_csv"))
# Normalize the indexes
cpus=("${cpus[@]}")
isolated_core=${cpus[1]}
scheduling_core=${cpus[2]}

set_scheduler_options() {
	local isolated_core_mask

	isolated_core_mask=$(mask_cpus ${isolated_core})
	rpc_cmd scheduler_set_options --scheduling-core ${scheduling_core} -i "${isolated_core_mask}"
}

set_scheduler_and_check_thread_status() {
	local isolated_thread_count tmp_count total_thread_count=0 idle_thread_count
	local core_mask reactors

	for cpu in "${cpus[@]}"; do
		core_mask=$(mask_cpus ${cpu})
		create_thread -n "thread${cpu}" -m "${core_mask}" -a 0
	done

	# Get current thread status. All threads are idle.
	reactors=$(rpc_cmd framework_get_reactors | jq -r '.reactors[]')
	isolated_thread_count=$(jq -r "select(.lcore == ${isolated_core}) | .lw_threads | length" <<< "$reactors")
	total_thread_count=$(echo "$reactors" | jq -r "select(.lcore) | .lw_threads | length" | awk '{s+=$1} END {print s}')

	rpc_cmd framework_set_scheduler dynamic

	reactors=$(rpc_cmd framework_get_reactors | jq -r '.reactors[]')
	isolated_thread_ids=($(echo "$reactors" | jq -r "select(.lcore == ${isolated_core}) | .lw_threads" | jq -r '.[].id'))

	# Check if isolated core's thread counts stay the same.
	tmp_count=$(jq -r "select(.lcore == ${isolated_core}) | .lw_threads | length" <<< "$reactors")
	((isolated_thread_count == tmp_count))

	# Check if rest of the idle threads are on the scheduling core.
	idle_thread_count=$(jq -r "select(.lcore == ${scheduling_core}) | .lw_threads| length" <<< "$reactors")
	tmp_count=$((total_thread_count - isolated_thread_count))

	# Make the thread on the isolated core busy and verify that it remains isolated.
	for thread_id in "${isolated_thread_ids[@]}"; do
		active_thread "$thread_id" 95
	done

	reactors=$(rpc_cmd framework_get_reactors | jq -r '.reactors[]')
	idle_thread_ids=($(echo "$reactors" | jq -r "select(.lcore == ${scheduling_core}) | .lw_threads" | jq -r '.[].id'))
	# Make the threads on the scheudling core busy and verify that they are distributed.
	for thread_id in "${idle_thread_ids[@]}"; do
		if ((thread_id == 1)); then
			continue
		fi
		active_thread "$thread_id" 80
	done
	sleep 20

	reactors=$(rpc_cmd framework_get_reactors | jq -r '.reactors[]')
	tmp_count=$(jq -r "select(.lcore == ${isolated_core}) | .lw_threads | length" <<< "$reactors")
	((isolated_thread_count == tmp_count))

	tmp_count=$(jq -r "select(.lcore == ${scheduling_core}) | .lw_threads| length" <<< "$reactors")
	((idle_thread_count >= tmp_count))
}

exec_under_static_scheduler "$scheduler" -m "$spdk_cpumask" --main-core "$spdk_main_core"

set_scheduler_options

rpc_cmd framework_start_init

set_scheduler_and_check_thread_status
+1 −0
Original line number Diff line number Diff line
@@ -16,3 +16,4 @@ run_test "idle" "$testdir/idle.sh"
#run_test "load_balancing" "$testdir/load_balancing.sh"
run_test "dpdk_governor" "$testdir/governor.sh"
run_test "interrupt_mode" "$testdir/interrupt.sh"
run_test "core_isolating" "$testdir/core_isolating.sh"