linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Display more ftrace configuration by trace-cmd stat
@ 2020-04-21 10:47 Tzvetomir Stoyanov (VMware)
  2020-04-21 10:47 ` [PATCH 1/2] trace-cmd: Add helper function to print content of a trace file Tzvetomir Stoyanov (VMware)
  2020-04-21 10:47 ` [PATCH 2/2] trace-cmd: Print configured filtered PIDs in trace-cmd stat command Tzvetomir Stoyanov (VMware)
  0 siblings, 2 replies; 4+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2020-04-21 10:47 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

Display configured filtered PIDs in trace-cmd stat command.

Tzvetomir Stoyanov (VMware) (2):
  trace-cmd: Add helper function to print content of a trace file
  trace-cmd: Print configured filtered PIDs in trace-cmd stat command

 tracecmd/trace-stat.c | 80 +++++++++++++------------------------------
 1 file changed, 24 insertions(+), 56 deletions(-)

-- 
2.25.3


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

* [PATCH 1/2] trace-cmd: Add helper function to print content of a trace file
  2020-04-21 10:47 [PATCH 0/2] Display more ftrace configuration by trace-cmd stat Tzvetomir Stoyanov (VMware)
@ 2020-04-21 10:47 ` Tzvetomir Stoyanov (VMware)
  2020-07-02 18:10   ` Steven Rostedt
  2020-04-21 10:47 ` [PATCH 2/2] trace-cmd: Print configured filtered PIDs in trace-cmd stat command Tzvetomir Stoyanov (VMware)
  1 sibling, 1 reply; 4+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2020-04-21 10:47 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

trace-cmd stat command prints various information about the current
ftrace configuration. Some of it is just a dump of a ftrace file.
These functions from trace-stat.c have almost the same logic:
 report_plugin()
 report_latency()
 report_errorlog()
A helper function is added, implementing this common logic:
 report_file()

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 tracecmd/trace-stat.c | 77 ++++++++++++-------------------------------
 1 file changed, 21 insertions(+), 56 deletions(-)

diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c
index c5057978..2e3d83c3 100644
--- a/tracecmd/trace-stat.c
+++ b/tracecmd/trace-stat.c
@@ -122,6 +122,24 @@ static char *get_instance_file_content(struct buffer_instance *instance,
 	return str;
 }
 
+static void report_file(struct buffer_instance *instance,
+			char *name, char *def_value, char *description)
+{
+	char *str;
+	char *cont;
+
+	if (!tracefs_file_exists(instance->tracefs, name))
+		return;
+	str = get_instance_file_content(instance, name);
+	if (!str)
+		return;
+	cont = strstrip(str);
+	if (cont[0] && strcmp(cont, def_value))
+		printf("\n%s%s\n", description, cont);
+
+	free(str);
+}
+
 static void report_instances(void)
 {
 	struct dirent *dent;
@@ -166,26 +184,6 @@ out:
 	tracefs_put_tracing_file(path);
 }
 
-static void report_plugin(struct buffer_instance *instance)
-{
-	char *str;
-	char *cont;
-
-	str = get_instance_file_content(instance, "current_tracer");
-	if (!str)
-		return;
-
-	cont = strstrip(str);
-
-	/* We only care if the plugin is something other than nop */
-	if (strcmp(cont, "nop") == 0)
-		goto out;
-
-	printf("\nTracer: %s\n", cont);
- out:
-	free(str);
-}
-
 struct event_iter *trace_event_iter_alloc(const char *path)
 {
 	struct event_iter *iter;
@@ -817,23 +815,6 @@ static void report_cpumask(struct buffer_instance *instance)
 	free(str);
 }
 
-static void report_latency(struct buffer_instance *instance)
-{
-	char *str;
-	char *cont;
-
-	str = get_instance_file_content(instance, "tracing_max_latency");
-	if (!str)
-		return;
-
-	cont = strstrip(str);
-
-	if (strcmp(cont, "0") != 0)
-		printf("\nMax Latency: %s\n", cont);
-
-	free(str);
-}
-
 static void report_probes(struct buffer_instance *instance,
 			  const char *file, const char *string)
 {
@@ -897,22 +878,6 @@ static void report_traceon(struct buffer_instance *instance)
 	free(str);
 }
 
-static void report_errorlog(struct buffer_instance *instance)
-{
-	char *str;
-
-	if (!tracefs_file_exists(instance->tracefs, "error_log"))
-		return;
-	str = get_instance_file_content(instance, "error_log");
-	if (!str)
-		return;
-
-	if (str[0])
-		printf("\nError log:\n%s\n", str);
-
-	free(str);
-}
-
 static void stat_instance(struct buffer_instance *instance)
 {
 	if (instance != &top_instance) {
@@ -923,7 +888,7 @@ static void stat_instance(struct buffer_instance *instance)
 	} else
 		report_instances();
 
-	report_plugin(instance);
+	report_file(instance, "current_tracer", "nop", "Tracer: ");
 	report_events(instance);
 	report_event_filters(instance);
 	report_event_triggers(instance);
@@ -932,11 +897,11 @@ static void stat_instance(struct buffer_instance *instance)
 	report_buffers(instance);
 	report_clock(instance);
 	report_cpumask(instance);
-	report_latency(instance);
+	report_file(instance, "tracing_max_latency", "0", "Max Latency: ");
 	report_kprobes(instance);
 	report_uprobes(instance);
 	report_traceon(instance);
-	report_errorlog(instance);
+	report_file(instance, "error_log", "", "Error log:\n");
 }
 
 void trace_stat (int argc, char **argv)
-- 
2.25.3


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

* [PATCH 2/2] trace-cmd: Print configured filtered PIDs in trace-cmd stat command
  2020-04-21 10:47 [PATCH 0/2] Display more ftrace configuration by trace-cmd stat Tzvetomir Stoyanov (VMware)
  2020-04-21 10:47 ` [PATCH 1/2] trace-cmd: Add helper function to print content of a trace file Tzvetomir Stoyanov (VMware)
