target/s390x: Fix infinite loop during replay
Replaying even trivial s390x kernels hangs, because:
- cpu_post_load() fires the TOD timer immediately.
- s390_tod_load() schedules work for firing the TOD timer.
- If rr loop sees work and then timer, we get one timer expiration.
- If rr loop sees timer and then work, we get two timer expirations.
- Record and replay may diverge due to this race.
- In this particular case divergence makes replay loop spin: it sees that
TOD timer has expired, but cannot invoke its callback, because there
is no recorded CHECKPOINT_CLOCK_VIRTUAL.
- The order in which rr loop sees work and timer depends on whether
and when rr loop wakes up during load_snapshot().
- rr loop may wake up after the main thread kicks the CPU and drops
the BQL, which may happen if it calls, e.g., qemu_cond_wait_bql().
Firing TOD timer twice is duplicate work, but it was introduced
intentionally in commit 7c12f710ba ("s390x/tcg: rearm the CKC timer
during migration") in order to avoid dependency on migration order.
The key culprits here are timers that are armed ready expired. They
break the ordering between timers and CPU work, because they are not
constrained by instruction execution, thus introducing non-determinism
and record-replay divergence.
Fix by converting such timer callbacks to CPU work. Also add TOD clock
updates to the save path, mirroring the load path, in order to have the
same CHECKPOINT_CLOCK_VIRTUAL during recording and replaying.
Link: https://lore.kernel.org/qemu-devel/20251128133949.181828-1-thuth@redhat.com/
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20251201215514.1751994-1-iii@linux.ibm.com>
[thuth: Add SPDX license identifiers to the new stubs files]
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
committed by
Thomas Huth
parent
c4a009cbdc
commit
f098c32db4
11
stubs/async-run-on-cpu.c
Normal file
11
stubs/async-run-on-cpu.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/core/cpu.h"
|
||||
|
||||
void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
8
stubs/cpus-queue.c
Normal file
8
stubs/cpus-queue.c
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/core/cpu.h"
|
||||
|
||||
CPUTailQ cpus_queue = QTAILQ_HEAD_INITIALIZER(cpus_queue);
|
||||
@@ -41,6 +41,8 @@ if have_block or have_ga
|
||||
stub_ss.add(files('monitor-internal.c'))
|
||||
stub_ss.add(files('qmp-command-available.c'))
|
||||
stub_ss.add(files('qmp-quit.c'))
|
||||
stub_ss.add(files('async-run-on-cpu.c'))
|
||||
stub_ss.add(files('cpus-queue.c'))
|
||||
endif
|
||||
|
||||
if have_block or have_user
|
||||
|
||||
Reference in New Issue
Block a user