Module: xenomai-jki
Branch: queues/ftrace
Commit: 2ad1fd56dacf8acd3385c98b6247bf5c6cc8694d
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=2ad1fd56dacf8acd3385c98b6247bf5c6cc8694d

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Thu Feb 14 21:11:38 2013 +0100

nucleus: Convert timer instrumentation

Drop migration and freeze instrumentation. The former is only interesting
when a running timer is actually moved between CPUs. But this can be
derived from thread migration events. The latter is the end of the world
anyway.

Also drop tbase_start/stop. Their events can be derived from the
corresponding timer events.

Move the instrumentations for tick events into the corresponding
functions to centralize related tracepoints.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 include/trace/xn_nucleus.h |  119 ++++++++++++++++++++++++++++++++++++++++++++
 ksrc/nucleus/intr.c        |    1 -
 ksrc/nucleus/pod.c         |    4 --
 ksrc/nucleus/timebase.c    |   11 +---
 ksrc/nucleus/timer.c       |   31 +++++-------
 5 files changed, 134 insertions(+), 32 deletions(-)

diff --git a/include/trace/xn_nucleus.h b/include/trace/xn_nucleus.h
index f01d52f..0acbf41 100644
--- a/include/trace/xn_nucleus.h
+++ b/include/trace/xn_nucleus.h
@@ -413,6 +413,125 @@ DEFINE_EVENT(irq_event, xn_nucleus_irq_disable,
        TP_ARGS(irq)
 );
 
+DECLARE_EVENT_CLASS(timer_event,
+       TP_PROTO(xntimer_t *timer),
+       TP_ARGS(timer),
+
+       TP_STRUCT__entry(
+               __field(xntimer_t *,    timer)
+       ),
+
+       TP_fast_assign(
+               __entry->timer          = timer;
+       ),
+
+       TP_printk("timer=%p", __entry->timer)
+);
+
+DEFINE_EVENT(timer_event, xn_nucleus_timer_stop,
+       TP_PROTO(xntimer_t *timer),
+       TP_ARGS(timer)
+);
+
+DEFINE_EVENT(timer_event, xn_nucleus_timer_expire,
+       TP_PROTO(xntimer_t *timer),
+       TP_ARGS(timer)
+);
+
+#define show_timer_mode(mode)                          \
+       __print_symbolic(mode,                          \
+                        {XN_RELATIVE, "rel"},          \
+                        {XN_ABSOLUTE, "abs"},          \
+                        {XN_REALTIME, "rt"})
+
+TRACE_EVENT(xn_nucleus_timer_start,
+       TP_PROTO(xntimer_t *timer, xnticks_t value, xnticks_t interval,
+                xntmode_t mode),
+       TP_ARGS(timer, value, interval, mode),
+
+       TP_STRUCT__entry(
+               __field(xntimer_t *,    timer)
+               __array(char,           handler_name, XNOBJECT_NAME_LEN)
+               __array(char,           base_name, XNOBJECT_NAME_LEN)
+               __field(xnticks_t,      value)
+               __field(xnticks_t,      interval)
+               __field(xntmode_t,      mode)
+       ),
+
+       TP_fast_assign(
+               __entry->timer          = timer;
+#ifdef CONFIG_XENO_OPT_STATS
+               strncpy(__entry->handler_name, timer->handler_name,
+                       XNOBJECT_NAME_LEN-1);
+               __entry->handler_name[XNOBJECT_NAME_LEN-1] = 0;
+#else
+               __entry->handler_name[0] = 0;
+#endif
+               strncpy(__entry->base_name, xntbase_name(xntimer_base(timer)),
+                       XNOBJECT_NAME_LEN-1);
+               __entry->base_name[XNOBJECT_NAME_LEN-1] = 0;
+               __entry->value          = value;
+               __entry->interval       = interval;
+               __entry->mode           = mode;
+       ),
+
+       TP_printk("timer=%p handler_name=%s base_name=%s value=%Lu interval %Lu"
+                 " mode=%s", __entry->timer, __entry->handler_name,
+                 __entry->base_name, __entry->value, __entry->interval,
+                 show_timer_mode(__entry->mode))
+);
+
+TRACE_EVENT(xn_nucleus_timer_tick_aperiodic,
+       TP_PROTO(int dummy),
+       TP_ARGS(dummy),
+
+       TP_STRUCT__entry(
+               __array(char, dummy, 0)
+       ),
+
+       TP_fast_assign(
+               (void)dummy;
+       ),
+
+       TP_printk("%s", "")
+);
+
+TRACE_EVENT(xn_nucleus_timer_tick_periodic,
+       TP_PROTO(xntbase_t *base),
+       TP_ARGS(base),
+
+       TP_STRUCT__entry(
+               __array(char,           base_name, XNOBJECT_NAME_LEN)
+       ),
+
+       TP_fast_assign(
+               strncpy(__entry->base_name, xntbase_name(base),
+                       XNOBJECT_NAME_LEN-1);
+               __entry->base_name[XNOBJECT_NAME_LEN-1] = 0;
+       ),
+
+       TP_printk("base_name=%s", __entry->base_name)
+);
+
+TRACE_EVENT(xn_nucleus_timebase_adjust,
+       TP_PROTO(xntbase_t *base, xnsticks_t delta),
+       TP_ARGS(base, delta),
+
+       TP_STRUCT__entry(
+               __array(char,           base_name, XNOBJECT_NAME_LEN)
+               __field(xnticks_t,      delta)
+       ),
+
+       TP_fast_assign(
+               strncpy(__entry->base_name, xntbase_name(base),
+                       XNOBJECT_NAME_LEN-1);
+               __entry->base_name[XNOBJECT_NAME_LEN-1] = 0;
+               __entry->delta          = delta;
+       ),
+
+       TP_printk("base_name=%s delta=%Lu", __entry->base_name, __entry->delta)
+);
+
 #endif /* _TRACE_XN_NUCLEUS_H */
 
 /* This part must be outside protection */
diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c
index a987ccd..de8cde9 100644
--- a/ksrc/nucleus/intr.c
+++ b/ksrc/nucleus/intr.c
@@ -103,7 +103,6 @@ void xnintr_clock_handler(void)
        xnstat_counter_inc(&nkclock.stat[xnsched_cpu(sched)].hits);
 
        trace_xn_nucleus_irq_entry(XNARCH_TIMER_IRQ);
-       trace_mark(xn_nucleus, tbase_tick, "base %s", nktbase.name);
 
        ++sched->inesting;
        __setbits(sched->lflags, XNINIRQ);
diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 9254d14..bf724da 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -2654,8 +2654,6 @@ int xnpod_enable_timesource(void)
                return err;
        }
 
-       trace_mark(xn_nucleus, tbase_start, "base %s", nktbase.name);
-
 #ifdef CONFIG_XENO_OPT_STATS
        /*
         * Only for statistical purpose, the clock interrupt will be
@@ -2750,8 +2748,6 @@ void xnpod_disable_timesource(void)
        spl_t s;
        int cpu;
 
-       trace_mark(xn_nucleus, tbase_stop, "base %s", nktbase.name);
-
        xnlock_get_irqsave(&nklock, s);
 
        if (!xnpod_active_p() || !xntbase_enabled_p(&nktbase)) {
diff --git a/ksrc/nucleus/timebase.c b/ksrc/nucleus/timebase.c
index abf153a..9d918d4 100644
--- a/ksrc/nucleus/timebase.c
+++ b/ksrc/nucleus/timebase.c
@@ -55,6 +55,8 @@
 #include <nucleus/timer.h>
 #include <nucleus/module.h>
 
+#include <trace/events/xn_nucleus.h>
+
 DEFINE_XNQUEUE(nktimebaseq);
 
 #ifdef CONFIG_XENO_OPT_TIMING_PERIODIC
@@ -386,8 +388,6 @@ void xntbase_start(xntbase_t *base)
        if (base == &nktbase || xntbase_enabled_p(base))
                return;
 
-       trace_mark(xn_nucleus, tbase_start, "base %s", base->name);
-
        xnlock_get_irqsave(&nklock, s);
 
        start_date = xnarch_get_cpu_time();
@@ -442,8 +442,6 @@ void xntbase_stop(xntbase_t *base)
 
        xntslave_stop(base2slave(base));
        __clrbits(base->status, XNTBRUN | XNTBSET);
-
-       trace_mark(xn_nucleus, tbase_stop, "base %s", base->name);
 }
 EXPORT_SYMBOL_GPL(xntbase_stop);
 
@@ -483,8 +481,6 @@ void xntbase_tick(xntbase_t *base)
 
        XENO_BUGON(NUCLEUS, !xnpod_interrupt_p());
 
-       trace_mark(xn_nucleus, tbase_tick, "base %s", base->name);
-
        if (base == &nktbase)
                xntimer_tick_aperiodic();
        else {
@@ -617,8 +613,7 @@ void xntbase_adjust_time(xntbase_t *base, xnsticks_t delta)
        }
 #endif /* CONFIG_XENO_OPT_TIMING_PERIODIC */
 
-       trace_mark(xn_nucleus, tbase_adjust, "base %s delta %Lu",
-                  base->name, delta);
+       trace_xn_nucleus_timebase_adjust(base, delta);
 }
 EXPORT_SYMBOL_GPL(xntbase_adjust_time);
 
diff --git a/ksrc/nucleus/timer.c b/ksrc/nucleus/timer.c
index c010482..c2c95fe 100644
--- a/ksrc/nucleus/timer.c
+++ b/ksrc/nucleus/timer.c
@@ -41,6 +41,8 @@
 #include <nucleus/timer.h>
 #include <asm/xenomai/bits/timer.h>
 
