From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
Li Zefan <lizf@cn.fujitsu.com>,
Masami Hiramatsu <mhiramat@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 2/9 - v2][RFC] tracing: Let tracepoints have data?passed to tracepoint callbacks
Date: Fri, 7 May 2010 10:39:01 -0400 [thread overview]
Message-ID: <20100507143901.GA18408@Krystal> (raw)
In-Reply-To: <7a22ce9b-4c74-4818-9521-7fbccd1b8b1d@email.android.com>
* Steven Rostedt (rostedt@goodmis.org) wrote:
>
>
> "Frederic Weisbecker" <fweisbec@gmail.com> wrote:
>
> >On Mon, May 03, 2010 at 11:40:47PM -0400, Steven Rostedt wrote:
[...]
> >>
> >> diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> >> index 78b4bd3..ee8059a 100644
> >> --- a/include/linux/tracepoint.h
> >> +++ b/include/linux/tracepoint.h
> >> @@ -20,12 +20,17 @@
> >> struct module;
> >> struct tracepoint;
> >>
> >> +struct tracepoint_func {
> >> + void *func;
> >> + void *data;
> >> +};
> >> +
> >> struct tracepoint {
> >> const char *name; /* Tracepoint name */
> >> int state; /* State. */
> >> void (*regfunc)(void);
> >> void (*unregfunc)(void);
> >> - void **funcs;
> >> + struct tracepoint_func *funcs;
> >> } __attribute__((aligned(32))); /*
> >> * Aligned on 32 bytes because it is
> >> * globally visible and gcc happily
> >> @@ -46,14 +51,18 @@ struct tracepoint {
> >> */
> >> #define __DO_TRACE(tp, proto, args) \
> >> do { \
> >> - void **it_func; \
> >> + struct tracepoint_func *it_func_ptr; \
> >> + void *it_func; \
> >> + void *__data; \
> >> \
> >> rcu_read_lock_sched_notrace(); \
> >> - it_func = rcu_dereference_sched((tp)->funcs); \
> >> - if (it_func) { \
> >> + it_func_ptr = rcu_dereference_sched((tp)->funcs); \
> >> + if (it_func_ptr) { \
> >> do { \
> >> - ((void(*)(proto))(*it_func))(args); \
> >> - } while (*(++it_func)); \
> >> + it_func = (it_func_ptr)->func; \
> >> + __data = (it_func_ptr)->data; \
> >> + ((void(*)(proto))(it_func))(args); \
> >
> >
> >So, we had a talk about this and we concluded that it is probably fine
> >on every archs to push one more argument than needed in a function.
> >
>
> Yeah, I'm hoping it's fine.
How about changing the callback prototypes to match the call arguments (changing
the type expected in register/unregister_trace, as well as an additional "check
type" that I proposed for Ftrace) ?
Otherwise, you basically expect here that:
void fct(void *foo, void *bar, etc etc) (N parameters expected)
{
}
called by:
fct(foo, bar, etc etc, foobar) (N + 1 parameters)
will always work.
Can you show me where the C standard says it is safe to do so ?
Thanks,
Mathieu
>
> >But I think it would be nice to add a comment about this. Firstly
> >because this line breaks all the self-explanation of the code, I mean
> >I tried hard to find how the non-data callback case was handled :)
> >Secondly to also to avoid people asking what happens here.
> >
>
> OK I'll add a bit of comments to the macros. So much for my job security ;-)
>
> >
> >
> >
> >> + } while ((++it_func_ptr)->func); \
> >> } \
> >> rcu_read_unlock_sched_notrace(); \
> >> } while (0)
> >> @@ -63,23 +72,47 @@ struct tracepoint {
> >> * not add unwanted padding between the beginning of the section and the
> >> * structure. Force alignment to the same alignment as the section start.
> >> */
> >> -#define DECLARE_TRACE(name, proto, args) \
> >> +#define __DECLARE_TRACE(name, proto, args, data_proto, data_args) \
> >> extern struct tracepoint __tracepoint_##name; \
> >> static inline void trace_##name(proto) \
> >> { \
> >> if (unlikely(__tracepoint_##name.state)) \
> >> __DO_TRACE(&__tracepoint_##name, \
> >> - TP_PROTO(proto), TP_ARGS(args)); \
> >> + TP_PROTO(data_proto), \
> >> + TP_ARGS(data_args)); \
> >> } \
> >> static inline int register_trace_##name(void (*probe)(proto)) \
> >> { \
> >> - return tracepoint_probe_register(#name, (void *)probe); \
> >> + return tracepoint_probe_register(#name, (void *)probe, \
> >> + NULL); \
> >> + } \
> >> + static inline int unregister_trace_##name(void (*probe)(proto)) \
> >> + { \
> >> + return tracepoint_probe_unregister(#name, (void *)probe,\
> >> + NULL); \
> >> } \
> >> - static inline int unregister_trace_##name(void (*probe)(proto)) \
> >> + static inline int \
> >> + register_trace_##name##_data(void (*probe)(data_proto), \
> >> + void *data) \
> >> { \
> >> - return tracepoint_probe_unregister(#name, (void *)probe);\
> >> + return tracepoint_probe_register(#name, (void *)probe, \
> >> + data); \
> >> + } \
> >> + static inline int \
> >> + unregister_trace_##name##_data(void (*probe)(data_proto), \
> >> + void *data) \
> >> + { \
> >> + return tracepoint_probe_unregister(#name, (void *)probe,\
> >> + data); \
> >> }
> >>
> >> +#define DECLARE_TRACE_NOARGS(name) \
> >> + __DECLARE_TRACE(name, void, , void *__data, __data)
> >
> >
> >
> >That too, may be, deserves a small comment :)
>
> OK
>
> >
> >
> >
> >> +
> >> +#define DECLARE_TRACE(name, proto, args) \
> >> + __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \
> >> + PARAMS(proto, void *__data), \
> >> + PARAMS(args, __data))
> >>
> >> #define DEFINE_TRACE_FN(name, reg, unreg) \
> >> static const char __tpstrtab_##name[] \
> >> @@ -100,19 +133,37 @@ extern void tracepoint_update_probe_range(struct tracepoint *begin,
> >> struct tracepoint *end);
> >>
[...]
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2010-05-07 14:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-07 12:40 [PATCH 2/9 - v2][RFC] tracing: Let tracepoints have data passed to tracepoint callbacks Steven Rostedt
2010-05-07 14:39 ` Mathieu Desnoyers [this message]
2010-05-07 14:55 ` [PATCH 2/9 - v2][RFC] tracing: Let tracepoints have data?passed " Steven Rostedt
2010-05-07 15:08 ` Mathieu Desnoyers
2010-05-07 15:15 ` Steven Rostedt
2010-05-07 15:30 ` Mathieu Desnoyers
2010-05-07 15:45 ` Steven Rostedt
-- strict thread matches above, loose matches on Subject: below --
2010-05-04 3:40 [PATCH 0/9 - v2][RFC] tracing: Lowering the footprint of TRACE_EVENTs Steven Rostedt
2010-05-04 3:40 ` [PATCH 2/9 - v2][RFC] tracing: Let tracepoints have data passed to tracepoint callbacks Steven Rostedt
2010-05-07 3:52 ` Frederic Weisbecker
2010-05-07 14:09 ` Steven Rostedt
2010-05-07 18:06 ` Frederic Weisbecker
2010-05-07 19:10 ` Steven Rostedt
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=20100507143901.GA18408@Krystal \
--to=mathieu.desnoyers@efficios.com \
--cc=acme@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=hch@lst.de \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=mhiramat@redhat.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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 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.