From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH] trace-cmd reset: Clear all dynamic events
Date: Fri, 14 Jan 2022 12:57:48 +0200 [thread overview]
Message-ID: <20220114105748.46761-1-tz.stoyanov@gmail.com> (raw)
The "trace-cmd reset" command should set ftrace state to default,
including all dynamically created events. Currently only synthetic events
are deleted. The command is enhanced to delete all dynamic events, using
the new tracefs library API for dynamic events.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
tracecmd/trace-record.c | 43 ++++++++++-------------------------------
1 file changed, 10 insertions(+), 33 deletions(-)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index b4200db1..aee3b01a 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -5221,41 +5221,18 @@ static void clear_error_log(void)
clear_instance_error_log(instance);
}
-static void clear_all_synth_events(void)
+static void clear_all_dynamic_events(void)
{
- char sevent[BUFSIZ];
- char *save = NULL;
- char *line;
- char *file;
- char *buf;
- int len;
-
- file = tracefs_instance_get_file(NULL, "synthetic_events");
- if (!file)
- return;
-
- buf = read_file(file);
- if (!buf)
- goto out;
-
- sevent[0] = '!';
-
- for (line = strtok_r(buf, "\n", &save); line; line = strtok_r(NULL, "\n", &save)) {
- len = strlen(line);
- if (len > BUFSIZ - 2)
- len = BUFSIZ - 2;
- strncpy(sevent + 1, line, len);
- sevent[len + 1] = '\0';
- write_file(file, sevent);
- }
-out:
- free(buf);
- tracefs_put_tracing_file(file);
-
+ /* Clear event probes first, as they may be attached to other dynamic event */
+ tracefs_dynevent_destroy_all(TRACEFS_DYNEVENT_EPROBE, true);
+ tracefs_dynevent_destroy_all(TRACEFS_DYNEVENT_KPROBE |
+ TRACEFS_DYNEVENT_KRETPROBE |
+ TRACEFS_DYNEVENT_UPROBE |
+ TRACEFS_DYNEVENT_URETPROBE |
+ TRACEFS_DYNEVENT_SYNTH,
+ true);
}
-
-
static void clear_func_filters(void)
{
struct buffer_instance *instance;
@@ -5951,7 +5928,7 @@ void trace_reset(int argc, char **argv)
set_buffer_size();
clear_filters();
clear_triggers();
- clear_all_synth_events();
+ clear_all_dynamic_events();
clear_error_log();
/* set clock to "local" */
reset_clock();
--
2.34.1
next reply other threads:[~2022-01-14 10:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 10:57 Tzvetomir Stoyanov (VMware) [this message]
2022-02-12 2:56 ` [PATCH] trace-cmd reset: Clear all dynamic events Steven Rostedt
2022-02-14 4:15 ` Tzvetomir Stoyanov
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=20220114105748.46761-1-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).