From b0319223ef35df5eb1615f2d8178992b9adc6ef0 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Mon, 30 Nov 2020 16:23:19 -0800 Subject: [PATCH 1/2] multiple-pipeline: explicit tmp_count initialization Break the strange dependency between how many processes to start and how many were found in the previous run. Also move it next to func_run_pipeline_with_type() to make it clearer it's actually a parameter of that function. Signed-off-by: Marc Herbert --- test-case/multiple-pipeline.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-case/multiple-pipeline.sh b/test-case/multiple-pipeline.sh index a74d0339..2fc0e88a 100755 --- a/test-case/multiple-pipeline.sh +++ b/test-case/multiple-pipeline.sh @@ -66,8 +66,6 @@ DEV_LST['playback']='/dev/zero' APP_LST['capture']='arecord_opts' DEV_LST['capture']='/dev/null' -tmp_count=$max_count - # define for load pipeline func_run_pipeline_with_type() { @@ -117,10 +115,12 @@ do f_arg=${OPT_VALUE_lst['f']} case "$f_arg" in 'p') + tmp_count=$max_count func_run_pipeline_with_type "playback" func_run_pipeline_with_type "capture" ;; 'c') + tmp_count=$max_count func_run_pipeline_with_type "capture" func_run_pipeline_with_type "playback" ;; From d56e0b96b9955e8331e5909798a4e6c8414ca492 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Mon, 30 Nov 2020 16:28:05 -0800 Subject: [PATCH 2/2] multiple-pipeline: replace pidof->ps to catch uninterruptible sleep pidof ignores processes in uninterruptable sleep by default, probably because sending them signals is futile. pidof has a -z option but it's just simpler to use "ps". Also de-duplicate code into new ps_checks() function Fixes: #472 Any aplay or arecord process can be in uninterruptable sleep when doing I/O but the easiest way to reproduce is to wait a few seconds and let the DSP go to sleep. Signed-off-by: Marc Herbert --- test-case/multiple-pipeline.sh | 56 ++++++++++++++++------------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/test-case/multiple-pipeline.sh b/test-case/multiple-pipeline.sh index 2fc0e88a..ccf8ff28 100755 --- a/test-case/multiple-pipeline.sh +++ b/test-case/multiple-pipeline.sh @@ -105,6 +105,27 @@ func_error_exit() exit 1 } + +ps_checks() +{ + local play_count rec_count total_count + # Extra logging + # >&2 ps u --no-headers -C aplay -C arecord || true + + rec_count=$(ps --no-headers -C arecord | wc -l) + play_count=$(ps --no-headers -C aplay | wc -l) + total_count=$((rec_count + play_count)) + + [ "$total_count" -eq "$max_count" ] || + func_error_exit "Target pipeline count: $max_count, current process count: $total_count" + + [ "$rec_count" = 0 ] || sof-process-state.sh arecord >/dev/null || + func_error_exit "Caught abnormal process status of arecord" + [ "$play_count" = 0 ] || sof-process-state.sh aplay >/dev/null || + func_error_exit "Caught abnormal process status of aplay" +} + + for i in $(seq 1 $loop_cnt) do # set up checkpoint for each iteration @@ -128,45 +149,22 @@ do die "Wrong -f argument $f_arg, see -h" esac - dlogi "pipeline start sleep 0.5s for device wakeup" + dlogi "sleep ${OPT_VALUE_lst['w']}s for sound device wakeup" sleep ${OPT_VALUE_lst['w']} - # check all refer capture pipeline status - # 1. check process count: - rec_count=$(pidof arecord|wc -w) - tmp_count=$((tmp_count + rec_count)) - play_count=$(pidof aplay|wc -w) - tmp_count=$((tmp_count + play_count)) - [[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count" - - # 2. check arecord process status dlogi "checking pipeline status" - [ "$rec_count" = 0 ] || sof-process-state.sh arecord >/dev/null || - func_error_exit "Catch the abnormal process status of arecord" - [ "$play_count" = 0 ] || sof-process-state.sh aplay >/dev/null || - func_error_exit "Catch the abnormal process status of aplay" + ps_checks dlogi "preparing sleep ${OPT_VALUE_lst['w']}" sleep ${OPT_VALUE_lst['w']} - # 3. check process count again: - tmp_count=0 - rec_count=$(pidof arecord|wc -w) - tmp_count=$((tmp_count + rec_count)) - play_count=$(pidof aplay|wc -w) - tmp_count=$((tmp_count + play_count)) - [[ $tmp_count -ne $max_count ]] && func_error_exit "Target pipeline count: $max_count, current process count: $tmp_count" - - # 4. check arecord process status + # check processes again dlogi "checking pipeline status again" - [ "$rec_count" = 0 ] || sof-process-state.sh arecord >/dev/null || - func_error_exit "Catch the abnormal process status of arecord" - [ "$play_count" = 0 ] || sof-process-state.sh aplay >/dev/null || - func_error_exit "Catch the abnormal process status of aplay" + ps_checks dlogc 'pkill -9 aplay arecord' - [ "$rec_count" = 0 ] || pkill -9 arecord - [ "$play_count" = 0 ] || pkill -9 aplay + pkill -9 arecord || true + pkill -9 aplay || true # check kernel log for each iteration to catch issues sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" || die "Caught error in kernel log"