Re: [Patch 2/2] tracepoints for softirq entry/exit - tracepoints

From: Mathieu Desnoyers
Date: Mon Mar 16 2009 - 15:21:24 EST


* Steven Rostedt (rostedt@xxxxxxxxxxx) wrote:
>
> On Mon, 16 Mar 2009, Jason Baron wrote:
>
> > hi,
> >
> > ok, below is a re-spun patch 2/2 which converts to the TRACE_EVENT
> > format.
>
> Thanks, some comments though.
>
> >
> > thanks,
> >
> > -Jason
> >
> >
> > Signed-off-by: Jason Baron <jbaron@xxxxxxxxxx>
> >
> > ---
> >
> > include/trace/irq_event_types.h | 36 ++++++++++++++++++++++++++++++++++++
> > kernel/softirq.c | 7 ++++++-
> > 2 files changed, 42 insertions(+), 1 deletions(-)
> >
> >
> > diff --git a/include/trace/irq_event_types.h b/include/trace/irq_event_types.h
> > index 214bb92..de1f2a9 100644
> > --- a/include/trace/irq_event_types.h
> > +++ b/include/trace/irq_event_types.h
> > @@ -40,4 +40,40 @@ TRACE_EVENT(irq_handler_exit,
> > __entry->irq, __entry->ret ? "handled" : "unhandled")
> > );
> >
> > +TRACE_EVENT(softirq_action_entry,
> > +
> > + TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
> > +
> > + TP_ARGS(h, vec),
> > +
> > + TP_STRUCT__entry(
> > + __array( char, softirq_name, MAX_SOFTIRQ_NAME_LEN )
> > + ),
> > +
> > + TP_fast_assign(
> > + memcpy(__entry->softirq_name, softirq_to_name[h-vec],
> > + MAX_SOFTIRQ_NAME_LEN);
>
> memcpy isn't fast ;-)
>

When given a constant size, memcpy is inlined by the compiler and turned
into a simple mov instruction. That shouldn't change a thing.

Mathieu

> What you want is this:
>
> TP_STRUCT__entry(
> __field( int, vec )
> ),
>
> TP_fast_assign(
> __entry->vec = h - vec;
> > + ),
> > +
> > + TP_printk("softirq entry: %s", __entry->softirq_name)
>
> TP_printk("softirq entry: %s", softirq_to_name[__entry->vec])
>
> > +);
> > +
> > +TRACE_EVENT(softirq_action_exit,
> > +
> > + TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
> > +
> > + TP_ARGS(h, vec),
> > +
> > + TP_STRUCT__entry(
> > + __array( char, softirq_name, MAX_SOFTIRQ_NAME_LEN )
> > + ),
> > +
> > + TP_fast_assign(
> > + memcpy(__entry->softirq_name, softirq_to_name[h-vec],
> > + MAX_SOFTIRQ_NAME_LEN);
> > + ),
> > +
> > + TP_printk("softirq exit: %s", __entry->softirq_name)
>
>
> And do the same here.
>
> -- Steve
>
> > +);
> > +
> > #undef TRACE_SYSTEM
> > diff --git a/kernel/softirq.c b/kernel/softirq.c
> > index 8f3ae57..5e96c77 100644
> > --- a/kernel/softirq.c
> > +++ b/kernel/softirq.c
> > @@ -24,6 +24,7 @@
> > #include <linux/ftrace.h>
> > #include <linux/smp.h>
> > #include <linux/tick.h>
> > +#include <trace/irq.h>
> >
> > #include <asm/irq.h>
> > /*
> > @@ -185,6 +186,9 @@ EXPORT_SYMBOL(local_bh_enable_ip);
> > */
> > #define MAX_SOFTIRQ_RESTART 10
> >
> > +DEFINE_TRACE(softirq_action_entry);
> > +DEFINE_TRACE(softirq_action_exit);
> > +
> > asmlinkage void __do_softirq(void)
> > {
> > struct softirq_action *h;
> > @@ -211,8 +215,9 @@ restart:
> > if (pending & 1) {
> > int prev_count = preempt_count();
> >
> > + trace_softirq_action_entry(h, softirq_vec);
> > h->action(h);
> > -
> > + trace_softirq_action_exit(h, softirq_vec);
> > if (unlikely(prev_count != preempt_count())) {
> > printk(KERN_ERR "huh, entered softirq %td %s %p"
> > "with preempt_count %08x,"
> >
>

--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/