The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <compudj@krystal.dyndns.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: 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>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	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 04/10][RFC] tracing: Remove per event trace registering
Date: Thu, 29 Apr 2010 10:55:59 -0400	[thread overview]
Message-ID: <20100429145559.GB24819@Krystal> (raw)
In-Reply-To: <1272550009.9739.136.camel@gandalf.stny.rr.com>

* Steven Rostedt (rostedt@goodmis.org) wrote:
> On Thu, 2010-04-29 at 09:36 -0400, Mathieu Desnoyers wrote:
> 
> > > Instead of calling register_trace_##name that is created for each
> > > tracepoint, we now call the tracepoint_probe_register() directly in the
> > > C file with the generated probe.
> > > 
> > > Both the probe and the tracepoint are created from the same data. I'm
> > > not seeing where you want to add this check.
> > 
> > So if they are created from the same data, we can expect this test to
> > always pass, which is good (and expected).
> > 
> > I'd add this extra check before casting the callback to (void *) before
> > it is passed to tracepoint_probe_register(). Let's just call this
> > internal preprocessing macro integrity check. As long as it does not add
> > a runtime cost, there is no reason not to put this extra check.
> 
> The problem is, the cast is now performed in a C file for all events.
> There's no way to know what to cast it to there. This is out of the
> automation of the macro.
> 
> We use to have the cast check by creating code that would create the
> "register_trace_##call", and the typecheck was doing by passing the data
> to this function. But we removed this code out of the per event, it was
> adding lots of text footprint, and moved it to one single function that
> handles all events. It is just expected that the callback created
> matches the function it was done.
> 
> If you are overly paranoid, we could create a special function that
> tests that the callback format that is created matches the tracepoint
> that is created, and make it so GCC sees that nothing calls it and
> removes it at final link. But I still see this as a waste.
> 
> 
> The tracepoint is created in include/linux/tracepoint.h:
> 
> #define TRACE_EVENT(name, proto, args, struct, assign, print)	\
> 	DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))

Can we add something like this to DECLARE_TRACE ? (not convinced it is
valid though)

static inline void check_trace_##name(cb_type)
{
	BUILD_BUG_ON(!__same_type(void (*probe)(TP_PROTO(proto), void *data),
				  cb_type));
}

> 
> The callback is created in include/trace/ftrace.h:
> 
> #undef TRACE_EVENT
> #define TRACE_EVENT(name, proto, args, tstuct, assign, print)	\
> 	DECLARE_EVENT_CLASS(name,				\
> 				PARAMS(proto),			\
> 				PARAMS(args),			\
> 				PARAMS(tstruct),		\
> 				PARAMS(assign),			\
> 				PARAMS(print));			\
> 	DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args));
> 
> #undef DECLARE_EVENT_CLASS
> #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
> 									\
> static notrace void							\
> ftrace_raw_event_##call(proto,						\
> 			struct ftrace_event_call *event_call)		\
> [...]
> 

Either within this callback, or in a dummy static function after, we
could add:

check_trace_##call(ftrace_raw_event_##call);

So.. you are the preprocessor expert, do you think this could fly ? ;)

Thanks,

Mathieu

> 
> Thus the "proto" field of the TRACE_EVENT() is used to make both the
> tracepoint and the callback. We add the struct ftrace_event_call
> *event_call which is the data we pass to the callback.
> 
> Now, where this gets called is in kernel/trace/trace_events.c:
> 
> 	tracepoint_probe_register(call->name,
> 				  call->class->probe,
> 				  call);
> 
> This is where we lose the typecheck. So my question is... where do you
> want to put in a check?
> 
> -- Steve
> 
> 	
> 
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2010-04-30 16:51 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-26 19:50 [PATCH 00/10][RFC] tracing: Lowering the footprint of TRACE_EVENTs Steven Rostedt
2010-04-26 19:50 ` [PATCH 01/10][RFC] tracing: Create class struct for events Steven Rostedt
2010-04-28 20:22   ` Mathieu Desnoyers
2010-04-28 20:38     ` Steven Rostedt
2010-04-26 19:50 ` [PATCH 02/10][RFC] tracing: Let tracepoints have data passed to tracepoint callbacks Steven Rostedt
2010-04-27  9:08   ` Li Zefan
2010-04-27 15:28     ` Steven Rostedt
2010-04-28 20:37   ` Mathieu Desnoyers
2010-04-28 23:56     ` Steven Rostedt
2010-04-26 19:50 ` [PATCH 03/10][RFC] tracing: Convert TRACE_EVENT() to use the DECLARE_TRACE_DATA() Steven Rostedt
2010-04-28 20:39   ` Mathieu Desnoyers
2010-04-28 23:57     ` Steven Rostedt
2010-04-29  0:03       ` Mathieu Desnoyers
2010-04-26 19:50 ` [PATCH 04/10][RFC] tracing: Remove per event trace registering Steven Rostedt
2010-04-28 20:44   ` Mathieu Desnoyers
2010-04-29  0:00     ` Steven Rostedt
2010-04-29  0:05       ` Mathieu Desnoyers
2010-04-29  0:20         ` Steven Rostedt
     [not found]           ` <20100429133649.GC14617@Krystal>
2010-04-29 14:06             ` Steven Rostedt
2010-04-29 14:55               ` Mathieu Desnoyers [this message]
2010-04-29 16:06                 ` Steven Rostedt
2010-04-30 17:09                   ` Mathieu Desnoyers
2010-04-30 18:16                     ` Steven Rostedt
2010-04-30 19:06                       ` Mathieu Desnoyers
2010-04-30 19:48                         ` Steven Rostedt
2010-04-30 20:07                           ` Mathieu Desnoyers
2010-04-30 20:14                             ` Steven Rostedt
2010-04-30 21:02                               ` Mathieu Desnoyers
2010-04-26 19:50 ` [PATCH 05/10][RFC] tracing: Move fields from event to class structure Steven Rostedt
2010-04-28 20:58   ` Mathieu Desnoyers
2010-04-29  0:02     ` Steven Rostedt
     [not found]       ` <20100429133213.GA14617@Krystal>
2010-04-29 13:50         ` Steven Rostedt
2010-04-26 19:50 ` [PATCH 06/10][RFC] tracing: Move raw_init from events to class Steven Rostedt
2010-04-28 21:00   ` Mathieu Desnoyers
2010-04-26 19:50 ` [PATCH 07/10][RFC] tracing: Allow events to share their print functions Steven Rostedt
2010-04-28 21:03   ` Mathieu Desnoyers
2010-04-26 19:50 ` [PATCH 08/10][RFC] tracing: Move print functions into event class Steven Rostedt
2010-04-28 21:03   ` Mathieu Desnoyers
2010-04-26 19:50 ` [PATCH 09/10][RFC] tracing: Remove duplicate id information in event structure Steven Rostedt
2010-04-28 21:06   ` Mathieu Desnoyers
2010-04-29  0:04     ` Steven Rostedt
2010-04-26 19:50 ` [PATCH 10/10][RFC] tracing: Combine event filter_active and enable into single flags field Steven Rostedt
2010-04-28 21:13   ` Mathieu Desnoyers
2010-04-28 14:45 ` [PATCH 00/10][RFC] tracing: Lowering the footprint of TRACE_EVENTs Masami Hiramatsu
2010-04-28 20:18 ` Mathieu Desnoyers

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=20100429145559.GB24819@Krystal \
    --to=compudj@krystal.dyndns.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox