* [PATCH][GIT PULL] tracing: add handler to trace_stat
@ 2009-03-25 3:30 Steven Rostedt
2009-03-25 22:01 ` Frederic Weisbecker
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2009-03-25 3:30 UTC (permalink / raw)
To: LKML; +Cc: Ingo Molnar, Frédéric Weisbecker, Andrew Morton
Ingo,
Please pull the latest tip/tracing/ftrace tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/ftrace
Steven Rostedt (1):
tracing: add handler to trace_stat
----
kernel/trace/trace_branch.c | 4 ++--
kernel/trace/trace_stat.c | 2 +-
kernel/trace/trace_stat.h | 2 +-
kernel/trace/trace_workqueue.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
---------------------------
commit 425480081e936d8725f0d44b8829d699bf088c6b
Author: Steven Rostedt <srostedt@redhat.com>
Date: Tue Mar 24 13:38:36 2009 -0400
tracing: add handler to trace_stat
Currently, if a trace_stat user wants a handle to some private data,
the trace_stat infrastructure does not supply a way to do that.
This patch passes the trace_stat structure to the start function of
the trace_stat code.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index ad8c22e..e6e3291 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -263,7 +263,7 @@ static int branch_stat_show(struct seq_file *m, void *v)
return 0;
}
-static void *annotated_branch_stat_start(void)
+static void *annotated_branch_stat_start(struct tracer_stat *trace)
{
return __start_annotated_branch_profile;
}
@@ -338,7 +338,7 @@ static int all_branch_stat_headers(struct seq_file *m)
return 0;
}
-static void *all_branch_stat_start(void)
+static void *all_branch_stat_start(struct tracer_stat *trace)
{
return __start_branch_profile;
}
diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
index f71b85b..f8f48d8 100644
--- a/kernel/trace/trace_stat.c
+++ b/kernel/trace/trace_stat.c
@@ -85,7 +85,7 @@ static int stat_seq_init(struct tracer_stat_session *session)
if (!ts->stat_cmp)
ts->stat_cmp = dummy_cmp;
- stat = ts->stat_start();
+ stat = ts->stat_start(ts);
if (!stat)
goto exit;
diff --git a/kernel/trace/trace_stat.h b/kernel/trace/trace_stat.h
index 202274c..f3546a2 100644
--- a/kernel/trace/trace_stat.h
+++ b/kernel/trace/trace_stat.h
@@ -12,7 +12,7 @@ struct tracer_stat {
/* The name of your stat file */
const char *name;
/* Iteration over statistic entries */
- void *(*stat_start)(void);
+ void *(*stat_start)(struct tracer_stat *trace);
void *(*stat_next)(void *prev, int idx);
/* Compare two entries for stats sorting */
int (*stat_cmp)(void *p1, void *p2);
diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
index 9ab035b..ee533c2 100644
--- a/kernel/trace/trace_workqueue.c
+++ b/kernel/trace/trace_workqueue.c
@@ -152,7 +152,7 @@ static struct cpu_workqueue_stats *workqueue_stat_start_cpu(int cpu)
return ret;
}
-static void *workqueue_stat_start(void)
+static void *workqueue_stat_start(struct tracer_stat *trace)
{
int cpu;
void *ret = NULL;
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH][GIT PULL] tracing: add handler to trace_stat
2009-03-25 3:30 [PATCH][GIT PULL] tracing: add handler to trace_stat Steven Rostedt
@ 2009-03-25 22:01 ` Frederic Weisbecker
2009-03-25 22:49 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Frederic Weisbecker @ 2009-03-25 22:01 UTC (permalink / raw)
To: Steven Rostedt; +Cc: LKML, Ingo Molnar, Andrew Morton
On Tue, Mar 24, 2009 at 11:30:33PM -0400, Steven Rostedt wrote:
>
> Ingo,
>
> Please pull the latest tip/tracing/ftrace tree, which can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/tracing/ftrace
>
>
> Steven Rostedt (1):
> tracing: add handler to trace_stat
>
> ----
> kernel/trace/trace_branch.c | 4 ++--
> kernel/trace/trace_stat.c | 2 +-
> kernel/trace/trace_stat.h | 2 +-
> kernel/trace/trace_workqueue.c | 2 +-
> 4 files changed, 5 insertions(+), 5 deletions(-)
> ---------------------------
> commit 425480081e936d8725f0d44b8829d699bf088c6b
> Author: Steven Rostedt <srostedt@redhat.com>
> Date: Tue Mar 24 13:38:36 2009 -0400
>
> tracing: add handler to trace_stat
>
> Currently, if a trace_stat user wants a handle to some private data,
> the trace_stat infrastructure does not supply a way to do that.
>
> This patch passes the trace_stat structure to the start function of
> the trace_stat code.
>
> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
>
> diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
> index ad8c22e..e6e3291 100644
> --- a/kernel/trace/trace_branch.c
> +++ b/kernel/trace/trace_branch.c
> @@ -263,7 +263,7 @@ static int branch_stat_show(struct seq_file *m, void *v)
> return 0;
> }
>
> -static void *annotated_branch_stat_start(void)
> +static void *annotated_branch_stat_start(struct tracer_stat *trace)
> {
> return __start_annotated_branch_profile;
> }
> @@ -338,7 +338,7 @@ static int all_branch_stat_headers(struct seq_file *m)
> return 0;
> }
>
> -static void *all_branch_stat_start(void)
> +static void *all_branch_stat_start(struct tracer_stat *trace)
> {
> return __start_branch_profile;
> }
> diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
> index f71b85b..f8f48d8 100644
> --- a/kernel/trace/trace_stat.c
> +++ b/kernel/trace/trace_stat.c
> @@ -85,7 +85,7 @@ static int stat_seq_init(struct tracer_stat_session *session)
> if (!ts->stat_cmp)
> ts->stat_cmp = dummy_cmp;
>
> - stat = ts->stat_start();
> + stat = ts->stat_start(ts);
> if (!stat)
> goto exit;
>
> diff --git a/kernel/trace/trace_stat.h b/kernel/trace/trace_stat.h
> index 202274c..f3546a2 100644
> --- a/kernel/trace/trace_stat.h
> +++ b/kernel/trace/trace_stat.h
> @@ -12,7 +12,7 @@ struct tracer_stat {
> /* The name of your stat file */
> const char *name;
> /* Iteration over statistic entries */
> - void *(*stat_start)(void);
> + void *(*stat_start)(struct tracer_stat *trace);
In that case, shoudn't we pass another thing than the struct tracer_stat?
Because nothing really private can be stored in it. Moreover, most of the
time the handler is dedicated to this tracer_stat so it is able to have
an access to it.
May be we could add a void *private inside struct trace_stat and then pass
it to stat_start() ?
Thanks,
Frederic.
> void *(*stat_next)(void *prev, int idx);
> /* Compare two entries for stats sorting */
> int (*stat_cmp)(void *p1, void *p2);
> diff --git a/kernel/trace/trace_workqueue.c b/kernel/trace/trace_workqueue.c
> index 9ab035b..ee533c2 100644
> --- a/kernel/trace/trace_workqueue.c
> +++ b/kernel/trace/trace_workqueue.c
> @@ -152,7 +152,7 @@ static struct cpu_workqueue_stats *workqueue_stat_start_cpu(int cpu)
> return ret;
> }
>
> -static void *workqueue_stat_start(void)
> +static void *workqueue_stat_start(struct tracer_stat *trace)
> {
> int cpu;
> void *ret = NULL;
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH][GIT PULL] tracing: add handler to trace_stat
2009-03-25 22:01 ` Frederic Weisbecker
@ 2009-03-25 22:49 ` Steven Rostedt
2009-03-25 23:04 ` Frederic Weisbecker
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2009-03-25 22:49 UTC (permalink / raw)
To: Frederic Weisbecker; +Cc: LKML, Ingo Molnar, Andrew Morton
On Wed, 25 Mar 2009, Frederic Weisbecker wrote:
> >
> > diff --git a/kernel/trace/trace_stat.h b/kernel/trace/trace_stat.h
> > index 202274c..f3546a2 100644
> > --- a/kernel/trace/trace_stat.h
> > +++ b/kernel/trace/trace_stat.h
> > @@ -12,7 +12,7 @@ struct tracer_stat {
> > /* The name of your stat file */
> > const char *name;
> > /* Iteration over statistic entries */
> > - void *(*stat_start)(void);
> > + void *(*stat_start)(struct tracer_stat *trace);
>
>
>
> In that case, shoudn't we pass another thing than the struct tracer_stat?
> Because nothing really private can be stored in it. Moreover, most of the
> time the handler is dedicated to this tracer_stat so it is able to have
> an access to it.
>
> May be we could add a void *private inside struct trace_stat and then pass
> it to stat_start() ?
>
Very few tracers need a private field so adding one would be a waste for
them. I just used the old container_of trick.
struct ftrace_profile_stat {
atomic_t disabled;
struct hlist_head *hash;
struct ftrace_profile_page *pages;
struct ftrace_profile_page *start;
struct tracer_stat stat;
};
static void *function_stat_start(struct tracer_stat *trace)
{
struct ftrace_profile_stat *stat =
container_of(trace, struct ftrace_profile_stat, stat);
[...]
And there you have it. I have everything I need unique to the tracer and
no need of a private pointer.
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH][GIT PULL] tracing: add handler to trace_stat
2009-03-25 22:49 ` Steven Rostedt
@ 2009-03-25 23:04 ` Frederic Weisbecker
0 siblings, 0 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2009-03-25 23:04 UTC (permalink / raw)
To: Steven Rostedt; +Cc: LKML, Ingo Molnar, Andrew Morton
On Wed, Mar 25, 2009 at 06:49:33PM -0400, Steven Rostedt wrote:
>
> On Wed, 25 Mar 2009, Frederic Weisbecker wrote:
> > >
> > > diff --git a/kernel/trace/trace_stat.h b/kernel/trace/trace_stat.h
> > > index 202274c..f3546a2 100644
> > > --- a/kernel/trace/trace_stat.h
> > > +++ b/kernel/trace/trace_stat.h
> > > @@ -12,7 +12,7 @@ struct tracer_stat {
> > > /* The name of your stat file */
> > > const char *name;
> > > /* Iteration over statistic entries */
> > > - void *(*stat_start)(void);
> > > + void *(*stat_start)(struct tracer_stat *trace);
> >
> >
> >
> > In that case, shoudn't we pass another thing than the struct tracer_stat?
> > Because nothing really private can be stored in it. Moreover, most of the
> > time the handler is dedicated to this tracer_stat so it is able to have
> > an access to it.
> >
> > May be we could add a void *private inside struct trace_stat and then pass
> > it to stat_start() ?
> >
>
>
> Very few tracers need a private field so adding one would be a waste for
> them. I just used the old container_of trick.
>
>
> struct ftrace_profile_stat {
> atomic_t disabled;
> struct hlist_head *hash;
> struct ftrace_profile_page *pages;
> struct ftrace_profile_page *start;
> struct tracer_stat stat;
> };
>
> static void *function_stat_start(struct tracer_stat *trace)
> {
> struct ftrace_profile_stat *stat =
> container_of(trace, struct ftrace_profile_stat, stat);
>
> [...]
>
> And there you have it. I have everything I need unique to the tracer and
> no need of a private pointer.
>
> -- Steve
>
And type safe :-)
Indeed, that's much better.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-03-25 23:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-25 3:30 [PATCH][GIT PULL] tracing: add handler to trace_stat Steven Rostedt
2009-03-25 22:01 ` Frederic Weisbecker
2009-03-25 22:49 ` Steven Rostedt
2009-03-25 23:04 ` Frederic Weisbecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox