2020-12-29 13:55:28 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-11-02 15:49:40 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright (C) 2020 Intel Corporation
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2020-12-29 13:55:28 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
thread_stats() {
|
|
|
|
local thread
|
2023-02-16 08:08:53 +00:00
|
|
|
busy_threads=0
|
2020-12-29 13:55:28 +00:00
|
|
|
|
|
|
|
get_thread_stats
|
|
|
|
|
|
|
|
# Simply verify if threads stay idle
|
|
|
|
for thread in "${!thread_map[@]}"; do
|
|
|
|
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
|
|
|
|
printf '%s is idle\n' "${thread_map[thread]}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
idle() {
|
|
|
|
local reactor_framework
|
|
|
|
local reactors thread
|
2023-01-30 16:10:38 +00:00
|
|
|
local thread_cpumask
|
2020-12-29 13:55:28 +00:00
|
|
|
local threads
|
|
|
|
|
2021-11-25 01:40:59 +00:00
|
|
|
exec_under_dynamic_scheduler "${SPDK_APP[@]}" -m "$spdk_cpumask" --main-core "$spdk_main_core"
|
2020-12-29 13:55:28 +00:00
|
|
|
|
|
|
|
# The expectation here is that when SPDK app is idle the following is true:
|
|
|
|
# - all threads are assigned to main lcore
|
|
|
|
# - threads are not being moved between lcores
|
|
|
|
|
|
|
|
xtrace_disable
|
|
|
|
while ((samples++ < 5)); do
|
2021-11-25 01:40:59 +00:00
|
|
|
cpumask=0
|
2020-12-29 13:55:28 +00:00
|
|
|
reactor_framework=$(rpc_cmd framework_get_reactors | jq -r '.reactors[]')
|
|
|
|
threads=($(
|
|
|
|
jq -r "select(.lcore == $spdk_main_core) | .lw_threads[].name" <<< "$reactor_framework"
|
|
|
|
))
|
|
|
|
|
|
|
|
for thread in "${threads[@]}"; do
|
|
|
|
thread_cpumask=0x$(jq -r "select(.lcore == $spdk_main_core) | .lw_threads[] | select(.name == \"$thread\") | .cpumask" <<< "$reactor_framework")
|
2023-01-30 16:10:38 +00:00
|
|
|
printf 'SPDK cpumask: %s Thread %s cpumask: %s\n' "$spdk_cpumask" "$thread" "$thread_cpumask"
|
2020-12-29 13:55:28 +00:00
|
|
|
done
|
|
|
|
|
2021-03-23 11:10:10 +00:00
|
|
|
thread_stats
|
2023-02-16 08:08:53 +00:00
|
|
|
|
|
|
|
# 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))
|
2020-12-29 13:55:28 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
xtrace_restore
|
|
|
|
}
|
|
|
|
|
|
|
|
idle
|