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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon May 26 17:30:35 2014 +0200

cobalt/posix/mq: introduce tracepoints

---

 kernel/cobalt/posix/mqueue.c       |   30 ++++--
 kernel/cobalt/posix/mqueue.h       |    8 +-
 kernel/cobalt/trace/cobalt-posix.h |  193 ++++++++++++++++++++++++++++++++++++
 3 files changed, 220 insertions(+), 11 deletions(-)

diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index 48a1c7a..7b8ac8d 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -39,18 +39,12 @@
 #include "timer.h"
 #include "mqueue.h"
 #include "clock.h"
+#include <trace/events/cobalt-posix.h>
 
 #define COBALT_MSGMAX          65536
 #define COBALT_MSGSIZEMAX      (16*1024*1024)
 #define COBALT_MSGPRIOMAX      32768
 
-struct mq_attr {
-       long mq_flags;
-       long mq_maxmsg;
-       long mq_msgsize;
-       long mq_curmsgs;
-};
-
 struct cobalt_mq {
        unsigned magic;
 
@@ -1013,6 +1007,8 @@ int cobalt_mq_notify(mqd_t fd, const struct sigevent 
*__user evp)
                goto out;
        }
 
+       trace_cobalt_mq_notify(fd, evp ? &sev : NULL);
+
        err = mq_notify(mqd, fd, evp ? &sev : NULL);
 
   out:
@@ -1047,11 +1043,15 @@ int cobalt_mq_open(const char __user *u_name, int 
oflags,
        } else
                attr = NULL;
 
+       trace_cobalt_mq_open(name, oflags, mode, uqd);
+
        return mq_open(uqd, name, oflags, mode, attr);
 }
 
 int cobalt_mq_close(mqd_t uqd)
 {
+       trace_cobalt_mq_close(uqd);
+
        return mq_close(uqd);
 }
 
@@ -1066,6 +1066,8 @@ int cobalt_mq_unlink(const char __user *u_name)
        if (len >= sizeof(name))
                return -ENAMETOOLONG;
 
+       trace_cobalt_mq_unlink(name);
+
        return mq_unlink(name);
 }
 
@@ -1085,6 +1087,8 @@ int cobalt_mq_getattr(mqd_t uqd, struct mq_attr __user 
*u_attr)
        if (err)
                return err;
 
+       trace_cobalt_mq_getattr(uqd, &attr);
+
        return __xn_safe_copy_to_user(u_attr, &attr, sizeof(attr));
 }
 
@@ -1104,6 +1108,8 @@ int cobalt_mq_setattr(mqd_t uqd, const struct mq_attr 
__user *u_attr,
                goto out;
        }
 
+       trace_cobalt_mq_setattr(uqd, &attr);
+
        err = mq_setattr(mqd, &attr, &oattr);
   out:
        cobalt_mqd_put(mqd);
@@ -1144,8 +1150,11 @@ int cobalt_mq_timedsend(mqd_t uqd, const void __user 
*u_buf, size_t len,
                        goto out;
                }
                timeoutp = &timeout;
