From: Peter Zijlstra on
On Fri, 2010-02-12 at 14:09 -0500, Steven Rostedt wrote:
> plain text document attachment (irq-events.patch)
> The irq trace events that map the softirq vectors to strings
> shows up in the format files as names. To allow binary parsers to
> be able to convert these names to their actual numbers, this patch
> extracts those enums.
>
> Signed-off-by: Steven Rostedt <rostedt(a)goodmis.org>
>
> ---
> include/trace/events/irq.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> Index: linux-trace.git/include/trace/events/irq.h
> ===================================================================
> --- linux-trace.git.orig/include/trace/events/irq.h 2010-02-12 13:29:44.000000000 -0500
> +++ linux-trace.git/include/trace/events/irq.h 2010-02-12 13:33:20.000000000 -0500
> @@ -7,6 +7,17 @@
> #include <linux/tracepoint.h>
> #include <linux/interrupt.h>
>
> +EXTRACT_TRACE_SYMBOL(HI_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(TIMER_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(NET_TX_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(NET_RX_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(BLOCK_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(BLOCK_IOPOLL_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(TASKLET_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(SCHED_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(HRTIMER_SOFTIRQ);
> +EXTRACT_TRACE_SYMBOL(RCU_SOFTIRQ);
> +

Still sucks you have to explicitly iterate them all, and far away from
the actual definition site too, its just asking to get out of whack with
reality.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Steven Rostedt on
On Sat, 2010-02-13 at 11:39 +0100, Peter Zijlstra wrote:
> On Fri, 2010-02-12 at 14:09 -0500, Steven Rostedt wrote:
> > plain text document attachment (irq-events.patch)
> > The irq trace events that map the softirq vectors to strings
> > shows up in the format files as names. To allow binary parsers to
> > be able to convert these names to their actual numbers, this patch
> > extracts those enums.
> >
> > Signed-off-by: Steven Rostedt <rostedt(a)goodmis.org>
> >
> > ---
> > include/trace/events/irq.h | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > Index: linux-trace.git/include/trace/events/irq.h
> > ===================================================================
> > --- linux-trace.git.orig/include/trace/events/irq.h 2010-02-12 13:29:44.000000000 -0500
> > +++ linux-trace.git/include/trace/events/irq.h 2010-02-12 13:33:20.000000000 -0500
> > @@ -7,6 +7,17 @@
> > #include <linux/tracepoint.h>
> > #include <linux/interrupt.h>
> >
> > +EXTRACT_TRACE_SYMBOL(HI_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(TIMER_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(NET_TX_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(NET_RX_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(BLOCK_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(BLOCK_IOPOLL_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(TASKLET_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(SCHED_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(HRTIMER_SOFTIRQ);
> > +EXTRACT_TRACE_SYMBOL(RCU_SOFTIRQ);
> > +
>
> Still sucks you have to explicitly iterate them all, and far away from
> the actual definition site too, its just asking to get out of whack with
> reality.

We don't care about adding them near the definition site. We care about
what is used. In this same file we have:

#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
#define show_softirq_name(val) \
__print_symbolic(val, \
softirq_name(HI), \
softirq_name(TIMER), \
softirq_name(NET_TX), \
softirq_name(NET_RX), \
softirq_name(BLOCK), \
softirq_name(BLOCK_IOPOLL), \
softirq_name(TASKLET), \
softirq_name(SCHED), \
softirq_name(HRTIMER), \
softirq_name(RCU))

Which uses the variables. If another softirq name is added, the
TRACE_EVENT already misses it. That's not the point of the EXTRACT
macro. The point is, if a TRACE_EVENT uses a name that is not a macro,
this gives a way for it to display that value.

-- Steve



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Steven Rostedt on
On Fri, 2010-02-26 at 00:48 +0100, Frederic Weisbecker wrote:

>
> And what about a kind of macro that could have two effects:
>
> - define the enum
> - define the nr -> name pairs for resolution
>
> This could be something like:
>
> define_trace_enum(softirq)
> enum_entry(TASKLET, 4), //don't know if it's 4, just an example
> enum_entry(HRTIMER, 5),
> end_trace_enum()

That wont work. Unless it is in a separate file that can be included
over and over again. That is we would need:

** include/linux/softirq_names.h:

define_trace_enum(softirq)
enum_entry(HI, 0),
enum_entry(TIMER, 1),
[...]
end_trace_enum();



** include/trace/define_enum.h:

#define define_trace_enum(name) enum name {
#define enum_entry(a, b) a = b
#define end_trace_enum() }


** include/linux/interrupt.h

/* instead of declaring an enum we have */

#include <trace/define_enum.h>
#include <linux/softirq_names.h>

Here we could do something special with that file.

>
> (My naming sucks, as usual).
>
> In normal headers, it would define an enum:
>
> enum softirq {
> TASKLET = 4,
> HRTIMER = 5,
> };
>
> And in the file that has DEFINE_TRACEPOINT:
>
> /* can be in ftrace_event.h */
> struct resolve_enum {
> const char *name;
> int val;
> };
>
> struct resolve_enum softirq = { //come from define_trace_enum()
> {"TASKLET", 4}, //come from enum_entry()
> {"HRTIMER", 5},
> { NULL, 0}, /* end */
> };
>
> /* This can be used from the trace_event macro */
> const char *softirq_name(int nr)
> {
> return resolve_enum[nr];
> }
>
>
> And then you can get back the struct resolve_enum softirq
> to export the values to debugfs, may be by storing such
> structures in a section (and adding the name of the enum)
>
> This has the advantage of beeing sync with core header
> changes, but this has the drawback of beeing less readable
> to define an enum usable from a TRACE_EVENT (especially
> if I define the naming personally).
>


This just gets ugly and I'm not sure people would like doing this. It
also requires that you number the enums specifically.

A better way could be this:

** include/linux/interrupt.h

#define SOFTIRQ_NAMES \
C(HI), \
C(TIMER), \
[...] \
C(RCU)

#define C(name) name##_SOFTIRQ

enum { SOFTIRQ_NAMES, NR_SOFTIRQS };

#undef C

And in the trace file we could do:

#define C(name) { #name, name##_SOFTIRQ, sizeof(name##_SOFTIRQ) }

struct {
char *name;
int val;
int size;
} softirq_names[] __attribute__((section("trace_syms"))) =
{ SOFTIRQ_NAMES };

#undef C


This way we don't need to number every enum, or have to move the enum
into another file. My question is...

Would the following be acceptable in normal headers?

#define ENUM_NAMES \
C(a), \
C(b), \
...

#define C(name) name

enum { ENUM_NAMES };

#undef C

-- Steve


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/