Module: xenomai-forge
Branch: next
Commit: 9824991b591302c7a2bd5af9524277d2d4879b0a
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9824991b591302c7a2bd5af9524277d2d4879b0a

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon May 19 11:20:33 2014 +0200

cobalt/posix/cond: introduce tracepoints

---

 kernel/cobalt/posix/Makefile       |    2 +-
 kernel/cobalt/posix/cond.c         |   22 +++++----
 kernel/cobalt/trace/cobalt-posix.h |   89 ++++++++++++++++++++++++++++++------
 3 files changed, 89 insertions(+), 24 deletions(-)

diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile
index 9d77f72..b23baa5 100644
--- a/kernel/cobalt/posix/Makefile
+++ b/kernel/cobalt/posix/Makefile
@@ -19,4 +19,4 @@ posix-y :=            \
        timer.o         \
        timerfd.o
 
-ccflags-y := -Iarch/$(SRCARCH)/xenomai/include -Iinclude/xenomai
+ccflags-y := -Iarch/$(SRCARCH)/xenomai/include -Iinclude/xenomai -Ikernel
diff --git a/kernel/cobalt/posix/cond.c b/kernel/cobalt/posix/cond.c
index 73f3971..5c3fd24 100644
--- a/kernel/cobalt/posix/cond.c
+++ b/kernel/cobalt/posix/cond.c
@@ -52,6 +52,7 @@
 #include "mutex.h"
 #include "cond.h"
 #include "clock.h"
+#include <trace/events/cobalt-posix.h>
 
 static inline void
 cond_destroy_internal(xnhandle_t handle, struct cobalt_kqueues *q)