-       } else
+               trace_cobalt_mq_timedsend(uqd, u_buf, len, prio, &timeout);
+       } else {
                timeoutp = NULL;
+               trace_cobalt_mq_send(uqd, u_buf, len, prio);
+       }
 
        msg = cobalt_mq_timedsend_inner(mqd, len, timeoutp);
        if (IS_ERR(msg)) {
@@ -1201,8 +1210,11 @@ int cobalt_mq_timedreceive(mqd_t uqd, void __user *u_buf,
                }
 
                timeoutp = &timeout;
-       } else
+               trace_cobalt_mq_timedreceive(uqd, u_buf, len, &timeout);
+       } else {
                timeoutp = NULL;
+               trace_cobalt_mq_receive(uqd, u_buf, len);
+       }
 
        msg = cobalt_mq_timedrcv_inner(mqd, len, timeoutp);
        if (IS_ERR(msg)) {
diff --git a/kernel/cobalt/posix/mqueue.h b/kernel/cobalt/posix/mqueue.h
index 712ea87..8370634 100644
--- a/kernel/cobalt/posix/mqueue.h
+++ b/kernel/cobalt/posix/mqueue.h
@@ -22,8 +22,12 @@
 #include <linux/types.h>
 #include <linux/fcntl.h>
 
-struct cobalt_process;
-struct mq_attr;
+struct mq_attr {
+       long mq_flags;
+       long mq_maxmsg;
+       long mq_msgsize;
+       long mq_curmsgs;
+};
 
 int cobalt_mq_open(const char __user *u_name, int oflags,
                   mode_t mode, struct mq_attr __user *u_attr, mqd_t uqd);
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index f9d2082..27b3a31 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -6,6 +6,7 @@
 
 #include <linux/tracepoint.h>
 #include <xenomai/posix/cond.h>
+#include <xenomai/posix/mqueue.h>
 
 #define __timespec_fields(__name)                              \
        __field(__kernel_time_t, tv_sec_##__name)               \
@@ -717,6 +718,198 @@ TRACE_EVENT(cobalt_cond_wait,
                  __entry->u_cnd, __entry->u_mx)
 );
 
+TRACE_EVENT(cobalt_mq_open,
+       TP_PROTO(const char *name, int oflags, mode_t mode, mqd_t mqd),
+       TP_ARGS(name, oflags, mode, mqd),
+
+       TP_STRUCT__entry(
+               __string(name, name)
+               __field(int, oflags)
+               __field(mode_t, mode)
+               __field(mqd_t, mqd)
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->oflags = oflags;
+               __entry->mode = (oflags & O_CREAT) ? mode : 0;
+               __entry->mqd = mqd;
+       ),
+
+       TP_printk("name=%s oflags=%#x(%s) mode=%o mqd=%d",
+                 __get_str(name),
+                 __entry->oflags, cobalt_print_oflags(__entry->oflags),
+                 __entry->mode,
+                 __entry->mqd)
+);
+
+TRACE_EVENT(cobalt_mq_notify,
+       TP_PROTO(mqd_t mqd, const struct sigevent *sev),
+       TP_ARGS(mqd, sev),
+
+       TP_STRUCT__entry(
+               __field(mqd_t, mqd)
+               __field(int, signo)
+       ),
+
+       TP_fast_assign(
+               __entry->mqd = mqd;
+               __entry->signo = sev && sev->sigev_notify != SIGEV_NONE ?
+                       sev->sigev_signo : 0;
+       ),
+
+       TP_printk("mqd=%d signo=%d",
+                 __entry->mqd, __entry->signo)
+);
+
+TRACE_EVENT(cobalt_mq_close,
+       TP_PROTO(mqd_t mqd),
+       TP_ARGS(mqd),
+
+       TP_STRUCT__entry(
+               __field(mqd_t, mqd)
+       ),
+
+       TP_fast_assign(
+               __entry->mqd = mqd;
+       ),
+
+       TP_printk("mqd=%d", __entry->mqd)
+);
+
+TRACE_EVENT(cobalt_mq_unlink,
+       TP_PROTO(const char *name),
+       TP_ARGS(name),
+
+       TP_STRUCT__entry(
+               __string(name, name)
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+       ),
+
+       TP_printk("name=%s", __get_str(name))
+);
+
+TRACE_EVENT(cobalt_mq_timedsend,
+       TP_PROTO(mqd_t mqd, const void __user *u_buf, size_t len,
+                unsigned int prio, const struct timespec *timeout),
+       TP_ARGS(mqd, u_buf, len, prio, timeout),
+       TP_STRUCT__entry(
+               __field(mqd_t, mqd)
+               __field(const void __user *, u_buf)
+               __field(size_t, len)
+               __field(unsigned int, prio)
+               __timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->mqd = mqd;
+               __entry->u_buf = u_buf;
+               __entry->len = len;
+               __entry->prio = prio;
+               __assign_timespec(timeout, timeout);
+       ),
+       TP_printk("mqd=%d buf=%p len=%Zu prio=%u timeout=(%ld.%09ld)",
+                 __entry->mqd, __entry->u_buf, __entry->len,
+                 __entry->prio, __timespec_args(timeout))
+);
+
+TRACE_EVENT(cobalt_mq_send,
+       TP_PROTO(mqd_t mqd, const void __user *u_buf, size_t len,
+                unsigned int prio),
+       TP_ARGS(mqd, u_buf, len, prio),
+       TP_STRUCT__entry(
+               __field(mqd_t, mqd)
+               __field(const void __user *, u_buf)
+               __field(size_t, len)
+               __field(unsigned int, prio)
+       ),
+       TP_fast_assign(
+               __entry->mqd = mqd;
+               __entry->u_buf = u_buf;
+               __entry->len = len;
+               __entry->prio = prio;
+       ),
+       TP_printk("mqd=%d buf=%p len=%Zu prio=%u",
+                 __entry->mqd, __entry->u_buf, __entry->len,
+                 __entry->prio)
+);
+
+TRACE_EVENT(cobalt_mq_timedreceive,
+       TP_PROTO(mqd_t mqd, const void __user *u_buf, size_t len,
+                const struct timespec *timeout),
+       TP_ARGS(mqd, u_buf, len, timeout),
+       TP_STRUCT__entry(
+               __field(mqd_t, mqd)
+               __field(const void __user *, u_buf)
+               __field(size_t, len)
+               __timespec_fields(timeout)
+       ),
+       TP_fast_assign(
+               __entry->mqd = mqd;
+               __entry->u_buf = u_buf;
+               __entry->len = len;
+               __assign_timespec(timeout, timeout);
+       ),
+       TP_printk("mqd=%d buf=%p len=%Zu timeout=(%ld.%09ld)",
+                 __entry->mqd, __entry->u_buf, __entry->len,
+                 __timespec_args(timeout))
+);
+
+TRACE_EVENT(cobalt_mq_receive,
+       TP_PROTO(mqd_t mqd, const void __user *u_buf, size_t len),
+       TP_ARGS(mqd, u_buf, len),
+       TP_STRUCT__entry(
+               __field(mqd_t, mqd)
+               __field(const void __user *, u_buf)
+               __field(size_t, len)
+       ),
+       TP_fast_assign(
+               __entry->mqd = mqd;
+               __entry->u_buf = u_buf;
+               __entry->len = len;
+       ),
+       TP_printk("mqd=%d buf=%p len=%Zu",
+                 __entry->mqd, __entry->u_buf, __entry->len)
+);
+
+DECLARE_EVENT_CLASS(cobalt_posix_mqattr,
+       TP_PROTO(mqd_t mqd, const struct mq_attr *attr),
+       TP_ARGS(mqd, attr),
+       TP_STRUCT__entry(
+               __field(mqd_t, mqd)
+               __field(long, flags)
+               __field(long, curmsgs)
+               __field(long, msgsize)
+               __field(long, maxmsg)
+       ),
+       TP_fast_assign(
+               __entry->mqd = mqd;
+               __entry->flags = attr->mq_flags;
+               __entry->curmsgs = attr->mq_curmsgs;
+               __entry->msgsize = attr->mq_msgsize;
+               __entry->maxmsg = attr->mq_maxmsg;
+       ),
+       TP_printk("mqd=%d flags=%#lx(%s) curmsgs=%ld msgsize=%ld maxmsg=%ld",
+                 __entry->mqd,
+                 __entry->flags, cobalt_print_oflags(__entry->flags),
+                 __entry->curmsgs,
+                 __entry->msgsize,
+                 __entry->maxmsg
+       )
+);
+
+DEFINE_EVENT(cobalt_posix_mqattr, cobalt_mq_getattr,
+       TP_PROTO(mqd_t mqd, const struct mq_attr *attr),
+       TP_ARGS(mqd, attr)
+);
+
+DEFINE_EVENT(cobalt_posix_mqattr, cobalt_mq_setattr,
+       TP_PROTO(mqd_t mqd, const struct mq_attr *attr),
+       TP_ARGS(mqd, attr)
+);
+
 #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