From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 1/2] libtracefs: New API to set synthetic event instance
Date: Tue, 28 Mar 2023 18:03:20 +0300 [thread overview]
Message-ID: <20230328150321.34808-2-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20230328150321.34808-1-tz.stoyanov@gmail.com>
The current implementation of tracefs_synth_create() API always creates
the synthetic event in the top trace instance - the "trigger" files of
the start and end events are updated in the context of the top instance.
Then the same synthetic event can be enabled and operates in any trace
instance. That logic works well in the most use cases, where there is a
single application, managing these events and the trace process.
However, there are use cases where multiple applications can run
different trace sessions, each in its own trace instance. For those use
cases, the default logic does not work well - the synthetic event can be
created by one application in the top instance, and cannot be reused
easily by any other applications in different trace instance.
The tracefs_synth structure already has an instance context, but there
is no way to set it to other than default top instance. That's why a new
API is introduced: tracefs_synth_set_instance(), which sets the instance
in the tracefs_synth structure. If that API is called before
tracefs_synth_create(), then the "trigger" files will be updated only in
the context of that user instance, instead of the default one. This
allows synthetic events to be more flexible and reduces the interference
between different trace instance.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
include/tracefs.h | 1 +
src/tracefs-hist.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/tracefs.h b/include/tracefs.h
index 3547b5a..9a53e0e 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -607,6 +607,7 @@ struct tracefs_hist *tracefs_synth_get_start_hist(struct tracefs_synth *synth);
int tracefs_synth_create(struct tracefs_synth *synth);
int tracefs_synth_destroy(struct tracefs_synth *synth);
void tracefs_synth_free(struct tracefs_synth *synth);
+int tracefs_synth_set_instance(struct tracefs_synth *synth, struct tracefs_instance *instance);
int tracefs_synth_echo_cmd(struct trace_seq *seq, struct tracefs_synth *synth);
int tracefs_synth_raw_fmt(struct trace_seq *seq, struct tracefs_synth *synth);
const char *tracefs_synth_show_event(struct tracefs_synth *synth);
diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index fb6231e..9141bbb 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -2178,6 +2178,25 @@ tracefs_synth_get_start_hist(struct tracefs_synth *synth)
return hist;
}
+/**
+ * tracefs_synth_set_instance - Set the ftrace instance of the synthetic events
+ * @synth: The tracefs_synth descriptor
+ * @instance: ftrace instance
+ *
+ * Set the ftrace instance, in which the synthetic event will be created. By default,
+ * the top instance is used. This API must be called before the call to tracefs_synth_create(),
+ * in order to use the new instance when creating the event.
+ *
+ * Returns 0 on success and -1 on error.
+ */
+int tracefs_synth_set_instance(struct tracefs_synth *synth, struct tracefs_instance *instance)
+{
+ if (!synth)
+ return -1;
+ synth->instance = instance;
+ return 0;
+}
+
/**
* tracefs_synth_create - creates the synthetic event on the system
* @synth: The tracefs_synth descriptor
--
2.39.2
next prev parent reply other threads:[~2023-03-28 15:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 15:03 [PATCH 0/2] Introduce new API to set synthetic event instance Tzvetomir Stoyanov (VMware)
2023-03-28 15:03 ` Tzvetomir Stoyanov (VMware) [this message]
2023-03-28 15:03 ` [PATCH 2/2] libtracefs: Documentation for tracefs_synth_set_instance Tzvetomir Stoyanov (VMware)
2023-05-30 4:50 ` Steven Rostedt
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=20230328150321.34808-2-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.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).