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

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Mon Oct 18 12:54:33 2010 +0200

Basic trace events conversion

Convert a few nucleus tracepoints into TRACE_EVENT format, providing
both the oportunity to build them against LTTng markers and upstream
kernel event tracepoints.

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

---

 include/trace/xn_nucleus.h |  228 ++++++++++++++++++++++++++++++++++++++++++++
 ksrc/nucleus/pod.c         |   39 +++-----
 2 files changed, 241 insertions(+), 26 deletions(-)

diff --git a/include/trace/xn_nucleus.h b/include/trace/xn_nucleus.h
new file mode 100644
index 0000000..f5a518b
--- /dev/null
+++ b/include/trace/xn_nucleus.h
@@ -0,0 +1,228 @@
+#ifndef CONFIG_MARKERS
+
+#if !defined(_TRACE_XN_NUCLEUS_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_XN_NUCLEUS_H
+
+#include <linux/tracepoint.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM xn_nucleus
+
+TRACE_EVENT(xn_nucleus_sched,
+       TP_PROTO(struct xnsched *sched),
+       TP_ARGS(sched),
+
+       TP_STRUCT__entry(
+               __field(unsigned long,          status)
+       ),
+
+       TP_fast_assign(
+               __entry->status         = sched->status;
+       ),
+
+       TP_printk("status=%lx", __entry->status)
+);
+
+TRACE_EVENT(xn_nucleus_sched_remote,
+       TP_PROTO(struct xnsched *sched),
+       TP_ARGS(sched),
+
+       TP_STRUCT__entry(
+               __field(unsigned long,          status)
+       ),
+
+       TP_fast_assign(
+               __entry->status         = sched->status;
+       ),
+
+       TP_printk("status=%lx", __entry->status)
+);
+
+TRACE_EVENT(xn_nucleus_sched_switch,
+       TP_PROTO(struct xnthread *prev, struct xnthread *next),
+       TP_ARGS(prev, next),
+
+       TP_STRUCT__entry(
+               __field(struct xnthread *,      prev)
+               __field(struct xnthread *,      next)
+               __array(char,                   prev_name, XNOBJECT_NAME_LEN)
+               __array(char,                   next_name, XNOBJECT_NAME_LEN)
+       ),
+
+       TP_fast_assign(
+               __entry->prev           = prev;
+               __entry->next           = next;
+               memcpy(__entry->prev_name, xnthread_name(prev),
+                      XNOBJECT_NAME_LEN);
+               memcpy(__entry->next_name, xnthread_name(next),
+                      XNOBJECT_NAME_LEN);
+       ),
+
+       TP_printk("prev=%p prev_name=%s next=%p next_name=%s",
+                 __entry->prev, __entry->prev_name,
+                 __entry->next, __entry->next_name)
+);
+
+TRACE_EVENT(xn_nucleus_sched_sigdispatch,
+       TP_PROTO(struct xnthread *thread),
+       TP_ARGS(thread),
+
+       TP_STRUCT__entry(
+               __field(unsigned long,          signals)
+       ),
+
+       TP_fast_assign(
+               __entry->signals        = thread->signals;
+       ),
+
+       TP_printk("signals=%lx", __entry->signals)
+);
+
+TRACE_EVENT(xn_nucleus_thread_init,
+       TP_PROTO(struct xnthread *thread,
+                const struct xnthread_init_attr *attr,
+                struct xnsched_class *sched_class),
+       TP_ARGS(thread, attr, sched_class),
+
+       TP_STRUCT__entry(
+               __field(struct xnthread *,      thread)
+               __array(char,                   thread_name, XNOBJECT_NAME_LEN)
+               __field(xnflags_t,              flags)
+               __array(char,                   class_name, XNOBJECT_NAME_LEN)
+               __field(int,                    cprio)
+       ),
+
+       TP_fast_assign(
+               __entry->thread         = thread;
+               memcpy(__entry->thread_name, xnthread_name(thread),
+                      XNOBJECT_NAME_LEN);
+               __entry->flags          = attr->flags;
+               memcpy(__entry->class_name, sched_class->name,
+                      XNOBJECT_NAME_LEN-1);
+               __entry->class_name[XNOBJECT_NAME_LEN-1] = 0;
+               __entry->cprio          = thread->cprio;
+       ),
+
+       TP_printk("thread=%p thread_name=%s flags=%lx class=%s prio=%d",
+                  __entry->thread, __entry->thread_name, __entry->flags,
+                  __entry->class_name, __entry->cprio)
+);
+
+TRACE_EVENT(xn_nucleus_thread_suspend,
+       TP_PROTO(struct xnthread *thread, xnflags_t mask, xnticks_t timeout,
+                xntmode_t timeout_mode, xnsynch_t *wchan),
+       TP_ARGS(thread, mask, timeout, timeout_mode, wchan),
+
+       TP_STRUCT__entry(
+               __field(struct xnthread *,      thread)
+               __array(char,                   thread_name, XNOBJECT_NAME_LEN)
+               __field(xnflags_t,              mask)
+               __field(xnticks_t,              timeout)
+               __field(xntmode_t,              timeout_mode)
+               __field(xnsynch_t *,            wchan)
+       ),
+
+       TP_fast_assign(
+               __entry->thread         = thread;
+               memcpy(__entry->thread_name, xnthread_name(thread),
+                      XNOBJECT_NAME_LEN);
+               __entry->mask           = mask;
+               __entry->timeout        = timeout;
+               __entry->timeout_mode   = timeout_mode;
+               __entry->wchan          = wchan;
+       ),
+
+       TP_printk("thread=%p thread_name=%s mask=%lu timeout=%Lu "
+                 "timeout_mode=%d wchan=%p",
+                 __entry->thread, __entry->thread_name, __entry->mask,
+                 __entry->timeout, __entry->timeout_mode, __entry->wchan)
+);
+
+TRACE_EVENT(xn_nucleus_thread_resume,
+       TP_PROTO(struct xnthread *thread, xnflags_t mask),
+       TP_ARGS(thread, mask),
+
+       TP_STRUCT__entry(
+               __field(struct xnthread *,      thread)
+               __array(char,                   thread_name, XNOBJECT_NAME_LEN)
+               __field(xnflags_t,              mask)
+       ),
+
+       TP_fast_assign(
+               __entry->thread         = thread;
+               memcpy(__entry->thread_name, xnthread_name(thread),
+                      XNOBJECT_NAME_LEN);
+               __entry->mask           = mask;
+       ),
+
+       TP_printk("thread=%p thread_name=%s mask=%lx",
+                 __entry->thread, __entry->thread_name, __entry->mask)
+);
+
+#endif /* _TRACE_XN_NUCLEUS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
+
+#else /* CONFIG_MARKERS */
+
+/* LTTng support */
+
+static inline void trace_xn_nucleus_sched(struct xnsched *sched)
+{
+       trace_mark(xn_nucleus, sched, MARK_NOARGS);
+}
+
+static inline void trace_xn_nucleus_sched_remote(struct xnsched *sched)
+{
+       trace_mark(xn_nucleus, sched_remote, MARK_NOARGS);
+}
+
+static inline void
+trace_xn_nucleus_sched_switch(struct xnthread *prev, struct xnthread *next)
+{
+       trace_mark(xn_nucleus, sched_switch,
+                  "prev %p prev_name %s "
+                  "next %p next_name %s",
+                  prev, xnthread_name(prev),
+                  next, xnthread_name(next));
+}
+
+static inline void trace_xn_nucleus_sched_sigdispatch(struct xnthread *thread)
+{
+       trace_mark(xn_nucleus, sched_sigdispatch, "signals %lu",
+                  thread->signals);
+}
+
+static inline void
+trace_xn_nucleus_thread_init(struct xnthread *thread,
+                            const struct xnthread_init_attr *attr,
+                            struct xnsched_class *sched_class)
+{
+       trace_mark(xn_nucleus, thread_init,
+                  "thread %p thread_name %s flags %lu class %s prio %d",
+                  thread, xnthread_name(thread), attr->flags,
+                  sched_class->name, thread->cprio);
+}
+
+static inline void
+trace_xn_nucleus_thread_suspend(struct xnthread *thread, xnflags_t mask,
+                               xnticks_t timeout, xntmode_t timeout_mode,
+                               xnsynch_t *wchan)
+{
+       trace_mark(xn_nucleus, thread_suspend,
+                  "thread %p thread_name %s mask %lu timeout %Lu "
+                  "timeout_mode %d wchan %p",
+                  thread, xnthread_name(thread), mask, timeout,
+                  timeout_mode, wchan);
+}
+
+static inline void
+trace_xn_nucleus_thread_resume(struct xnthread *thread, xnflags_t mask)
+{
+       trace_mark(xn_nucleus, thread_resume,
+                  "thread %p thread_name %s mask %lu",
+                  thread, xnthread_name(thread), mask);
+}
+
+#endif /* CONFIG_MARKERS */
diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 862838c..9e135f3 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -46,6 +46,9 @@
 #include <nucleus/select.h>
 #include <asm/xenomai/bits/pod.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/xn_nucleus.h>
