[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/47] accel/tcg: Add a quicker check for breakpoints
From: |
Richard Henderson |
Subject: |
[PULL 04/47] accel/tcg: Add a quicker check for breakpoints |
Date: |
Wed, 26 Oct 2022 12:10:33 +1000 |
From: Leandro Lupori <leandro.lupori@eldorado.org.br>
Profiling QEMU during Fedora 35 for PPC64 boot revealed that a
considerable amount of time was being spent in
check_for_breakpoints() (0.61% of total time on PPC64 and 2.19% on
amd64), even though it was just checking that its queue was empty
and returning, when no breakpoints were set. It turns out this
function is not inlined by the compiler and it's always called by
helper_lookup_tb_ptr(), one of the most called functions.
By leaving only the check for empty queue in
check_for_breakpoints() and moving the remaining code to
check_for_breakpoints_slow(), called only when the queue is not
empty, it's possible to avoid the call overhead. An improvement of
about 3% in total time was measured on POWER9.
Signed-off-by: Leandro Lupori <leandro.lupori@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20221025202424.195984-2-leandro.lupori@eldorado.org.br>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/cpu-exec.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index f9e5cc9ba0..bb4b9e92ce 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -304,16 +304,12 @@ static void log_cpu_exec(target_ulong pc, CPUState *cpu,
}
}
-static bool check_for_breakpoints(CPUState *cpu, target_ulong pc,
- uint32_t *cflags)
+static bool check_for_breakpoints_slow(CPUState *cpu, target_ulong pc,
+ uint32_t *cflags)
{
CPUBreakpoint *bp;
bool match_page = false;
- if (likely(QTAILQ_EMPTY(&cpu->breakpoints))) {
- return false;
- }
-
/*
* Singlestep overrides breakpoints.
* This requirement is visible in the record-replay tests, where
@@ -374,6 +370,13 @@ static bool check_for_breakpoints(CPUState *cpu,
target_ulong pc,
return false;
}
+static inline bool check_for_breakpoints(CPUState *cpu, target_ulong pc,
+ uint32_t *cflags)
+{
+ return unlikely(!QTAILQ_EMPTY(&cpu->breakpoints)) &&
+ check_for_breakpoints_slow(cpu, pc, cflags);
+}
+
/**
* helper_lookup_tb_ptr: quick check for next tb
* @env: current cpu state
--
2.34.1
- [PULL 00/47] tcg patch queue, Richard Henderson, 2022/10/25
- [PULL 01/47] Revert "accel/tcg: Init TCG cflags in vCPU thread handler", Richard Henderson, 2022/10/25
- [PULL 02/47] tcg/loongarch64: Add direct jump support, Richard Henderson, 2022/10/25
- [PULL 03/47] tcg/aarch64: Remove unused code in tcg_out_op, Richard Henderson, 2022/10/25
- [PULL 05/47] include/qemu/osdep: Add qemu_build_assert, Richard Henderson, 2022/10/25
- [PULL 04/47] accel/tcg: Add a quicker check for breakpoints,
Richard Henderson <=
- [PULL 06/47] include/qemu/atomic: Use qemu_build_assert, Richard Henderson, 2022/10/25
- [PULL 08/47] accel/tcg: Make page_alloc_target_data allocation constant, Richard Henderson, 2022/10/25
- [PULL 07/47] include/qemu/thread: Use qatomic_* functions, Richard Henderson, 2022/10/25
- [PULL 09/47] accel/tcg: Remove disabled debug in translate-all.c, Richard Henderson, 2022/10/25
- [PULL 10/47] accel/tcg: Split out PageDesc to internal.h, Richard Henderson, 2022/10/25
- [PULL 12/47] accel/tcg: Move assert_no_pages_locked to internal.h, Richard Henderson, 2022/10/25
- [PULL 11/47] accel/tcg: Split out tb-maint.c, Richard Henderson, 2022/10/25
- [PULL 13/47] accel/tcg: Drop cpu_get_tb_cpu_state from TARGET_HAS_PRECISE_SMC, Richard Henderson, 2022/10/25
- [PULL 14/47] accel/tcg: Remove duplicate store to tb->page_addr[], Richard Henderson, 2022/10/25
- [PULL 15/47] accel/tcg: Introduce tb_{set_}page_addr{0,1}, Richard Henderson, 2022/10/25