All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] trace-cmd reset: Clear all dynamic events
@ 2022-01-14 10:57 Tzvetomir Stoyanov (VMware)
  2022-02-12  2:56 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2022-01-14 10:57 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

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


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

* Re: [PATCH] trace-cmd reset: Clear all dynamic events
  2022-01-14 10:57 [PATCH] trace-cmd reset: Clear all dynamic events Tzvetomir Stoyanov (VMware)
@ 2022-02-12  2:56 ` Steven Rostedt
  2022-02-14  4:15   ` Tzvetomir Stoyanov
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2022-02-12  2:56 UTC (permalink / raw)
  To: Tzvetomir Stoyanov (VMware); +Cc: linux-trace-devel

On Fri, 14 Jan 2022 12:57:48 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> +	/* 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);
>  }

I accepted this patch, but really, tracefs needs something to define:

	TRACEFS_DYNEVENT_ALL

as callers should not have to call out each type of dynamic event.
Especially when we are about to add new dynamic events, causing this to
break again.

Want to add that?

Thanks Tzvetomir,

-- Steve

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

* Re: [PATCH] trace-cmd reset: Clear all dynamic events
  2022-02-12  2:56 ` Steven Rostedt
@ 2022-02-14  4:15   ` Tzvetomir Stoyanov
  0 siblings, 0 replies; 3+ messages in thread
From: Tzvetomir Stoyanov @ 2022-02-14  4:15 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Linux Trace Devel

On Sat, Feb 12, 2022 at 4:56 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Fri, 14 Jan 2022 12:57:48 +0200
> "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
>
> > +     /* 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);
> >  }
>
> I accepted this patch, but really, tracefs needs something to define:
>
>         TRACEFS_DYNEVENT_ALL
>
> as callers should not have to call out each type of dynamic event.
> Especially when we are about to add new dynamic events, causing this to
> break again.
>
> Want to add that?
>

Sure, I'll send a patch with that.
Thanks!


> Thanks Tzvetomir,
>
> -- Steve



-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

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

end of thread, other threads:[~2022-02-14  4:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 10:57 [PATCH] trace-cmd reset: Clear all dynamic events Tzvetomir Stoyanov (VMware)
2022-02-12  2:56 ` Steven Rostedt
2022-02-14  4:15   ` Tzvetomir Stoyanov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.