From: Bart Van Assche <bvanassche@acm.org>
To: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
linux-block@vger.kernel.org
Cc: Yi Zhang <yi.zhang@redhat.com>
Subject: Re: [PATCH blktests] block/008: avoid _offline_cpu() call in sub-shell
Date: Wed, 6 Jul 2022 06:55:42 -0700 [thread overview]
Message-ID: <521c76db-1c3c-07f5-8b00-7fc5385fbd4a@acm.org> (raw)
In-Reply-To: <20220704111638.1109883-1-shinichiro.kawasaki@wdc.com>
On 7/4/22 04:16, Shin'ichiro Kawasaki wrote:
> The helper function _offline_cpu() sets a value to RESTORE_CPUS_ONLINE.
> However, the commit bd6b882b2650 ("block/008: check CPU offline failure
> due to many IRQs") put _offline_cpu() call in sub-shell, then the set
> value to RESTORE_CPUS_ONLINE no longer affects function caller's
> environment. This resulted in offlined CPUs not restored by _cleanup()
> when the test case block/008 calls only _offline_cpu() and does not call
> _online_cpu().
>
> To fix the issue, avoid _offline_cpu() call in sub-shell. Use file
> redirect to get output of _offline_cpu() instead of sub-shell execution.
>
> Fixes: bd6b882b2650 ("block/008: check CPU offline failure due to many IRQs")
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Tested-by: Yi Zhang <yi.zhang@redhat.com>
> Link: https://lore.kernel.org/linux-block/20220703180956.2922025-1-yi.zhang@redhat.com/
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
> tests/block/008 | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/tests/block/008 b/tests/block/008
> index 75aae65..cd09352 100755
> --- a/tests/block/008
> +++ b/tests/block/008
> @@ -34,6 +34,7 @@ test_device() {
> local offline_cpus=()
> local offlining=1
> local max_offline=${#HOTPLUGGABLE_CPUS[@]}
> + local o=$TMPDIR/offline_cpu_out
> if [[ ${#HOTPLUGGABLE_CPUS[@]} -eq ${#ALL_CPUS[@]} ]]; then
> (( max_offline-- ))
> fi
> @@ -60,18 +61,18 @@ test_device() {
>
> if (( offlining )); then
> idx=$((RANDOM % ${#online_cpus[@]}))
> - if err=$(_offline_cpu "${online_cpus[$idx]}" 2>&1); then
> + if _offline_cpu "${online_cpus[$idx]}" > "$o" 2>&1; then
> offline_cpus+=("${online_cpus[$idx]}")
> unset "online_cpus[$idx]"
> online_cpus=("${online_cpus[@]}")
> - elif [[ $err =~ "No space left on device" ]]; then
> + elif [[ $(<"$o") =~ "No space left on device" ]]; then
> # ENOSPC means CPU offline failure due to IRQ
> # vector shortage. Keep current number of
> # offline CPUs as maximum CPUs to offline.
> max_offline=${#offline_cpus[@]}
> offlining=0
> else
> - echo "Failed to offline CPU: $err"
> + echo "Failed to offline CPU: $(<"$o")"
> break
> fi
> fi
Has it been considered to move RESTORE_CPUS_ONLINE=1 from _online_cpu()
/ _offline_cpu() into the callers of these functions instead of making
the above change?
Thanks,
Bart.
next prev parent reply other threads:[~2022-07-06 13:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 11:16 [PATCH blktests] block/008: avoid _offline_cpu() call in sub-shell Shin'ichiro Kawasaki
2022-07-06 13:55 ` Bart Van Assche [this message]
2022-07-07 3:13 ` Shinichiro Kawasaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=521c76db-1c3c-07f5-8b00-7fc5385fbd4a@acm.org \
--to=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=yi.zhang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox