Re: [PATCH 4/4] tracing/events: add trace-events-sample

Steven Rostedt
2009-04-16T17:35:24Z

On Thu, 16 Apr 2009, Christoph Hellwig wrote:

> On Tue, Apr 14, 2009 at 11:15:15PM -0400, Steven Rostedt wrote:
> > +++ b/samples/trace_events/Makefile
> > @@ -0,0 +1,8 @@
> > +# builds the trace events example kernel modules;
> > +# then to use one (as root): insmod <module_name.ko>
> > +
> > +PWD := $(shell pwd)
> > +
> > +CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/
>
> CFLAGS_trace-events-sample.o += -I$(src)

Is $(src) defined to be where the object is compiled?

>
> That should better be written as. But you'd easily get rid of that
> by just including the file using #include "foo.h" instead of <foo.h>,
> no?

That is for the define_trace.h to find the file. The define_trace.h will
look from where it is located. ie. include/trace

>
> > --- /dev/null
> > +++ b/samples/trace_events/trace-events-sample.h
> > @@ -0,0 +1,124 @@
> > +/*
> > + * Notice that this file is not protected like a normal header.
> > + * We also must allow for rereading of this file. The
> > + *
> > + * || defined(TRACE_HEADER_MULTI_READ)
> > + *
> > + * serves this purpose.
> > + */
> > +#if !defined(_TRACE_EVENT_SAMPLE_H) || defined(TRACE_HEADER_MULTI_READ)
> > +#define _TRACE_EVENT_SAMPLE_H
>
> Why do we need this protection at all? It only be included by the users
> of the tracepoints, and it seems just fair to take some more than normal
> precaution for more than unusual magic headers.

This was needed for kmem.h because it was causing header recursive hell.
But instead of doing this for just a few headers, having it in all was a
way to be:

1) safe

2) descriptive

#2 is because people are use to the #ifndef _MY_HEADER_H and seeing that
there is also a TRACE_HEADER_MULTI_READ it makes it obvious that this
header may be included more than once, purposefully.

-- Steve