Commit 19377d66 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

test/scheduler: measure ticks since last check



get_thread_stats() gathers busy/idle from start of
the application, directly from RPC.
For some tests it is not required to measure state
from app start, but only changes during test.

idle.sh assumes that second check would make all
threads idle. Yet if initialization takes long enough,
app_thread will not be idle longer than it was busy by then.
This became apparent when adding ASAN to all jobs,
which considerably increased start up time.

To fix that, only measure ticks between consecutive RPC calls.
Added get_thread_stats_current() that returns busy/idle
difference, since last time it was called.

It allows to remove the workaround for first sample,
per removed comment.

While here:
- added print with load/busy/idle for each thread
- fixed unlikely condition for idle[thread] == busy[thread]

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Iaacce31aa7d4bcc22a51dbd7e71a4c7a4d274862
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20884


Reviewed-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 8cd4cc63
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -406,6 +406,22 @@ exec_under_dynamic_scheduler() {
	"$rootdir/scripts/rpc.py" framework_start_init
}

# Gather busy/idle stats since this function was last called
get_thread_stats_current() {
	xtrace_disable

	local total_busy total_idle

	_get_thread_stats total_busy total_idle

	for thread in "${!thread_map[@]}"; do
		: $((busy[thread] = total_busy[thread] - past_busy[thread], past_busy[thread] = total_busy[thread]))
		: $((idle[thread] = total_idle[thread] - past_idle[thread], past_idle[thread] = total_idle[thread]))
	done
	xtrace_restore
}

# Gather busy/idle stats since application start
get_thread_stats() {
	xtrace_disable
	_get_thread_stats busy idle
+10 −7
Original line number Diff line number Diff line
@@ -13,17 +13,20 @@ source "$testdir/common.sh"
trap 'killprocess "$spdk_pid"' EXIT

thread_stats() {
	local thread
	local thread load
	busy_threads=0

	get_thread_stats
	get_thread_stats_current

	# Simply verify if threads stay idle
	for thread in "${!thread_map[@]}"; do
		printf '[load:%3u%%, idle:%10u, busy:%10u] ' \
			$((busy[thread] * 100 / (busy[thread] + idle[thread]))) \
			"${idle[thread]}" "${busy[thread]}"
		if ((idle[thread] < busy[thread])); then
			printf 'Waiting for %s to become idle\n' "${thread_map[thread]}"
			((++busy_threads))
		elif ((idle[thread] > busy[thread])); then
		else
			printf '%s is idle\n' "${thread_map[thread]}"
		fi
	done
@@ -41,6 +44,9 @@ idle() {
	# - all threads are assigned to main lcore
	# - threads are not being moved between lcores

	# Get first set of stats, to exclude initialization from the busy/idle
	get_thread_stats_current

	xtrace_disable
	while ((samples++ < 5)); do
		cpumask=0
@@ -56,10 +62,7 @@ idle() {

		thread_stats

		# Allow app_thread is busy for the first sample. Because on some system the dpdk_governor
		# initiation process on app_thread is time consuming. This may make the busy time greater
		# than idle time which causes the test to fail.
		((samples == 1 && busy_threads <= 1 || samples > 1 && busy_threads == 0))
		((busy_threads == 0))
	done

	xtrace_restore