@ 2020-04-21 10:47 ` Tzvetomir Stoyanov (VMware)
  1 sibling, 0 replies; 4+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2020-04-21 10:47 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

Print information of currently configured filtered event PIDs and
filtered function tracer PIDs in trace-cmd stat command. This information
is part of the ftrace configuration and should be displayed by the stat command.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 tracecmd/trace-stat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c
index 2e3d83c3..e9369842 100644
--- a/tracecmd/trace-stat.c
+++ b/tracecmd/trace-stat.c
@@ -900,6 +900,9 @@ static void stat_instance(struct buffer_instance *instance)
 	report_file(instance, "tracing_max_latency", "0", "Max Latency: ");
 	report_kprobes(instance);
 	report_uprobes(instance);
+	report_file(instance, "set_event_pid", "", "Filtered event PIDs:\n");
+	report_file(instance, "set_ftrace_pid", "no pid",
+		    "Filtered function tracer PIDs:\n");
 	report_traceon(instance);
 	report_file(instance, "error_log", "", "Error log:\n");
 }
-- 
2.25.3


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

* Re: [PATCH 1/2] trace-cmd: Add helper function to print content of a trace file
  2020-04-21 10:47 ` [PATCH 1/2] trace-cmd: Add helper function to print content of a trace file Tzvetomir Stoyanov (VMware)
@ 2020-07-02 18:10   ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-07-02 18:10 UTC (permalink / raw)
  To: Tzvetomir Stoyanov (VMware); +Cc: linux-trace-devel

On Tue, 21 Apr 2020 13:47:12 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> trace-cmd stat command prints various information about the current
> ftrace configuration. Some of it is just a dump of a ftrace file.
> These functions from trace-stat.c have almost the same logic:
>  report_plugin()
>  report_latency()
>  report_errorlog()
> A helper function is added, implementing this common logic:
>  report_file()
> 
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
>  tracecmd/trace-stat.c | 77 ++++++++++++-------------------------------
>  1 file changed, 21 insertions(+), 56 deletions(-)
> 

Hi Tzvetomir,

I didn't realize how old this patch was, just noticed it in patchwork :-p

