From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>,
"Julian Ganz" <neither@nut.email>
Cc: qemu-devel@nongnu.org, Alexandre Iooss <erdnaxe@crans.org>,
Mahmoud Mandour <ma.mandourr@gmail.com>
Subject: Re: [RFC PATCH v3 04/11] contrib/plugins: add plugin showcasing new dicontinuity related API
Date: Fri, 10 Jan 2025 13:02:51 -0800 [thread overview]
Message-ID: <0369698c-0fbe-45f8-bad9-1e6a7b1ed410@linaro.org> (raw)
In-Reply-To: <87cygu4s4a.fsf@draig.linaro.org>
On 1/10/25 07:15, Alex Bennée wrote:
> "Julian Ganz" <neither@nut.email> writes:
>
>> Hi Alex,
>>
>> January 9, 2025 at 3:04 PM, "Alex Bennée" wrote:
>>> Julian Ganz <neither@nut.email> writes:
>>>> We recently introduced new plugin API for registration of discontinuity
>>>> related callbacks. This change introduces a minimal plugin showcasing
>>>> the new API. It simply counts the occurances of interrupts, exceptions
>>>> and host calls per CPU and reports the counts when exitting.
>>>> ---
>>>> contrib/plugins/meson.build | 3 +-
>>>> contrib/plugins/traps.c | 96 +++++++++++++++++++++++++++++++++++++
>>>> 2 files changed, 98 insertions(+), 1 deletion(-)
>>>> create mode 100644 contrib/plugins/traps.c
>>>>
>>>> diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build
>>>> index 63a32c2b4f..9a3015e1c1 100644
>>>> --- a/contrib/plugins/meson.build
>>>> +++ b/contrib/plugins/meson.build
>>>> @@ -1,5 +1,6 @@
>>>> contrib_plugins = ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotblocks',
>>>> - 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger']
>>>> + 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger',
>>>> + 'traps']
>>>>
>>> I wonder if this is better in tests/tcg/plugins? We need to do something
>>> to ensure it gets covered by CI although we might want to be smarter
>>> about running it together with a test binary that will actually pick up
>>> something.
>>
>> The callback is intended as an example. The patch-series does contain a
>> dedicated testing plugin. And iirc the contrib plugins are now built
>> with the rest of qemu anyway?
>
> They do - however we generate additional tests with tests/tcg/plugins
> with the existing multiarch linux-user and softmmu check-tcg tests. Its
> a fairly dumb expansion though:
>
> # We need to ensure expand the run-plugin-TEST-with-PLUGIN
> # pre-requistes manually here as we can't use stems to handle it. We
> # only expand MULTIARCH_TESTS which are common on most of our targets
> # to avoid an exponential explosion as new tests are added. We also
> # add some special helpers the run-plugin- rules can use below.
> # In more, extra tests can be added using ADDITIONAL_PLUGINS_TESTS variable.
>
> ifneq ($(MULTIARCH_TESTS),)
> $(foreach p,$(PLUGINS), \
> $(foreach t,$(MULTIARCH_TESTS) $(ADDITIONAL_PLUGINS_TESTS),\
> $(eval run-plugin-$(t)-with-$(p): $t $p) \
> $(eval RUN_TESTS+=run-plugin-$(t)-with-$(p))))
> endif # MULTIARCH_TESTS
> endif # CONFIG_PLUGIN
>
> We also have a hand-hacked test for validating memory instrumentation:
>
> # Test plugin memory access instrumentation
> run-plugin-test-plugin-mem-access-with-libmem.so: \
> PLUGIN_ARGS=$(COMMA)print-accesses=true
> run-plugin-test-plugin-mem-access-with-libmem.so: \
> CHECK_PLUGIN_OUTPUT_COMMAND= \
> $(SRC_PATH)/tests/tcg/multiarch/check-plugin-output.sh \
> $(QEMU) $<
>
> test-plugin-mem-access: CFLAGS+=-pthread -O0
> test-plugin-mem-access: LDFLAGS+=-pthread -O0
>
> That said as I mention in the reply to the cover letter the traps stuff
> might be better exercised with the functional test so could utilise a
> plugin built in contrib just as easily.
>
I agree, as it was discussed in previous versions, we should add a
functional test for this. I'm not sure if we should write a custom and
complicated test, or simply boot and shutdown an existing image, and
call it a day.
Do you have any opinion on this Alex?
>>
>>>> +QEMU_PLUGIN_EXPORT
>>>> +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
>>>> + int argc, char **argv)
>>>> +{
>>>> + if (!info->system_emulation) {
>>>> + fputs("trap plugin can only be used in system emulation mode.\n",
>>>> + stderr);
>>>> + return -1;
>>>> + }
>>>> +
>>>> + max_vcpus = info->system.max_vcpus;
>>>> + traps = qemu_plugin_scoreboard_new(sizeof(TrapCounters));
>>>> + qemu_plugin_register_vcpu_init_cb(id, vcpu_init);
>>>> + qemu_plugin_vcpu_for_each(id, vcpu_init);
>>>>
>>> Hmm at first glances this seems redundant - however I guess this is
>>> covering the use case you load the plugin after the system is up and
>>> running.
>>
>> Yep, but really that was just me being paranoid.
>>
>>> I wonder if you have unearthed a foot-gun in the API that is easy to
>>> fall into? Maybe we should expand qemu_plugin_register_vcpu_init_cb to
>>> call the call back immediately for existing vcpus?
>>
>> Would probably not hurt.
>>
>> Regards,
>> Julian
>
next prev parent reply other threads:[~2025-01-10 21:03 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 19:26 [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 01/11] plugins: add types for callbacks related to certain discontinuities Julian Ganz
2024-12-03 8:45 ` Julian Ganz
2024-12-04 22:41 ` Pierrick Bouvier
2024-12-05 12:40 ` Julian Ganz
2024-12-05 17:56 ` Pierrick Bouvier
2024-12-05 21:50 ` Julian Ganz
2024-12-05 22:14 ` Julian Ganz
2024-12-05 23:03 ` Pierrick Bouvier
2024-12-06 8:58 ` Julian Ganz
2024-12-06 18:59 ` Pierrick Bouvier
2024-12-07 13:38 ` Julian Ganz
2024-12-09 18:52 ` Pierrick Bouvier
2024-12-04 22:45 ` Pierrick Bouvier
2024-12-05 12:44 ` Julian Ganz
2024-12-05 17:35 ` Pierrick Bouvier
2024-12-05 21:25 ` Julian Ganz
2025-01-09 13:52 ` Alex Bennée
2025-01-09 22:28 ` Pierrick Bouvier
2025-01-10 11:43 ` Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 02/11] plugins: add API for registering discontinuity callbacks Julian Ganz
2024-12-04 22:45 ` Pierrick Bouvier
2025-01-09 13:57 ` Alex Bennée
2025-01-10 11:40 ` Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 03/11] plugins: add hooks for new discontinuity related callbacks Julian Ganz
2024-12-04 22:47 ` Pierrick Bouvier
2025-01-09 13:58 ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 04/11] contrib/plugins: add plugin showcasing new dicontinuity related API Julian Ganz
2024-12-04 23:14 ` Pierrick Bouvier
2024-12-05 13:00 ` Julian Ganz
2024-12-05 17:23 ` Pierrick Bouvier
2025-01-09 14:04 ` Alex Bennée
2025-01-09 22:10 ` Pierrick Bouvier
2025-01-10 11:49 ` Julian Ganz
2025-01-10 15:15 ` Alex Bennée
2025-01-10 21:02 ` Pierrick Bouvier [this message]
2025-01-11 12:15 ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 05/11] target/alpha: call plugin trap callbacks Julian Ganz
2024-12-04 22:48 ` Pierrick Bouvier
2024-12-02 19:26 ` [RFC PATCH v3 06/11] target/arm: " Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 07/11] target/avr: " Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 08/11] target/mips: " Julian Ganz
2025-01-09 13:43 ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 09/11] target/riscv: " Julian Ganz
2024-12-03 4:39 ` Alistair Francis
2024-12-02 19:41 ` [RFC PATCH v3 10/11] target/sparc: " Julian Ganz
2025-01-09 13:46 ` Alex Bennée
2024-12-02 19:41 ` [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc Julian Ganz
2024-12-04 23:33 ` Pierrick Bouvier
2024-12-05 13:10 ` Julian Ganz
2024-12-05 17:30 ` Pierrick Bouvier
2024-12-05 21:22 ` Julian Ganz
2024-12-05 22:28 ` Pierrick Bouvier
2024-12-06 8:42 ` Julian Ganz
2024-12-06 19:02 ` Pierrick Bouvier
2024-12-06 19:42 ` Richard Henderson
2024-12-06 20:40 ` Pierrick Bouvier
2024-12-06 22:56 ` Richard Henderson
2024-12-07 13:47 ` Julian Ganz
2024-12-07 13:41 ` Julian Ganz
2024-12-20 11:47 ` Julian Ganz
2024-12-20 21:17 ` Pierrick Bouvier
2024-12-20 21:46 ` Pierrick Bouvier
2025-01-09 16:35 ` Alex Bennée
2025-01-09 16:33 ` Alex Bennée
2025-01-09 22:27 ` Pierrick Bouvier
2025-01-10 11:58 ` Julian Ganz
2024-12-03 8:36 ` [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities Julian Ganz
2024-12-04 22:51 ` Pierrick Bouvier
2025-01-09 16:43 ` 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=0369698c-0fbe-45f8-bad9-1e6a7b1ed410@linaro.org \
--to=pierrick.bouvier@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=erdnaxe@crans.org \
--cc=ma.mandourr@gmail.com \
--cc=neither@nut.email \
--cc=qemu-devel@nongnu.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).