linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libtracefs: Destroy synthetic and eprobes before other events
@ 2024-10-16 16:35 Steven Rostedt
  2024-10-17  8:38 ` Metin Kaya
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Rostedt @ 2024-10-16 16:35 UTC (permalink / raw)
  To: Linux Trace Devel

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

Synthetic events can be based on eprobes and other dynamic events. When
destroying multiple events via tracefs_dynevent_destroy() make sure to
remove the synthetic events first, followed by eprobes (as they can be on
other dynamic events as well), then the rest of the dynamic events.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-dynevents.c | 42 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/src/tracefs-dynevents.c b/src/tracefs-dynevents.c
index 6df7212fb38e..77bdf94fdbfe 100644
--- a/src/tracefs-dynevents.c
+++ b/src/tracefs-dynevents.c
@@ -654,6 +654,22 @@ tracefs_dynevent_get(enum tracefs_dynevent_type type, const char *system,
 	return devent;
 }
 
+static int destroy_dynevents(struct tracefs_dynevent **all, bool force)
+{
+	int ret = 0;
+	int i;
+
+	if (!all)
+		return 0;
+
+	for (i = 0; all[i]; i++) {
+		if (tracefs_dynevent_destroy(all[i], force))
+			ret = -1;
+	}
+
+	return ret;
+}
+
 /**
  * tracefs_dynevent_destroy_all - removes all dynamic events of given types from the system
  * @types: Dynamic event type, or bitmask of dynamic event types. If 0 is passed, all types
@@ -671,16 +687,32 @@ int tracefs_dynevent_destroy_all(unsigned int types, bool force)
 {
 	struct tracefs_dynevent **all;
 	int ret = 0;
-	int i;
 
+	/*
+	 * Destroy synthetic events first, as they may depend on
+	 * other dynamic events.
+	 */
+	if (types & TRACEFS_DYNEVENT_SYNTH) {
+		all = tracefs_dynevent_get_all(TRACEFS_DYNEVENT_SYNTH, NULL);
+		ret = destroy_dynevents(all, force);
+		tracefs_dynevent_list_free(all);
+		types &= ~TRACEFS_DYNEVENT_SYNTH;
+	}
+
+	/* Eprobes may depend on other events as well */
+	if (types & TRACEFS_DYNEVENT_EPROBE) {
+		all = tracefs_dynevent_get_all(TRACEFS_DYNEVENT_EPROBE, NULL);
+		ret |= destroy_dynevents(all, force);
+		tracefs_dynevent_list_free(all);
+		types &= ~TRACEFS_DYNEVENT_EPROBE;
+	}
+
+	/* Destroy the rest */
 	all = tracefs_dynevent_get_all(types, NULL);
 	if (!all)
 		return 0;
 
-	for (i = 0; all[i]; i++) {
-		if (tracefs_dynevent_destroy(all[i], force))
-			ret = -1;
-	}
+	ret |= destroy_dynevents(all, force);
 
 	tracefs_dynevent_list_free(all);
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-20  7:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-16 16:35 [PATCH] libtracefs: Destroy synthetic and eprobes before other events Steven Rostedt
2024-10-17  8:38 ` Metin Kaya
2024-10-17 20:01   ` Steven Rostedt
2024-10-18  9:13     ` Metin Kaya
2024-10-18 14:17       ` Steven Rostedt
2024-10-18 14:51         ` Metin Kaya
2024-11-20  3:57           ` Steven Rostedt
2024-11-20  7:42             ` Metin Kaya

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).