linux-trace-devel.vger.kernel.org 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: Destroy synthetic and eprobes before other events
Date: Wed, 16 Oct 2024 12:35:52 -0400	[thread overview]
Message-ID: <20241016123552.55efa78f@gandalf.local.home> (raw)

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


             reply	other threads:[~2024-10-16 16:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16 16:35 Steven Rostedt [this message]
2024-10-17  8:38 ` [PATCH] libtracefs: Destroy synthetic and eprobes before other events 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

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=20241016123552.55efa78f@gandalf.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 NNTP newsgroup(s).