From: Randy Dunlap <rdunlap@infradead.org>
To: Joel Fernandes <joelagnelf@nvidia.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Josh Triplett <josh@joshtriplett.org>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Shuah Khan <shuah@kernel.org>
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH RFC 1/2] rcutorture: Prevent concurrent kvm.sh runs on same source tree
Date: Sun, 28 Dec 2025 14:34:12 -0800 [thread overview]
Message-ID: <24f4df13-0875-49bd-95d1-4bf1a400ff15@infradead.org> (raw)
In-Reply-To: <20251228220519.150179-1-joelagnelf@nvidia.com>
On 12/28/25 2:05 PM, Joel Fernandes wrote:
> Add flock-based locking to kvm.sh to prevent multiple instances from
> running concurrently on the same source tree. This prevents build
> failures caused by one instance's "make clean" deleting generated files
> while another instance is building causing build failures.
>
> The lock file is placed in the rcutorture directory and added to
> .gitignore.
>
> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
> ---
> tools/testing/selftests/rcutorture/.gitignore | 1 +
> tools/testing/selftests/rcutorture/bin/kvm.sh | 17 +++++++++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/tools/testing/selftests/rcutorture/.gitignore b/tools/testing/selftests/rcutorture/.gitignore
> index f6cbce77460b..b8fd42547a6e 100644
> --- a/tools/testing/selftests/rcutorture/.gitignore
> +++ b/tools/testing/selftests/rcutorture/.gitignore
> @@ -3,3 +3,4 @@ initrd
> b[0-9]*
> res
> *.swp
> +.kvm.sh.lock
> diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/selftests/rcutorture/bin/kvm.sh
> index fff15821c44c..d1fbd092e22a 100755
> --- a/tools/testing/selftests/rcutorture/bin/kvm.sh
> +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh
> @@ -275,6 +275,23 @@ do
> shift
> done
>
> +# Prevent concurrent kvm.sh runs on the same source tree. The flock
> +# is automatically released when the script exits, even if killed.
> +TORTURE_LOCK="$RCUTORTURE/.kvm.sh.lock"
> +if test -z "$dryrun"
> +then
> + # Create a file descriptor and flock it, so that when kvm.sh (and its
> + # children) exit, the flock is released by the kernel automatically.
> + exec 9>"$TORTURE_LOCK"
> + if ! flock -n 9
> + then
> + echo "ERROR: Another kvm.sh instance is already running on this tree."
> + echo " Lock file: $TORTURE_LOCK"
> + echo " To run kvm.sh, kill all existing kvm.sh runs first."
> + exit 1
> + fi
> +fi
> +
> if test -n "$dryrun" || test -z "$TORTURE_INITRD" || tools/testing/selftests/rcutorture/bin/mkinitrd.sh
> then
> :
>
> base-commit: 0ff41df1cb268fc69e703a08a57ee14ae967d0ca
> prerequisite-patch-id: 912adecf969d167ddd35b26844249c809a2d4664
> prerequisite-patch-id: 95ca224b0870cebb545ddaf313691fd18dfd04e1
> prerequisite-patch-id: 68a218b9aaada53aa85cf33fcf4afe1592fe160f
> prerequisite-patch-id: e40912ee9655a8abef17413a1bb9b05d2d4520de
> prerequisite-patch-id: c0511755626728abcbed2f76e9a0b1d2f15e7c9e
> prerequisite-patch-id: 0a8814cf3965ce3d5fb30d18db3daf2b96c3db74
> prerequisite-patch-id: 450827b1f88e4ab714a63a24a66bd209f8c332af
Are all 54K of these required?
--
~Randy
next prev parent reply other threads:[~2025-12-28 22:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-28 22:05 [PATCH RFC 1/2] rcutorture: Prevent concurrent kvm.sh runs on same source tree Joel Fernandes
2025-12-28 22:05 ` [PATCH RFC 2/2] rcutorture: Add --kill-previous option to terminate previous kvm.sh runs Joel Fernandes
2025-12-28 22:34 ` Randy Dunlap [this message]
2025-12-28 22:37 ` [PATCH RFC 1/2] rcutorture: Prevent concurrent kvm.sh runs on same source tree Joel Fernandes
2025-12-29 16:39 ` Steven Rostedt
2025-12-30 23:12 ` Joel Fernandes
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=24f4df13-0875-49bd-95d1-4bf1a400ff15@infradead.org \
--to=rdunlap@infradead.org \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
/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