[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 7/7] cpu-exec: centralize exiting to the main loop
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 7/7] cpu-exec: centralize exiting to the main loop |
Date: |
Sun, 29 Jan 2017 22:09:10 +0100 |
The cpu->exit_request check in cpu_loop_exec_tb is unnecessary,
because cpu->tcg_exit_req is always set after cpu->exit_request.
So let the TB exit and we will pick up the exit request later
in cpu_handle_interrupt.
Likewise, use cpu->exit_request to set EXCP_INTERRUPT when the
instruction counter expires. Because cpu_loop_exec_tb is
followed immediately by align_clocks, this lets us remove the
SyncClocks *sc argument to cpu_loop_exec_tb.
Signed-off-by: Paolo Bonzini <address@hidden>
---
cpu-exec.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 903a834..3838eb8 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -517,6 +517,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
*last_tb = NULL;
}
}
+
+ /* Finally, check if we need to exit to the main loop. */
if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt())) {
atomic_set(&cpu->exit_request, 0);
cpu->exception_index = EXCP_INTERRUPT;
@@ -527,16 +529,11 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
}
static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
- TranslationBlock **last_tb, int *tb_exit,
- SyncClocks *sc)
+ TranslationBlock **last_tb, int *tb_exit)
{
uintptr_t ret;
int32_t insns_left;
- if (unlikely(atomic_read(&cpu->exit_request))) {
- return;
- }
-
trace_exec_tb(tb, tb->pc);
ret = cpu_tb_exec(cpu, tb);
tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);
@@ -578,10 +575,8 @@ static inline void cpu_loop_exec_tb(CPUState *cpu,
TranslationBlock *tb,
*/
if (insns_left > 0) {
cpu_exec_nocache(cpu, insns_left, tb, false);
- align_clocks(sc, cpu);
}
- cpu->exception_index = EXCP_INTERRUPT;
- cpu_loop_exit(cpu);
+ atomic_set(&cpu->exit_request, 1);
}
}
@@ -641,7 +636,7 @@ int cpu_exec(CPUState *cpu)
while (!cpu_handle_interrupt(cpu, &last_tb)) {
TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit);
- cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc);
+ cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit);
/* Try to align the host and virtual clocks
if the guest is in advance */
align_clocks(&sc, cpu);
--
2.9.3
- [Qemu-devel] [RFC/RFT PATCH 0/7] cpu-exec: simplify cpu_exec and remove some icount special cases, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 2/7] cpu-exec: tighten barrier on TCG_EXIT_REQUESTED, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 1/7] cpu-exec: fix jmp_first out-of-bounds access with icount, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 5/7] cpu-exec: remove outermost infinite loop, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 4/7] cpu-exec: avoid repeated sigsetjmp on interrupts, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 3/7] cpu-exec: avoid cpu_loop_exit in cpu_handle_interrupt, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 6/7] cpu-exec: unify icount_decr and tcg_exit_req, Paolo Bonzini, 2017/01/29
- [Qemu-devel] [PATCH 7/7] cpu-exec: centralize exiting to the main loop,
Paolo Bonzini <=
- Re: [Qemu-devel] [RFC/RFT PATCH 0/7] cpu-exec: simplify cpu_exec and remove some icount special cases, no-reply, 2017/01/29
- Re: [Qemu-devel] [RFC/RFT PATCH 0/7] cpu-exec: simplify cpu_exec and remove some icount special cases, Pavel Dovgalyuk, 2017/01/31