From: Paolo Bonzini <pbonzini@redhat.com>
To: Leandro Lupori <leandro.lupori@eldorado.org.br>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: richard.henderson@linaro.org, clg@kaod.org,
danielhb413@gmail.com, david@gibson.dropbear.id.au,
groug@kaod.org
Subject: Re: [PATCH 1/3] accel/tcg: Add a quicker check for breakpoints
Date: Tue, 25 Oct 2022 14:29:47 +0200 [thread overview]
Message-ID: <7c33ff5c-69c5-a6b7-7f8a-7e8eaaeb33c6@redhat.com> (raw)
In-Reply-To: <20221021170112.151393-2-leandro.lupori@eldorado.org.br>
On 10/21/22 19:01, Leandro Lupori wrote:
> 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 moving the check for empty queue to the have_breakpoints()
> macro and calling check_for_breakpoints() only when it returns
> true, 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>
> ---
> accel/tcg/cpu-exec.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index f9e5cc9ba0..9eec01ad9a 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -304,16 +304,15 @@ static void log_cpu_exec(target_ulong pc, CPUState *cpu,
> }
> }
>
> +#define have_breakpoints(cpu) (likely(QTAILQ_EMPTY(&(cpu)->breakpoints)) ? \
> + false : true)
> +
> static bool check_for_breakpoints(CPUState *cpu, target_ulong pc,
> uint32_t *cflags)
> {
> CPUBreakpoint *bp;
> bool match_page = false;
>
> - if (likely(QTAILQ_EMPTY(&cpu->breakpoints))) {
> - return false;
> - }
> -
It's a little more readable to just split out the slow path:
-static inline 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;
- }
...
}
+
+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);
+}
Paolo
next prev parent reply other threads:[~2022-10-25 12:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-21 17:01 [PATCH 0/3] Performance optimizations for PPC64 Leandro Lupori
2022-10-21 17:01 ` [PATCH 1/3] accel/tcg: Add a quicker check for breakpoints Leandro Lupori
2022-10-22 11:12 ` Richard Henderson
2022-10-24 15:00 ` Leandro Lupori
2022-10-25 12:29 ` Paolo Bonzini [this message]
2022-10-21 17:01 ` [PATCH 2/3] target/ppc: Add new PMC HFLAGS Leandro Lupori
2022-10-25 19:24 ` Daniel Henrique Barboza
2022-10-21 17:01 ` [PATCH 3/3] target/ppc: Increment PMC5 with inline insns Leandro Lupori
2022-10-25 19:29 ` Daniel Henrique Barboza
2022-10-25 20:39 ` Leandro Lupori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7c33ff5c-69c5-a6b7-7f8a-7e8eaaeb33c6@redhat.com \
--to=pbonzini@redhat.com \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=leandro.lupori@eldorado.org.br \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).