[PATCH stalld 32/36] tests/functional: Fix multi-CPU detection in test_starvation_detection
Wander Lairson Costa <[email protected]> Mon, 30 Mar 2026 16:43:55 -0300
| Newsgroups | org.kernel.vger.linux-rt-users |
|---|---|
| Message-ID | <[email protected]> |
The multi-CPU test greps for "starvation_gen" in the starvation log, but stalld might detect other starving tasks on the target CPU, such as kworker threads. Relax the grep to match any task starving on the expected CPU. To support this, add an optional cpu parameter to wait_for_starvation_detected() so the test waits for each CPU independently. Signed-off-by: Wander Lairson Costa <[email protected]> --- tests/functional/test_starvation_detection.sh | 12 +++++------- tests/helpers/test_helpers.sh | 9 +++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/functional/test_starvation_detection.sh b/tests/functional/test_starvation_detection.sh index 680cf39..6ca2121 100755 --- a/tests/functional/test_starvation_detection.sh +++ b/tests/functional/test_starvation_detection.sh @@ -271,18 +271,16 @@ else start_stalld_with_log "${STALLD_LOG}" -f -v -N -l -t $threshold -c ${CPU0},${CPU1} -a ${STALLD_CPU_MULTI} - # Wait for starvation detection - log "Waiting for starvation detection..." - wait_for_starvation_detected "${STALLD_LOG}" - - # Check both CPUs detected - specifically look for starvation_gen tasks - if grep -qE "starvation_gen.*starved on CPU ${CPU0}|starved on CPU ${CPU0}.*starvation_gen" "${STALLD_LOG}"; then + # Wait for starvation detection on both CPUs + log "Waiting for starvation detection on CPU ${CPU0}..." + if wait_for_starvation_detected "${STALLD_LOG}" 30 "${CPU0}"; then pass "Starvation detected on CPU ${CPU0}" else fail "Starvation not detected on CPU ${CPU0}" fi - if grep -qE "starvation_gen.*starved on CPU ${CPU1}|starved on CPU ${CPU1}.*starvation_gen" "${STALLD_LOG}"; then + log "Waiting for starvation detection on CPU ${CPU1}..." + if wait_for_starvation_detected "${STALLD_LOG}" 30 "${CPU1}"; then pass "Starvation detected on CPU ${CPU1}" else fail "Starvation not detected on CPU ${CPU1}" diff --git a/tests/helpers/test_helpers.sh b/tests/helpers/test_helpers.sh index 3a7164d..6e29a3b 100755 --- a/tests/helpers/test_helpers.sh +++ b/tests/helpers/test_helpers.sh @@ -542,11 +542,16 @@ wait_for_stalld_ready() { # Wait for stalld to detect a starving task. # -# Usage: wait_for_starvation_detected <log_file> [timeout] +# Usage: wait_for_starvation_detected <log_file> [timeout] [cpu] wait_for_starvation_detected() { local log_file=$1 local timeout=${2:-30} - wait_for_log_message "starved on CPU" "${timeout}" "${log_file}" + local cpu=${3:-} + local pattern="starved on CPU" + if [ -n "${cpu}" ]; then + pattern="starved on CPU ${cpu}" + fi + wait_for_log_message "${pattern}" "${timeout}" "${log_file}" } # Wait for stalld to boost a starving task. -- 2.53.0