+
 /*
  * NOTE: We need to initialize the globals; remember that this code
  * also runs over the simulator in user-space.
@@ -276,17 +279,14 @@ EXPORT_SYMBOL_GPL(xnpod_fatal_helper);
 
 void xnpod_schedule_handler(void) /* Called with hw interrupts off. */
 {
-       xnsched_t *sched;
+       xnsched_t *sched = xnpod_current_sched();
 
-       trace_mark(xn_nucleus, sched_remote, MARK_NOARGS);
+       trace_xn_nucleus_sched_remote(sched);
 #if defined(CONFIG_SMP) && defined(CONFIG_XENO_OPT_PRIOCPL)
-       sched = xnpod_current_sched();
        if (testbits(sched->status, XNRPICK)) {
                clrbits(sched->status, XNRPICK);
                xnshadow_rpi_check();
        }
-#else
-       (void)sched;
 #endif /* CONFIG_SMP && CONFIG_XENO_OPT_PRIOCPL */
        xnpod_schedule();
 }
@@ -647,10 +647,7 @@ int xnpod_init_thread(struct xnthread *thread,
        if (ret)
                return ret;
 
-       trace_mark(xn_nucleus, thread_init,
-                  "thread %p thread_name %s flags %lu class %s prio %d",
-                  thread, xnthread_name(thread), attr->flags,
-                  sched_class->name, thread->cprio);
+       trace_xn_nucleus_thread_init(thread, attr, sched_class);
 
        xnlock_get_irqsave(&nklock, s);
        appendq(&nkpod->threadq, &thread->glink);
@@ -1380,11 +1377,8 @@ void xnpod_suspend_thread(xnthread_t *thread, xnflags_t 
mask,
 
        xnlock_get_irqsave(&nklock, s);
 
-       trace_mark(xn_nucleus, thread_suspend,
-                  "thread %p thread_name %s mask %lu timeout %Lu "
-                  "timeout_mode %d wchan %p",
-                  thread, xnthread_name(thread), mask, timeout,
-                  timeout_mode, wchan);
+       trace_xn_nucleus_thread_suspend(thread, mask, timeout, timeout_mode,
+                                       wchan);
 
        sched = thread->sched;
        oldstate = thread->state;
@@ -1597,9 +1591,7 @@ void xnpod_resume_thread(struct xnthread *thread, 
xnflags_t mask)
 
        xnlock_get_irqsave(&nklock, s);
 
-       trace_mark(xn_nucleus, thread_resume,
-                  "thread %p thread_name %s mask %lu",
-                  thread, xnthread_name(thread), mask);
+       trace_xn_nucleus_thread_resume(thread, mask);
        xnarch_trace_pid(xnthread_user_task(thread) ?
                         xnarch_user_pid(xnthread_archtcb(thread)) : -1,
                         xnthread_current_priority(thread));
@@ -2020,8 +2012,7 @@ void xnpod_dispatch_signals(void)
            || thread->asr == XNTHREAD_INVALID_ASR)
                return;
 
-       trace_mark(xn_nucleus, sched_sigdispatch, "signals %lu",
-                  thread->signals);
+       trace_xn_nucleus_sched_sigdispatch(thread);
 
        /* Start the asynchronous service routine */
        oldmode = xnthread_test_state(thread, XNTHREAD_MODE_BITS);
@@ -2192,10 +2183,10 @@ void __xnpod_schedule(struct xnsched *sched)
        if (xnarch_escalate())
                return;
 
-       trace_mark(xn_nucleus, sched, MARK_NOARGS);
-
        xnlock_get_irqsave(&nklock, s);
 
+       trace_xn_nucleus_sched(sched);
+
        curr = sched->curr;
 
        xnarch_trace_pid(xnthread_user_task(curr) ?
@@ -2226,11 +2217,7 @@ reschedule:
 
        prev = curr;
 
-       trace_mark(xn_nucleus, sched_switch,
-                  "prev %p prev_name %s "
-                  "next %p next_name %s",
-                  prev, xnthread_name(prev),
-                  next, xnthread_name(next));
+       trace_xn_nucleus_sched_switch(prev, next);
 
 #ifdef CONFIG_XENO_OPT_PERVASIVE
        shadow = xnthread_test_state(prev, XNSHADOW);


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to