From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH][GIT PULL] tracing: add handler to trace_stat
Date: Thu, 26 Mar 2009 00:04:38 +0100 [thread overview]
Message-ID: <20090325230437.GN5932@nowhere> (raw)
In-Reply-To: <alpine.DEB.2.00.0903251846470.5675@gandalf.stny.rr.com>
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.
prev parent reply other threads:[~2009-03-25 23:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=20090325230437.GN5932@nowhere \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.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