Skip to contentSkip to conversation

tracing/ftrace: handle more than one stat file per tracer

PATCH Superseded Frederic Weisbecker 2 participants 4 messages Jan 7, 2009 – Jan 8, 2009 Tracing

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 tracing/ftrace: handle more than one stat file per tracer

Impact: new API for tracers

Make the stat tracing API reentrant. And also provide the new directory /debugfs/tracing/trace_stat which will contain all the stat files for the current active tracer.

Now a tracer will, if desired, want to provide a zero terminated array of tracer_stat structures.
Each one contains the callbacks necessary for one stat file. It have to provide at least a name for its stat file, an iterator with stat_start/start_next callback and an output callback for one stat entry.

Changes in v2:

_ Apply the previous memory leak fix (rebase against tip/master)

---
 kernel/trace/trace.h      |   35 ++++---
 kernel/trace/trace_stat.c |  230 +++++++++++++++++++++++++++++++++------------
 2 files changed, 189 insertions(+), 76 deletions(-)
kernel/trace/trace.h +20 -15
index 94ed45e..b3f9ad1 100644
@@ -335,6 +335,25 @@ struct tracer_flags {
 #define TRACER_OPT(s, b)	.name = #s, .bit = b
 
 /*
+ * If you want to provide a stat file (one-shot statistics), fill
+ * an iterator with stat_start/stat_next and a stat_show callbacks.
+ * The others callbacks are optional.
+ */
+struct tracer_stat {
+	/* The name of your stat file */
+	const char		*name;
+	/* Iteration over statistic entries */
+	void			*(*stat_start)(void);
+	void			*(*stat_next)(void *prev, int idx);
+	/* Compare two entries for stats sorting (optional) */
+	int			(*stat_cmp)(void *p1, void *p2);
+	/* Print a stat entry */
+	int			(*stat_show)(struct seq_file *s, void *p);
+	/* Print the headers of your stat entries */
+	int			(*stat_headers)(struct seq_file *s);
+};
+
+/*
  * A specific tracer, represented by methods that operate on a trace array:
  */
 struct tracer {
@@ -361,21 +380,7 @@ struct tracer {
 	struct tracer		*next;
 	int			print_max;
 	struct tracer_flags 	*flags;
-
-	/*
-	 * If you change one of the following on tracing runtime, recall
-	 * init_tracer_stat()
-	 */
-
-	/* Iteration over statistic entries */
-	void			*(*stat_start)(void);
-	void			*(*stat_next)(void *prev, int idx);
-	/* Compare two entries for sorting (optional) for stats */
-	int			(*stat_cmp)(void *p1, void *p2);
-	/* Print a stat entry */
-	int			(*stat_show)(struct seq_file *s, void *p);
-	/* Print the headers of your stat entries */
-	int			(*stat_headers)(struct seq_file *s);
+	struct tracer_stat	*stats;
 };
 
 struct trace_seq {
kernel/trace/trace_stat.c +169 -61

349 lines not on this page · raw message

Signature · 1 line
1.6.0.4
maintainer
#1 lore raw
Quoted 6 lines · Frederic Weisbecker

Impact: new API for tracers

Make the stat tracing API reentrant. And also provide the new directory /debugfs/tracing/trace_stat which will contain all the stat files for the current active tracer.

Quoted 8 lines

Now a tracer will, if desired, want to provide a zero terminated array of tracer_stat structures.
Each one contains the callbacks necessary for one stat file. It have to provide at least a name for its stat file, an iterator with stat_start/start_next callback and an output callback for one stat entry.

Changes in v2:

Hi Frederic,

This patch fails to compile the branch tracer by itself. No patch should break a build (for bisecting reasons).

-- Steve

#2 lore raw
Quoted 18 lines · Steven Rostedt
Quoted 6 lines · Frederic Weisbecker

Impact: new API for tracers

Make the stat tracing API reentrant. And also provide the new directory /debugfs/tracing/trace_stat which will contain all the stat files for the current active tracer.

Quoted 8 lines

Now a tracer will, if desired, want to provide a zero terminated array of tracer_stat structures.
Each one contains the callbacks necessary for one stat file. It have to provide at least a name for its stat file, an iterator with stat_start/start_next callback and an output callback for one stat entry.

Changes in v2:

Quoted 7 lines

Hi Frederic,

This patch fails to compile the branch tracer by itself. No patch should break a build (for bisecting reasons).

-- Steve

Hmm. Yes, so perhaps I can resend the two patches in one?

maintainer
#3 lore raw
Quoted 21 lines · Frederic Weisbecker
Quoted 20 lines · Steven Rostedt
Quoted 6 lines · Frederic Weisbecker

Impact: new API for tracers

Make the stat tracing API reentrant. And also provide the new directory /debugfs/tracing/trace_stat which will contain all the stat files for the current active tracer.

Quoted 8 lines

Now a tracer will, if desired, want to provide a zero terminated array of tracer_stat structures.
Each one contains the callbacks necessary for one stat file. It have to provide at least a name for its stat file, an iterator with stat_start/start_next callback and an output callback for one stat entry.

Changes in v2:

Hi Frederic,

Quoted 7 lines
Quoted 5 lines

This patch fails to compile the branch tracer by itself. No patch should break a build (for bisecting reasons).

-- Steve

Hmm. Yes, so perhaps I can resend the two patches in one?

Sure.

-- Steve