From: "Alex Bennée" <alex.bennee@linaro.org>
To: Xingran Wang <wangxingran123456@outlook.com>
Cc: qemu-devel@nongnu.org,
Richard Henderson <richard.henderson@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Alexandre Iooss <erdnaxe@crans.org>,
Mahmoud Mandour <ma.mandourr@gmail.com>,
Pierrick Bouvier <pierrick.bouvier@linaro.org>
Subject: Re: [PATCH] plugins: add two events for cpu_restore_state_from_tb() and cpu_io_recompile()
Date: Mon, 02 Sep 2024 11:42:44 +0100 [thread overview]
Message-ID: <87mskqcp5n.fsf@draig.linaro.org> (raw)
In-Reply-To: <SY8P282MB4322879DBA2E5E3E3B72B383A1912@SY8P282MB4322.AUSP282.PROD.OUTLOOK.COM> (Xingran Wang's message of "Mon, 2 Sep 2024 00:34:06 +0800")
Xingran Wang <wangxingran123456@outlook.com> writes:
> Currently, the instruction count obtained by plugins using the translation
> block execution callback is larger than the actual value. Adding callbacks
> in cpu_restore_state_from_tb() and cpu_io_recompile() allows plugins to
> correct the instruction count when exiting a translation block
> mid-execution, properly subtracting the excess unexecuted
> instructions.
This smells like exposing two much of the TCG internals to the plugin
mechanism. You can already detect when we don't reach the end of a block
of instructions by instrumentation as I did in:
Message-Id: <20240718145958.1315270-1-alex.bennee@linaro.org>
Date: Thu, 18 Jul 2024 15:59:58 +0100
Subject: [RFC PATCH v3] contrib/plugins: control flow plugin
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= <alex.bennee@linaro.org>
So what exactly are we trying to achieve here? A more efficient
detection of short blocks?
>
> Signed-off-by: Xingran Wang <wangxingran123456@outlook.com>
> ---
> accel/tcg/translate-all.c | 27 ++++++++
> include/qemu/plugin-event.h | 2 +
> include/qemu/plugin.h | 24 +++++++
> include/qemu/qemu-plugin.h | 131 +++++++++++++++++++++++++++++++++++
> plugins/api.c | 78 +++++++++++++++++++++
> plugins/core.c | 42 +++++++++++
> plugins/qemu-plugins.symbols | 10 +++
> tests/tcg/plugins/bb.c | 25 +++++++
> 8 files changed, 339 insertions(+)
>
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index fdf6d8ac19..642f684372 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -65,6 +65,7 @@
> #include "internal-target.h"
> #include "tcg/perf.h"
> #include "tcg/insn-start-words.h"
> +#include "qemu/plugin.h"
>
> TBContext tb_ctx;
>
> @@ -218,6 +219,19 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
> cpu->neg.icount_decr.u16.low += insns_left;
> }
>
> +#ifdef CONFIG_PLUGIN
> + /*
> + * Notify the plugin with the relevant information
> + * when restoring the execution state of a TB.
> + */
> + struct qemu_plugin_tb_restore ptb_restore;
> + ptb_restore.cpu_index = cpu->cpu_index;
> + ptb_restore.insns_left = insns_left;
> + ptb_restore.tb_n = tb->icount;
> + ptb_restore.tb_pc = tb->pc;
> + qemu_plugin_tb_restore_cb(cpu, &ptb_restore);
> +#endif
> +
See also the unwind patches which is a more generic approach to ensuring
"special" registers are synced at midpoint when using the register API:
Message-Id: <20240606032926.83599-1-richard.henderson@linaro.org>
Date: Wed, 5 Jun 2024 20:29:17 -0700
Subject: [PATCH v2 0/9] plugins: Use unwind info for special gdb registers
From: Richard Henderson <richard.henderson@linaro.org>
<snip>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2024-09-02 10:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-01 16:34 [PATCH] plugins: add two events for cpu_restore_state_from_tb() and cpu_io_recompile() Xingran Wang
2024-09-02 10:42 ` Alex Bennée [this message]
2024-09-02 16:08 ` Pierrick Bouvier
2024-09-02 17:52 ` Alex Bennée
2024-09-02 18:56 ` Pierrick Bouvier
2024-09-03 6:53 ` Xingran Wang
2024-09-03 16:41 ` Richard Henderson
2024-09-03 17:17 ` Alex Bennée
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=87mskqcp5n.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=erdnaxe@crans.org \
--cc=ma.mandourr@gmail.com \
--cc=pbonzini@redhat.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=wangxingran123456@outlook.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.