Anyway, I applied it with the following update (the change log spacing,
and used "strncmp() != 0" instead of "strncmp()".

-- Steve

From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Date: Tue, 21 Apr 2020 13:47:12 +0300
Subject: [PATCH] trace-cmd: Add helper function to print content of a trace
 file

trace-cmd stat command prints various information about the current
ftrace configuration. Some of it is just a dump of a ftrace file.
These functions from trace-stat.c have almost the same logic:

 report_plugin()
 report_latency()
 report_errorlog()

A helper function is added, implementing this common logic:

 report_file()

Link: https://lore.kernel.org/linux-trace-devel/20200421104713.31762-2-tz.stoyanov@gmail.com

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
[ Use strcmp() != 0 instead of just strncmp() ]
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/trace-stat.c | 77 ++++++++++++-------------------------------
 1 file changed, 21 insertions(+), 56 deletions(-)

diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c
index bd0e647a..8ab686da 100644
--- a/tracecmd/trace-stat.c
+++ b/tracecmd/trace-stat.c
@@ -122,6 +122,24 @@ static char *get_instance_file_content(struct buffer_instance *instance,
 	return str;
 }
 
+static void report_file(struct buffer_instance *instance,
+			char *name, char *def_value, char *description)
+{
+	char *str;
+	char *cont;
+
+	if (!tracefs_file_exists(instance->tracefs, name))
+		return;
+	str = get_instance_file_content(instance, name);
+	if (!str)
+		return;
+	cont = strstrip(str);
+	if (cont[0] && strcmp(cont, def_value) != 0)
+		printf("\n%s%s\n", description, cont);
+
+	free(str);
+}
+
 static void report_instances(void)
 {
 	struct dirent *dent;
@@ -166,26 +184,6 @@ out:
 	tracefs_put_tracing_file(path);
 }
 
-static void report_plugin(struct buffer_instance *instance)
-{
-	char *str;
-	char *cont;
-
-	str = get_instance_file_content(instance, "current_tracer");
-	if (!str)
-		return;
-
-	cont = strstrip(str);
-
-	/* We only care if the plugin is something other than nop */
-	if (strcmp(cont, "nop") == 0)
-		goto out;
-
-	printf("\nTracer: %s\n", cont);
- out:
-	free(str);
-}
-
 struct event_iter *trace_event_iter_alloc(const char *path)
 {
 	struct event_iter *iter;
@@ -817,23 +815,6 @@ static void report_cpumask(struct buffer_instance *instance)
 	free(str);
 }
 
-static void report_latency(struct buffer_instance *instance)
-{
-	char *str;
-	char *cont;
-
-	str = get_instance_file_content(instance, "tracing_max_latency");
-	if (!str)
-		return;
-
-	cont = strstrip(str);
-
-	if (strcmp(cont, "0") != 0)
-		printf("\nMax Latency: %s\n", cont);
-
-	free(str);
-}
-
 static void report_probes(struct buffer_instance *instance,
 			  const char *file, const char *string)
 {
@@ -897,22 +878,6 @@ static void report_traceon(struct buffer_instance *instance)
 	free(str);
 }
 
-static void report_errorlog(struct buffer_instance *instance)
-{
-	char *str;
-
-	if (!tracefs_file_exists(instance->tracefs, "error_log"))
-		return;
-	str = get_instance_file_content(instance, "error_log");
-	if (!str)
-		return;
-
-	if (str[0])
-		printf("\nError log:\n%s\n", str);
-
-	free(str);
-}
-
 static void stat_instance(struct buffer_instance *instance)
 {
 	if (instance != &top_instance) {
@@ -922,7 +887,7 @@ static void stat_instance(struct buffer_instance *instance)
 			tracefs_instance_get_name(instance->tracefs));
 	}
 
-	report_plugin(instance);
+	report_file(instance, "current_tracer", "nop", "Tracer: ");
 	report_events(instance);
 	report_event_filters(instance);
 	report_event_triggers(instance);
@@ -931,11 +896,11 @@ static void stat_instance(struct buffer_instance *instance)
 	report_buffers(instance);
 	report_clock(instance);
 	report_cpumask(instance);
-	report_latency(instance);
+	report_file(instance, "tracing_max_latency", "0", "Max Latency: ");
 	report_kprobes(instance);
 	report_uprobes(instance);
 	report_traceon(instance);
-	report_errorlog(instance);
+	report_file(instance, "error_log", "", "Error log:\n");
 	if (instance == &top_instance)
 		report_instances();
 }
-- 
2.25.4


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

end of thread, other threads:[~2020-07-02 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 10:47 [PATCH 0/2] Display more ftrace configuration by trace-cmd stat Tzvetomir Stoyanov (VMware)
2020-04-21 10:47 ` [PATCH 1/2] trace-cmd: Add helper function to print content of a trace file Tzvetomir Stoyanov (VMware)
2020-07-02 18:10   ` Steven Rostedt
2020-04-21 10:47 ` [PATCH 2/2] trace-cmd: Print configured filtered PIDs in trace-cmd stat command Tzvetomir Stoyanov (VMware)

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