From e4cd96571f00e290e93dcc65a6d2b616b159dea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Fri, 31 Mar 2017 16:09:42 +0100 Subject: cpus: don't credit executed instructions before they have run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Outside of the vCPU thread icount time will only be tracked against timers_state.qemu_icount. We no longer credit cycles until they have completed the run. Inside the vCPU thread we adjust for passage of time by looking at how many have run so far. This is only valid inside the vCPU thread while it is running. Signed-off-by: Alex Bennée --- include/qom/cpu.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/qom/cpu.h b/include/qom/cpu.h index c3292ef..5d10359 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -332,6 +332,7 @@ struct CPUState { /* updates protected by BQL */ uint32_t interrupt_request; int singlestep_enabled; + int64_t icount_budget; int64_t icount_extra; sigjmp_buf jmp_env; -- cgit v1.1 From 512d3c807177b5cfff6b5a4925d71ae1b5521093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Wed, 5 Apr 2017 12:32:37 +0100 Subject: cpus: introduce cpu_update_icount helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By holding off updates to timer_state.qemu_icount we can run into trouble when the non-vCPU thread needs to know the time. This helper ensures we atomically update timers_state.qemu_icount based on what has been currently executed. Signed-off-by: Alex Bennée --- include/qemu/timer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/qemu/timer.h b/include/qemu/timer.h index e1742f2..8a1eb74 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -869,6 +869,7 @@ int64_t cpu_get_icount_raw(void); int64_t cpu_get_icount(void); int64_t cpu_get_clock(void); int64_t cpu_icount_to_ns(int64_t icount); +void cpu_update_icount(CPUState *cpu); /*******************************************/ /* host CPU ticks (if available) */ -- cgit v1.1