Linux-Trace-Devel Archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] libtracefs: Fix tracefs_instance_reset to clear synthetic events
Date: Fri, 5 Jan 2024 23:57:20 -0500	[thread overview]
Message-ID: <20240105235720.6f0bb664@rorschach.local.home> (raw)

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

tracefs_instance_reset() was not clearing synthetic events as there's an
order that is needed in clearing out the triggers.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-instance.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c
index b94630a324a1..0ee0225e0222 100644
--- a/src/tracefs-instance.c
+++ b/src/tracefs-instance.c
@@ -1481,9 +1481,12 @@ void tracefs_instance_reset(struct tracefs_instance *instance)
 	int has_trigger = -1;
 	char **systems;
 	struct stat st;
+	char **file_list = NULL;
+	int list_size = 0;
 	char **events;
 	char *file;
 	int i, j;
+	int ret;
 
 	tracefs_trace_off(instance);
 	disable_func_stack_trace_instance(instance);
@@ -1514,8 +1517,15 @@ void tracefs_instance_reset(struct tracefs_instance *instance)
 					else
 						has_trigger = 1;
 				}
-				if (has_trigger)
-					clear_trigger(file);
+				if (has_trigger) {
+					ret = clear_trigger(file);
+					if (ret) {
+						char **list;
+						list = tracefs_list_add(file_list, file);
+						if (list)
+							file_list = list;
+					}
+				}
 				tracefs_put_tracing_file(file);
 			}
 			tracefs_list_free(events);
@@ -1523,6 +1533,25 @@ void tracefs_instance_reset(struct tracefs_instance *instance)
 		tracefs_list_free(systems);
 	}
 
+	while (file_list && list_size != tracefs_list_size(file_list)) {
+		char **list = file_list;
+
+		list_size = tracefs_list_size(file_list);
+		file_list = NULL;
+		for (i = 0; list[i]; i++) {
+			ret = clear_trigger(file);
+			if (ret) {
+				char **tlist;
+				tlist = tracefs_list_add(file_list, list[i]);
+				if (tlist)
+					file_list = tlist;
+			}
+		}
+		tracefs_list_free(list);
+	}
+	tracefs_list_free(file_list);
+
+	tracefs_instance_file_write(instance, "synthetic_events", " ");
 	tracefs_instance_file_write(instance, "error_log", " ");
 	tracefs_instance_file_write(instance, "trace_clock", "local");
 	tracefs_instance_file_write(instance, "set_event_pid", "");
-- 
2.42.0


                 reply	other threads:[~2024-01-06  4:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240105235720.6f0bb664@rorschach.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).