+#include <trace/events/xn_nucleus.h>
+
 static inline void xntimer_enqueue_aperiodic(xntimer_t *timer)
 {
        xntimerq_t *q = &timer->sched->timerqueue;
@@ -225,9 +227,7 @@ int xntimer_start_aperiodic(xntimer_t *timer,
 {
        xnticks_t date, now;
 
-       trace_mark(xn_nucleus, timer_start,
-                  "timer %p base %s value %Lu interval %Lu mode %u",
-                  timer, xntimer_base(timer)->name, value, interval, mode);
+       trace_xn_nucleus_timer_start(timer, value, interval, mode);
 
        if (!testbits(timer->status, XNTIMER_DEQUEUED))
                xntimer_dequeue_aperiodic(timer);
@@ -278,7 +278,7 @@ void xntimer_stop_aperiodic(xntimer_t *timer)
 {
        int heading;
 
-       trace_mark(xn_nucleus, timer_stop, "timer %p", timer);
+       trace_xn_nucleus_timer_stop(timer);
 
        heading = xntimer_heading_p(timer);
        xntimer_dequeue_aperiodic(timer);
@@ -347,6 +347,8 @@ void xntimer_tick_aperiodic(void)
        xntimer_t *timer;
        xnsticks_t delta;
 
+       trace_xn_nucleus_timer_tick_aperiodic(0);
+
        /*
         * Optimisation: any local timer reprogramming triggered by
         * invoked timer handlers can wait until we leave the tick
@@ -368,7 +370,7 @@ void xntimer_tick_aperiodic(void)
                if (delta > (xnsticks_t)(nklatency + nktimerlat))
                        break;
 
-               trace_mark(xn_nucleus, timer_expire, "timer %p", timer);
+               trace_xn_nucleus_timer_expire(timer);
 
                xntimer_dequeue_aperiodic(timer);
                xnstat_counter_inc(&timer->fired);
@@ -463,9 +465,7 @@ static int xntimer_start_periodic(xntimer_t *timer,
                                  xnticks_t value, xnticks_t interval,
                                  xntmode_t mode)
 {
-       trace_mark(xn_nucleus, timer_start,
-                  "timer %p base %s value %Lu interval %Lu mode %u", timer,
-                  xntimer_base(timer)->name, value, interval, mode);
+       trace_xn_nucleus_timer_start(timer, value, interval, mode);
 
        if (!testbits(timer->status, XNTIMER_DEQUEUED))
                xntimer_dequeue_periodic(timer);
@@ -502,7 +502,7 @@ static int xntimer_start_periodic(xntimer_t *timer,
 
 static void xntimer_stop_periodic(xntimer_t *timer)
 {
-       trace_mark(xn_nucleus, timer_stop, "timer %p", timer);
+       trace_xn_nucleus_timer_stop(timer);
 
        xntimer_dequeue_periodic(timer);
 }
@@ -571,6 +571,8 @@ void xntimer_tick_periodic_inner(xntslave_t *slave)
        xnqueue_t *timerq;
        xntimer_t *timer;
 
+       trace_xn_nucleus_timer_tick_periodic(base);
+
        /*
         * Update the periodic clocks keeping the things strictly
         * monotonous (this routine is run on every cpu, but only CPU
@@ -588,7 +590,7 @@ void xntimer_tick_periodic_inner(xntslave_t *slave)
                                  - base->jiffies) > 0)
                        break;
 
-               trace_mark(xn_nucleus, timer_expire, "timer %p", timer);
+               trace_xn_nucleus_timer_expire(timer);
 
                xntimer_dequeue_periodic(timer);
                xnstat_counter_inc(&timer->fired);
@@ -727,8 +729,6 @@ void xntslave_start(xntslave_t *slave, xnticks_t start, 
xnticks_t interval)
        int nr_cpus, cpu;
        spl_t s;
 
-       trace_mark(xn_nucleus, tbase_start, "base %s", slave->base.name);
-
        for (cpu = 0, nr_cpus = xnarch_num_online_cpus(); cpu < nr_cpus; cpu++) 
{
 
                struct percpu_cascade *pc = &slave->cascade[cpu];
@@ -746,8 +746,6 @@ void xntslave_stop(xntslave_t *slave)
        int nr_cpus, cpu;
        spl_t s;
 
-       trace_mark(xn_nucleus, tbase_stop, "base %s", slave->base.name);
-
        for (cpu = 0, nr_cpus = xnarch_num_online_cpus(); cpu < nr_cpus; cpu++) 
{
 
                struct percpu_cascade *pc = &slave->cascade[cpu];
@@ -945,9 +943,6 @@ int xntimer_migrate(xntimer_t *timer, xnsched_t *sched)
        int queued;
        spl_t s;
 
-       trace_mark(xn_nucleus, timer_migrate, "timer %p cpu %d",
-                  timer, (int)xnsched_cpu(sched));
-
        xnlock_get_irqsave(&nklock, s);
 
        if (sched == timer->sched)
@@ -1046,8 +1041,6 @@ void xntimer_freeze(void)
        int nr_cpus, cpu;
        spl_t s;
 
-       trace_mark(xn_nucleus, timer_freeze, MARK_NOARGS);
-
        xnlock_get_irqsave(&nklock, s);
 
        nr_cpus = xnarch_num_online_cpus();


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to