Reduce lock contention by acquiring / releasing the BQL outside of the entire vCPU inner loop.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- target/i386/hvf/hvf.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 0ffa3658dc5..f8bc01d38d3 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -1009,6 +1009,9 @@ int hvf_arch_vcpu_exec(CPUState *cpu) return EXCP_HLT; } + bql_unlock(); + cpu_exec_start(cpu); + /* Inner vCPU loop */ do { if (cpu->vcpu_dirty) { @@ -1017,26 +1020,26 @@ int hvf_arch_vcpu_exec(CPUState *cpu) } if (hvf_inject_interrupts(cpu)) { - return EXCP_INTERRUPT; + ret = EXCP_INTERRUPT; + break; } + vmx_update_tpr(cpu); - bql_unlock(); if (!cpu_is_bsp(X86_CPU(cpu)) && cpu->halted) { - bql_lock(); - return EXCP_HLT; + ret = EXCP_HLT; + break; } - cpu_exec_start(cpu); - hv_return_t r = hv_vcpu_run_until(cpu->accel->fd, HV_DEADLINE_FOREVER); assert_hvf_ok(r); - cpu_exec_end(cpu); - ret = hvf_handle_vmexit(cpu); } while (ret == 0); + cpu_exec_end(cpu); + bql_lock(); + return ret; } -- 2.53.0
