From: "Alex Bennée" <alex.bennee@linaro.org>
To: Jim MacArthur <jim.macarthur@linaro.org>
Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org
Subject: Re: Record/replay thread determinism
Date: Fri, 20 Feb 2026 15:06:20 +0000 [thread overview]
Message-ID: <87zf534fpv.fsf@draig.linaro.org> (raw)
In-Reply-To: <aZhuzUi4P0-mB-FH@linaro.org> (Jim MacArthur's message of "Fri, 20 Feb 2026 14:25:17 +0000")
Jim MacArthur <jim.macarthur@linaro.org> writes:
> It looks like we have a solution to the RCU patch which was causing problems with the func-alpha-replay test (see 20260217-alpha-v1-0-0dcc708c9db3@rsg.ci.i.u-tokyo.ac.jp).
> While this was going on I spent a bit of time investigating repeatability in record/replay and I think there may be broader problems with record & replay.
>
> While running the func-alpha-replay test we have two threads reading
> or writing the replay event log; the "main" thread running
> qemu_main_loop and the "RR" (round robin) thread running
> rr_cpu_thread_fn. Both of these use replay_mutex_lock() and bql_lock()
> to synchronize some actions. There's a third thread running RCU
> maintenance which also uses bql_lock(), but not replay_mutex_lock().
>
> replay_mutex_lock() has some extra logic to improve fairness of
> locking. This means that the first caller of replay_mutex_lock()
> should obtain the lock first. However, so far as I can see, this
> doesn't make the scheduling of the Main and RR threads deterministic.
> I have observed times when neither of those threads holds the lock,
> and as such, there's no way to predict which will call
> replay_mutex_lock() first. This means the ordering of events during
> either recording or replay is not deterministic.
The replay_lock was a kludge we added when we did the original
transition to multi-threaded TCG which involved nailing down the BQL
calls that had previously kept everything in sync.
However if we could keep all replay events in the single RR thread we
could get rid of replay lock because everything should behave serially.
> It is possible to alter the lock function such that the two threads
> will run in lockstep; see
> https://gitlab.com/jmacarthur/qemu-jmac-development/-/commits/jmac/replay-tick-tock
> for a rough demonstration. Adding this significantly reduced timeouts
> on func-alpha-replay; I can also see that the replay recordings are
> much more consistent from one recording to the next; typically
> diverging around the 380000th event, rather than the 20th event
> without this hack.
> This is not a good fix since it slows QEMU down significantly and may be prone to deadlocks, but I think this demonstrates that the current system is not perfect.
>
> Do you agree with my analysis above? Is there something I've missed which is meant to deterministically schedule these two threads?
>
> Jim MacArthur
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2026-02-20 15:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 14:25 Record/replay thread determinism Jim MacArthur
2026-02-20 15:06 ` Alex Bennée [this message]
2026-02-27 14:02 ` Jim MacArthur
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=87zf534fpv.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=jim.macarthur@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.