From: "Alex Bennée" <alex.bennee@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: Pierrick Bouvier <pierrick.bouvier@linaro.org>,
Xingran Wang <wangxingran123456@outlook.com>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Alexandre Iooss <erdnaxe@crans.org>,
Mahmoud Mandour <ma.mandourr@gmail.com>
Subject: Re: [PATCH] plugins: add two events for cpu_restore_state_from_tb() and cpu_io_recompile()
Date: Tue, 03 Sep 2024 18:17:46 +0100 [thread overview]
Message-ID: <871q20vepx.fsf@draig.linaro.org> (raw)
In-Reply-To: <664c54d6-ac73-4e3f-9d2c-dd0a357fd1d8@linaro.org> (Richard Henderson's message of "Tue, 3 Sep 2024 09:41:40 -0700")
Richard Henderson <richard.henderson@linaro.org> writes:
> On 9/2/24 10:52, Alex Bennée wrote:
>> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
>>
>>> Hi Xingran,
>>>
>>> On 9/2/24 03:42, Alex Bennée wrote:
>>>> 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:
>>>>
>>>
>>> I agree that this is definitely a QEMU implementation "detail", and
>>> should not be a concern for end users.
>>>
<snip>
>> /**
>> * qemu_plugin_register_vcpu_tb_exec_end_cb() - register execution callback at end of TB
>> * @tb: the opaque qemu_plugin_tb handle for the translation
>> * @cb: callback function
>> * @flags: does the plugin read or write the CPU's registers?
>> * @userdata: any plugin data to pass to the @cb?
>> *
>> * The @cb function is called every time a translated unit executes.
>> */
>> QEMU_PLUGIN_API
>> void qemu_plugin_register_vcpu_tb_exec_end_cb(struct qemu_plugin_tb *tb,
>> qemu_plugin_vcpu_tb_end_cb_t cb,
>> enum qemu_plugin_cb_flags flags,
>> void *userdata);
>> I think the tricky bit would be getting TCG to emit the callback
>> code
>> for the last instruction before the
>> tcg_gen_exit_tb/tcg_gen_lookup_and_goto_ptr bits but after whatever else
>> it has done to execute the instruction.
>> I don't think we could easily support inline ops at tb end though.
>> Richard,
>> What do you think?
> I think this will miss all exceptions raised in the middle of the block.
> I don't think it will be reliable at all.
Ahh yes - I guess we can't fixup as we go through cpu_loop_exit() and
the restore code is only called from helpers. Oh well I think we can
make do with what we currently have.
>
>
> r~
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
prev parent reply other threads:[~2024-09-03 17:18 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
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 [this message]
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=871q20vepx.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.