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

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Fri Feb 15 19:19:50 2013 +0100

nucleus: Instrument lostage work submission and handling

Helps to visualize the interaction between the nucleus and Linux. To
print the work type symbolically, we need to pull the related constants
into a header.

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

---

 include/nucleus/shadow.h   |    6 ++++++
 include/trace/xn_nucleus.h |   39 +++++++++++++++++++++++++++++++++++++++
 ksrc/nucleus/shadow.c      |   31 ++++++++++++++-----------------
 3 files changed, 59 insertions(+), 17 deletions(-)

diff --git a/include/nucleus/shadow.h b/include/nucleus/shadow.h
index bca3c48..1604c0d 100644
--- a/include/nucleus/shadow.h
+++ b/include/nucleus/shadow.h
@@ -22,6 +22,12 @@
 
 #include <asm/xenomai/atomic.h>
 
+#define XNSHADOW_LO_START_REQ  0
+#define XNSHADOW_LO_WAKEUP_REQ 1
+#define XNSHADOW_LO_SIGGRP_REQ 2
+#define XNSHADOW_LO_SIGTHR_REQ 3
+#define XNSHADOW_LO_UNMAP_REQ  4
+
 #ifdef CONFIG_XENO_OPT_PERVASIVE
 
 #include <asm/xenomai/syscall.h>
diff --git a/include/trace/xn_nucleus.h b/include/trace/xn_nucleus.h
index 0acbf41..2950da0 100644
--- a/include/trace/xn_nucleus.h
+++ b/include/trace/xn_nucleus.h
@@ -532,6 +532,45 @@ TRACE_EVENT(xn_nucleus_timebase_adjust,
        TP_printk("base_name=%s delta=%Lu", __entry->base_name, __entry->delta)
 );
 
+#define show_lostage_work_type(type)                           \
+       __print_symbolic(type,                                  \
+                        {XNSHADOW_LO_START_REQ, "start"},      \
+                        {XNSHADOW_LO_WAKEUP_REQ, "wakeup"},    \
+                        {XNSHADOW_LO_SIGGRP_REQ, "siggroup"},  \
+                        {XNSHADOW_LO_SIGTHR_REQ, "sigthread"}, \
+                        {XNSHADOW_LO_UNMAP_REQ, "unmap"})
+
+DECLARE_EVENT_CLASS(lostage_event,
+       TP_PROTO(int type, struct task_struct *p),
+       TP_ARGS(type, p),
+
+       TP_STRUCT__entry(
+               __field(int,            type)
+               __array(char,           comm,   TASK_COMM_LEN)
+               __field(pid_t,          pid)
+       ),
+
+       TP_fast_assign(
+               __entry->type           = type;
+               memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+               __entry->pid            = p->pid;
+       ),
+
+       TP_printk("type=%s comm=%s pid=%d",
+                 show_lostage_work_type(__entry->type),
+                 __entry->comm, __entry->pid)
+);
+
+DEFINE_EVENT(lostage_event, xn_nucleus_lostage_submit,
+       TP_PROTO(int type, struct task_struct *p),
+       TP_ARGS(type, p)
+);
+
+DEFINE_EVENT(lostage_event, xn_nucleus_lostage_work,
+       TP_PROTO(int type, struct task_struct *p),
+       TP_ARGS(type, p)
+);
+
 #endif /* _TRACE_XN_NUCLEUS_H */
 
 /* This part must be outside protection */
diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c
index b676f37..13865a3 100644
--- a/ksrc/nucleus/shadow.c
+++ b/ksrc/nucleus/shadow.c
@@ -87,11 +87,6 @@ static struct __lostagerq {
        int in, out;
 
        struct {
-#define LO_START_REQ  0
-#define LO_WAKEUP_REQ 1
-#define LO_SIGGRP_REQ 2
-#define LO_SIGTHR_REQ 3
-#define LO_UNMAP_REQ  4
                int type;
                struct task_struct *task;
                int arg;
@@ -772,16 +767,14 @@ static void lostage_handler(void *cookie)
 
                rq->out = (reqnum + 1) & (LO_MAX_REQUESTS - 1);
 
-               trace_mark(xn_nucleus, lostage_work,
-                          "type %d comm %s pid %d",
-                          type, p->comm, p->pid);
+               trace_xn_nucleus_lostage_work(type, p);
 
                switch (type) {
-               case LO_UNMAP_REQ:
+               case XNSHADOW_LO_UNMAP_REQ:
                        xnshadow_dereference_skin(arg);
 
                        /* fall through */
-               case LO_WAKEUP_REQ:
+               case XNSHADOW_LO_WAKEUP_REQ:
                        /*
                         * We need to downgrade the root thread
                         * priority whenever the APC runs over a
@@ -795,11 +788,11 @@ static void lostage_handler(void *cookie)
                        xnpod_schedule();
 
                        /* fall through */
-               case LO_START_REQ:
+               case XNSHADOW_LO_START_REQ:
                        wake_up_process(p);
                        break;
 
-               case LO_SIGTHR_REQ:
+               case XNSHADOW_LO_SIGTHR_REQ:
                        xnshadow_sig_demux(arg, sig, sigarg);
                        if (sig == SIGSHADOW || sig == SIGDEBUG) {
                                siginfo_t si;
@@ -812,7 +805,7 @@ static void lostage_handler(void *cookie)
                                send_sig(sig, p, 1);
                        break;
 
-               case LO_SIGGRP_REQ:
+               case XNSHADOW_LO_SIGGRP_REQ:
                        kill_proc(p->pid, arg, 1);
                        break;
                }
@@ -831,6 +824,8 @@ static void schedule_linux_call(int type, struct 
task_struct *p, int arg)
                            arg);
                );
 
+       trace_xn_nucleus_lostage_submit(type, p);
+
        splhigh(s);
 
        cpu = rthal_processor_id();
@@ -1134,7 +1129,7 @@ void xnshadow_relax(int notify, int reason)
         */
        splmax();
        rpi_push(thread->sched, thread);
-       schedule_linux_call(LO_WAKEUP_REQ, current, 0);
+       schedule_linux_call(XNSHADOW_LO_WAKEUP_REQ, current, 0);
 
        /*
         * Task nklock to synchronize the Linux task state manipulation with
@@ -1441,7 +1436,8 @@ void xnshadow_unmap(xnthread_t *thread)
 
        xnshadow_thrptd(p) = NULL;
 
-       schedule_linux_call(LO_UNMAP_REQ, p, xnthread_get_magic(thread));
+       schedule_linux_call(XNSHADOW_LO_UNMAP_REQ, p,
+                           xnthread_get_magic(thread));
 }
 EXPORT_SYMBOL_GPL(xnshadow_unmap);
 
@@ -1502,7 +1498,7 @@ void xnshadow_start(struct xnthread *thread)
 
        if (p->state == TASK_INTERRUPTIBLE)
                /* Wakeup the Linux mate waiting on the barrier. */
-               schedule_linux_call(LO_START_REQ, p, 0);
+               schedule_linux_call(XNSHADOW_LO_START_REQ, p, 0);
 }
 EXPORT_SYMBOL_GPL(xnshadow_start);
 
@@ -2218,7 +2214,8 @@ substitute_linux_syscall(struct pt_regs *regs)
 
 void xnshadow_send_sig(xnthread_t *thread, int sig, int arg, int specific)
 {
-       schedule_linux_call(specific ? LO_SIGTHR_REQ : LO_SIGGRP_REQ,
+       schedule_linux_call(specific ? XNSHADOW_LO_SIGTHR_REQ
+                                    : XNSHADOW_LO_SIGGRP_REQ,
                            xnthread_user_task(thread),
                            xnshadow_sig_mux(sig, specific ? arg : 0));
 }


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

Reply via email to