From: Richard Henderson <richard.henderson@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>, qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v3 05/17] plugins: scoreboard API
Date: Wed, 7 Feb 2024 13:21:24 +1000 [thread overview]
Message-ID: <e4db51de-a040-4c9e-93fa-64a378e4e5fa@linaro.org> (raw)
In-Reply-To: <20240206092423.3005995-6-pierrick.bouvier@linaro.org>
On 2/6/24 19:24, Pierrick Bouvier wrote:
> We introduce a cpu local storage, automatically managed (and extended)
> by QEMU itself. Plugin allocate a scoreboard, and don't have to deal
> with how many cpus are launched.
>
> This API will be used by new inline functions but callbacks can benefit
> from this as well. This way, they can operate without a global lock for
> simple operations.
>
> At any point during execution, any scoreboard will be dimensioned with
> at least qemu_plugin_num_vcpus entries.
>
> New functions:
> - qemu_plugin_scoreboard_find
> - qemu_plugin_scoreboard_free
> - qemu_plugin_scoreboard_new
>
> In more, we define a qemu_plugin_u64, which is a simple struct holding
> a pointer to a scoreboard, and a given offset.
> This allows to have a scoreboard containing structs, without having to
> bring offset for all operations on a specific field.
>
> Since most of the plugins are simply collecting a sum of per-cpu values,
> qemu_plugin_u64 directly support this operation as well.
>
> New functions:
> - qemu_plugin_u64_add
> - qemu_plugin_u64_get
> - qemu_plugin_u64_set
> - qemu_plugin_u64_sum
> New macros:
> - qemu_plugin_scoreboard_u64
> - qemu_plugin_scoreboard_u64_in_struct
I think the u64 stuff should be a second patch built upon the basic scoreboard support.
> +/* A scoreboard is an array of values, indexed by vcpu_index */
> +struct qemu_plugin_scoreboard {
> + GArray *data;
> +};
Unnecessary? Generates an extra pointer dereference for no apparent benefit.
Alternately, might be useful for other data structure changes...
> +/**
> + * typedef qemu_plugin_u64 - uint64_t member of an entry in a scoreboard
> + *
> + * This field allows to access a specific uint64_t member in one given entry,
> + * located at a specified offset. Inline operations expect this as entry.
> + */
> +typedef struct {
> + struct qemu_plugin_scoreboard *score;
Embed the struct instead?
> @@ -31,6 +31,9 @@ struct qemu_plugin_state {
> * but with the HT we avoid adding a field to CPUState.
> */
> GHashTable *cpu_ht;
> + /* Scoreboards, indexed by their addresses. */
> + GHashTable *scoreboards;
Why a hash table? All you want is to be able to iterate through all, and add/remove
easily. Seems like QLIST from <qemu/queue.h> would be better, and the QLIST_ENTRY member
would make struct qemu_plugin_scoreboard useful.
r~
next prev parent reply other threads:[~2024-02-07 3:22 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 9:24 [PATCH v3 00/17] TCG Plugin inline operation enhancement Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 01/17] plugins: remove previous n_vcpus functions from API Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 02/17] plugins: add qemu_plugin_num_vcpus function Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 03/17] plugins: fix order of init/idle/resume callback Pierrick Bouvier
2024-02-07 2:59 ` Richard Henderson
2024-02-06 9:24 ` [PATCH v3 04/17] cpu: call plugin init hook asynchronously Pierrick Bouvier
2024-02-07 3:00 ` Richard Henderson
2024-02-06 9:24 ` [PATCH v3 05/17] plugins: scoreboard API Pierrick Bouvier
2024-02-07 3:21 ` Richard Henderson [this message]
2024-02-07 5:59 ` Pierrick Bouvier
2024-02-11 0:41 ` Richard Henderson
2024-02-11 14:26 ` Pierrick Bouvier
2024-02-11 19:13 ` Richard Henderson
2024-02-12 6:24 ` Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 06/17] docs/devel: plugins can trigger a tb flush Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 07/17] plugins: implement inline operation relative to cpu_index Pierrick Bouvier
2024-02-07 3:42 ` Richard Henderson
2024-02-07 6:01 ` Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 08/17] plugins: add inline operation per vcpu Pierrick Bouvier
2024-02-07 3:45 ` Richard Henderson
2024-02-07 6:05 ` Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 09/17] tests/plugin: add test plugin for inline operations Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 10/17] tests/plugin/mem: migrate to new per_vcpu API Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 11/17] tests/plugin/insn: " Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 12/17] tests/plugin/bb: " Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 13/17] contrib/plugins/hotblocks: " Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 14/17] contrib/plugins/howvec: " Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 15/17] plugins: remove non per_vcpu inline operation from API Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 16/17] plugins: cleanup codepath for previous inline operation Pierrick Bouvier
2024-02-06 9:24 ` [PATCH v3 17/17] MAINTAINERS: Add myself as reviewer for TCG Plugins Pierrick Bouvier
2024-02-07 15:45 ` [PATCH v3 00/17] TCG Plugin inline operation enhancement Alex Bennée
2024-02-07 16:06 ` Alex Bennée
2024-02-07 18:21 ` Pierrick Bouvier
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=e4db51de-a040-4c9e-93fa-64a378e4e5fa@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=eduardo@habkost.net \
--cc=erdnaxe@crans.org \
--cc=ma.mandourr@gmail.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=wangyanan55@huawei.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 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).