[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 11/12] cpus: call cpu_update_icount on read
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v2 11/12] cpus: call cpu_update_icount on read |
Date: |
Wed, 5 Apr 2017 14:25:02 +0100 |
This ensures each time the vCPU thread reads the icount we update the
master timer_state.qemu_icount field. This way as long as updates are
in BQL protected sections (which they should be) the main-loop can
never come to update the log and find time has gone backwards.
Signed-off-by: Alex Bennée <address@hidden>
---
cpus.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/cpus.c b/cpus.c
index ff75af449a..63de033cc8 100644
--- a/cpus.c
+++ b/cpus.c
@@ -246,19 +246,17 @@ void cpu_update_icount(CPUState *cpu)
int64_t cpu_get_icount_raw(void)
{
- int64_t icount;
CPUState *cpu = current_cpu;
- icount = atomic_read(&timers_state.qemu_icount);
if (cpu && cpu->running) {
if (!cpu->can_do_io) {
fprintf(stderr, "Bad icount read\n");
exit(1);
}
/* Take into account what has run */
- icount += cpu_get_icount_executed(cpu);
+ cpu_update_icount(cpu);
}
- return icount;
+ return atomic_read(&timers_state.qemu_icount);
}
/* Return the virtual CPU time, based on the instruction counter. */
--
2.11.0
[Qemu-devel] [PATCH v2 11/12] cpus: call cpu_update_icount on read,
Alex Bennée <=
[Qemu-devel] [PATCH v2 10/12] cpu-exec: update icount after each TB_EXIT, Alex Bennée, 2017/04/05