From: Sven Schnelle <svens@stackframe.org>
To: "Alex Bennée" <alex.bennee@linaro.org>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>
Cc: qemu-devel@nongnu.org, deller@gmx.de,
Sven Schnelle <svens@stackframe.org>
Subject: [PATCH 1/4] plugins/execlog: add struct execlog_ctx
Date: Wed, 28 Feb 2024 21:02:08 +0100 [thread overview]
Message-ID: <20240228200211.1512816-2-svens@stackframe.org> (raw)
In-Reply-To: <20240228200211.1512816-1-svens@stackframe.org>
Add a context structure for future enhancements. No functional
change intended.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
contrib/plugins/execlog.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c
index 82dc2f584e..90da1911b2 100644
--- a/contrib/plugins/execlog.c
+++ b/contrib/plugins/execlog.c
@@ -24,6 +24,10 @@ static GRWLock expand_array_lock;
static GPtrArray *imatches;
static GArray *amatches;
+struct execlog_ctx {
+ GString *s;
+};
+
/*
* Expand last_exec array.
*
@@ -34,8 +38,9 @@ static void expand_last_exec(int cpu_index)
{
g_rw_lock_writer_lock(&expand_array_lock);
while (cpu_index >= last_exec->len) {
- GString *s = g_string_new(NULL);
- g_ptr_array_add(last_exec, s);
+ struct execlog_ctx *ctx = g_new(struct execlog_ctx, 1);
+ ctx->s = g_string_new(NULL);
+ g_ptr_array_add(last_exec, ctx);
}
g_rw_lock_writer_unlock(&expand_array_lock);
}
@@ -46,14 +51,13 @@ static void expand_last_exec(int cpu_index)
static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info,
uint64_t vaddr, void *udata)
{
- GString *s;
-
/* Find vCPU in array */
g_rw_lock_reader_lock(&expand_array_lock);
g_assert(cpu_index < last_exec->len);
- s = g_ptr_array_index(last_exec, cpu_index);
+ struct execlog_ctx *ctx = g_ptr_array_index(last_exec, cpu_index);
g_rw_lock_reader_unlock(&expand_array_lock);
+ GString *s = ctx->s;
/* Indicate type of memory access */
if (qemu_plugin_mem_is_store(info)) {
g_string_append(s, ", store");
@@ -77,8 +81,6 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info,
*/
static void vcpu_insn_exec(unsigned int cpu_index, void *udata)
{
- GString *s;
-
/* Find or create vCPU in array */
g_rw_lock_reader_lock(&expand_array_lock);
if (cpu_index >= last_exec->len) {
@@ -86,8 +88,9 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata)
expand_last_exec(cpu_index);
g_rw_lock_reader_lock(&expand_array_lock);
}
- s = g_ptr_array_index(last_exec, cpu_index);
+ struct execlog_ctx *ctx = g_ptr_array_index(last_exec, cpu_index);
g_rw_lock_reader_unlock(&expand_array_lock);
+ GString *s = ctx->s;
/* Print previous instruction in cache */
if (s->len) {
@@ -183,9 +186,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
static void plugin_exit(qemu_plugin_id_t id, void *p)
{
guint i;
- GString *s;
+
for (i = 0; i < last_exec->len; i++) {
- s = g_ptr_array_index(last_exec, i);
+ struct execlog_ctx *ctx = g_ptr_array_index(last_exec, i);
+ GString *s = ctx->s;
if (s->str) {
qemu_plugin_outs(s->str);
qemu_plugin_outs("\n");
--
2.43.2
next prev parent reply other threads:[~2024-02-28 20:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 20:02 [PATCH 0/4] plugins/execlog: add data address match and address range support Sven Schnelle
2024-02-28 20:02 ` Sven Schnelle [this message]
2024-02-28 20:02 ` [PATCH 2/4] plugins/execlog: pass matches array to parse_vaddr_match Sven Schnelle
2024-02-28 20:02 ` [PATCH 3/4] plugins/execlog: add data address match Sven Schnelle
2024-02-28 20:02 ` [PATCH 4/4] plugins/execlog: add address range matching Sven Schnelle
2024-02-29 6:05 ` [PATCH 0/4] plugins/execlog: add data address match and address range support Pierrick Bouvier
2024-02-29 15:09 ` Sven Schnelle
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=20240228200211.1512816-2-svens@stackframe.org \
--to=svens@stackframe.org \
--cc=alex.bennee@linaro.org \
--cc=deller@gmx.de \
--cc=erdnaxe@crans.org \
--cc=ma.mandourr@gmail.com \
--cc=pierrick.bouvier@linaro.org \
--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).