diff options
author | Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> | 2016-03-10 14:56:09 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-03-15 18:23:45 +0100 |
commit | e76d1798faa6d29f54c0930a034b67f3ecdb947d (patch) | |
tree | fbfade6e7fcfafd8f8059923a4e82f849d8ea40a /docs/replay.txt | |
parent | 281b2201e4e18d5b9a26e1e8d81b62b5581a13be (diff) | |
download | qemu-e76d1798faa6d29f54c0930a034b67f3ecdb947d.zip qemu-e76d1798faa6d29f54c0930a034b67f3ecdb947d.tar.gz qemu-e76d1798faa6d29f54c0930a034b67f3ecdb947d.tar.bz2 |
icount: decouple warp calls
qemu_clock_warp function is called to update virtual clock when CPU
is sleeping. This function includes replay checkpoint to make execution
deterministic in icount mode.
Record/replay module flushes async event queue at checkpoints.
Some of the events (e.g., block devices operations) include interaction
with hardware. E.g., APIC polled by block devices sets one of IRQ flags.
Flag to be set depends on currently executed thread (CPU or iothread).
Therefore in replay mode we have to process the checkpoints in the same thread
as they were recorded.
qemu_clock_warp function (and its checkpoint) may be called from different
thread. This patch decouples two different execution cases of this function:
call when CPU is sleeping from iothread and call from cpu thread to update
virtual clock.
First task is performed by qemu_start_warp_timer function. It sets warp
timer event to the moment of nearest pending virtual timer.
Second function (qemu_account_warp_timer) is called from cpu thread
before execution of the code. It advances virtual clock by adding the length
of period while CPU was sleeping.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Message-Id: <20160310115609.4812.44986.stgit@PASHA-ISP>
[Update docs. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'docs/replay.txt')
-rw-r--r-- | docs/replay.txt | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/docs/replay.txt b/docs/replay.txt index 149727e..3cedc25 100644 --- a/docs/replay.txt +++ b/docs/replay.txt @@ -107,7 +107,7 @@ at the specified moments of time. There are several kinds of timers: sources (e.g. real time clock chip). Host clock is the one of the sources of non-determinism. Host clock read operations should be logged to make the execution deterministic. - * Real time clock for icount. This clock is similar to real time clock but + * Virtual real time clock. This clock is similar to real time clock but it is used only for increasing virtual clock while virtual machine is sleeping. Due to its nature it is also non-deterministic as the host clock and has to be logged too. @@ -134,11 +134,20 @@ of time. That's why we do not process a group of timers until the checkpoint event will be read from the log. Such an event allows synchronizing CPU execution and timer events. -Another checkpoints application in record/replay is instruction counting -while the virtual machine is idle. This function (qemu_clock_warp) is called -from the wait loop. It changes virtual machine state and must be deterministic -then. That is why we added checkpoint to this function to prevent its -operation in replay mode when it does not correspond to record mode. +Two other checkpoints govern the "warping" of the virtual clock. +While the virtual machine is idle, the virtual clock increments at +1 ns per *real time* nanosecond. This is done by setting up a timer +(called the warp timer) on the virtual real time clock, so that the +timer fires at the next deadline of the virtual clock; the virtual clock +is then incremented (which is called "warping" the virtual clock) as +soon as the timer fires or the CPUs need to go out of the idle state. +Two functions are used for this purpose; because these actions change +virtual machine state and must be deterministic, each of them creates a +checkpoint. qemu_start_warp_timer checks if the CPUs are idle and if so +starts accounting real time to virtual clock. qemu_account_warp_timer +is called when the CPUs get an interrupt or when the warp timer fires, +and it warps the virtual clock by the amount of real time that has passed +since qemu_start_warp_timer. Bottom halves ------------- |