@@ -112,9 +113,6 @@ pthread_cond_init(struct cobalt_cond_shadow *cnd, const 
pthread_condattr_t *attr
        struct xnsys_ppd *sys_ppd;
        spl_t s;
 
-       if (attr == NULL)
-               attr = &cobalt_default_cond_attr;
-
        cond = xnmalloc(sizeof(*cond));
        if (cond == NULL)
                return -ENOMEM;
@@ -360,8 +358,9 @@ unlock_and_return:
 int cobalt_cond_init(struct cobalt_cond_shadow __user *u_cnd,
                     const pthread_condattr_t __user *u_attr)
 {
-       pthread_condattr_t locattr, *attr;
+       const pthread_condattr_t *attr;
        struct cobalt_cond_shadow cnd;
+       pthread_condattr_t locattr;
        int err;
 
        if (__xn_safe_copy_from_user(&cnd, u_cnd, sizeof(cnd)))
@@ -374,9 +373,10 @@ int cobalt_cond_init(struct cobalt_cond_shadow __user 
*u_cnd,
 
                attr = &locattr;
        } else
-               attr = NULL;
+               attr = &cobalt_default_cond_attr;
+
+       trace_cobalt_cond_init(u_cnd, attr);
 
-       /* Always use default attribute. */
        err = pthread_cond_init(&cnd, attr);
        if (err < 0)
                return err;
@@ -392,6 +392,8 @@ int cobalt_cond_destroy(struct cobalt_cond_shadow __user 
*u_cnd)
        if (__xn_safe_copy_from_user(&cnd, u_cnd, sizeof(cnd)))
                return -EFAULT;
 
+       trace_cobalt_cond_destroy(u_cnd);
+
        err = pthread_cond_destroy(&cnd);
        if (err < 0)
                return err;
@@ -432,14 +434,18 @@ int cobalt_cond_wait_prologue(struct cobalt_cond_shadow 
__user *u_cnd,
 
        if (timed) {
                err = __xn_safe_copy_from_user(&ts, u_ts, sizeof(ts))?-EFAULT:0;
-               if (!err)
+               if (!err) {
+                       trace_cobalt_cond_timedwait(u_cnd, u_mx, &ts);
                        err = cobalt_cond_timedwait_prologue(cur,
                                                             cnd, mx, timed,
                                                             ts2ns(&ts) + 1);
-       } else
+               }
+       } else {
+               trace_cobalt_cond_wait(u_cnd, u_mx);
                err = cobalt_cond_timedwait_prologue(cur, cnd,
                                                     mx, timed,
                                                     XN_INFINITE);
+       }
 
        switch(err) {
        case 0:
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index 66dc7b0..f9d2082 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -5,6 +5,7 @@
 #define _TRACE_COBALT_POSIX_H
 
 #include <linux/tracepoint.h>
+#include <xenomai/posix/cond.h>
 
 #define __timespec_fields(__name)                              \
        __field(__kernel_time_t, tv_sec_##__name)               \
@@ -70,21 +71,6 @@
        __ret;                                                          \
 })
 
-DECLARE_EVENT_CLASS(cobalt_posix_timespec,
-       TP_PROTO(struct timespec *ts),
-       TP_ARGS(ts),
-
-       TP_STRUCT__entry(
-               __timespec_fields(ts)
-       ),
-
-       TP_fast_assign(
-               __assign_timespec(ts, ts);
-       ),
-
-       TP_printk("time=(%ld.%09ld)", __timespec_args(ts))
-);
-
 DECLARE_EVENT_CLASS(cobalt_posix_schedparam,
        TP_PROTO(unsigned long pth, int policy,
                 struct sched_param_ex *param_ex),
@@ -658,6 +644,79 @@ DEFINE_EVENT(cobalt_clock_ident, cobalt_clock_deregister,
        TP_ARGS(name, clk_id)
 );
 
+#define cobalt_print_clock(__clk_id)                                   \
+       __print_symbolic(__clk_id,                                      \
+                        {CLOCK_MONOTONIC, "CLOCK_MONOTONIC"},          \
+                        {CLOCK_MONOTONIC_RAW, "CLOCK_MONOTONIC_RAW"},  \
+                        {CLOCK_REALTIME, "CLOCK_REALTIME"})
+
+TRACE_EVENT(cobalt_cond_init,
+       TP_PROTO(const struct cobalt_cond_shadow __user *u_cnd,
+                const pthread_condattr_t *attr),
+       TP_ARGS(u_cnd, attr),
+       TP_STRUCT__entry(
+               __field(const struct cobalt_cond_shadow __user *, u_cnd)
+               __field(clockid_t, clk_id)
+               __field(int, pshared)
+       ),
+       TP_fast_assign(
+               __entry->u_cnd = u_cnd;
+               __entry->clk_id = attr->clock;
+               __entry->pshared = attr->pshared;
+       ),
+       TP_printk("cond=%p attr={ .clock=%s, .pshared=%d }",
+                 __entry->u_cnd,
+                 cobalt_print_clock(__entry->clk_id),
+                 __entry->pshared)
+);
+
+TRACE_EVENT(cobalt_cond_destroy,
+       TP_PROTO(const struct cobalt_cond_shadow __user *u_cnd),
+       TP_ARGS(u_cnd),
+       TP_STRUCT__entry(
+               __field(const struct cobalt_cond_shadow __user *, u_cnd)
+       ),
+       TP_fast_assign(
+               __entry->u_cnd = u_cnd;
+       ),
+       TP_printk("cond=%p", __entry->u_cnd)
+);
+
+TRACE_EVENT(cobalt_cond_timedwait,
+       TP_PROTO(const struct cobalt_cond_shadow __user *u_cnd,
+                const struct cobalt_mutex_shadow __user *u_mx,
+                const struct timespec *timeout),
+       TP_ARGS(u_cnd, u_mx, timeout),
+       TP_STRUCT__entry(
+               __field(const struct cobalt_cond_shadow __user *, u_cnd)
+               __field(const struct cobalt_mutex_shadow __user *, u_mx)
+               __timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->u_cnd = u_cnd;
+               __entry->u_mx = u_mx;
+               __assign_timespec(timeout, timeout);
+       ),
+       TP_printk("cond=%p, mutex=%p, timeout=(%ld.%09ld)",
+                 __entry->u_cnd, __entry->u_mx, __timespec_args(timeout))
+);
+
+TRACE_EVENT(cobalt_cond_wait,
+       TP_PROTO(const struct cobalt_cond_shadow __user *u_cnd,
+                const struct cobalt_mutex_shadow __user *u_mx),
+       TP_ARGS(u_cnd, u_mx),
+       TP_STRUCT__entry(
+               __field(const struct cobalt_cond_shadow __user *, u_cnd)
+               __field(const struct cobalt_mutex_shadow __user *, u_mx)
+       ),
+       TP_fast_assign(
+               __entry->u_cnd = u_cnd;
+               __entry->u_mx = u_mx;
+       ),
+       TP_printk("cond=%p, mutex=%p",
+                 __entry->u_cnd, __entry->u_mx)
+);
+
 #endif /* _TRACE_COBALT_POSIX_H */
 
 /* This part must be outside protection */


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

Reply via email to