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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue May 13 18:06:23 2014 +0200

cobalt/posix/clock: kernel tracepoints (WIP)

---

 kernel/cobalt/posix/clock.c        |   24 +++++++---
 kernel/cobalt/trace/cobalt-posix.h |   86 ++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 68383a7..951daf8 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -60,6 +60,7 @@
 #include "internal.h"
 #include "thread.h"
 #include "clock.h"
+#include <trace/events/cobalt-posix.h>
 
 static struct xnclock *external_clocks[COBALT_MAX_EXTCLOCKS];
 
@@ -177,6 +178,8 @@ int cobalt_clock_getres(clockid_t clock_id, struct timespec 
__user *u_ts)
        if (u_ts && __xn_safe_copy_to_user(u_ts, &ts, sizeof(ts)))
                return -EFAULT;
 
+       trace_cobalt_clock_getres(clock_id, &ts);
+
        return 0;
 }
 
@@ -184,7 +187,7 @@ int cobalt_clock_gettime(clockid_t clock_id, struct 
timespec __user *u_ts)
 {
        struct timespec ts;
        xnticks_t ns;
-       int ret = 0;
+       int ret;
 
        switch (clock_id) {
        case CLOCK_REALTIME:
@@ -208,13 +211,15 @@ int cobalt_clock_gettime(clockid_t clock_id, struct 
timespec __user *u_ts)
        if (__xn_safe_copy_to_user(u_ts, &ts, sizeof(*u_ts)))
                return -EFAULT;
 
-       return ret;
+       trace_cobalt_clock_gettime(clock_id, &ts);
+
+       return 0;
 }
 
 int cobalt_clock_settime(clockid_t clock_id, const struct timespec __user 
*u_ts)
 {
        struct timespec ts;
-       int _ret, ret = 0;
+       int _ret, ret;
        xnticks_t now;
        spl_t s;
 
@@ -233,11 +238,13 @@ int cobalt_clock_settime(clockid_t clock_id, const struct 
timespec __user *u_ts)
                break;
        default:
                _ret = do_ext_clock(clock_id, set_time, ret, &ts);
-               if (_ret)
-                       ret = _ret;
+               if (_ret || ret)
+                       return _ret ?: ret;
        }
 
-       return ret;
+       trace_cobalt_clock_settime(clock_id, &ts);
+
+       return 0;
 }
 
 int cobalt_clock_nanosleep(clockid_t clock_id, int flags,
@@ -256,6 +263,8 @@ int cobalt_clock_nanosleep(clockid_t clock_id, int flags,
        if (__xn_safe_copy_from_user(&rqt, u_rqt, sizeof(rqt)))
                return -EFAULT;
 
+       trace_cobalt_clock_nanosleep(clock_id, flags, &rqt);
+
        if (clock_id != CLOCK_MONOTONIC &&
            clock_id != CLOCK_MONOTONIC_RAW &&
            clock_id != CLOCK_REALTIME)
@@ -325,12 +334,15 @@ int cobalt_clock_register(struct xnclock *clock, 
clockid_t *clk_id)
        clock->id = nr;
        *clk_id = __COBALT_CLOCK_CODE(clock->id);
 
+       trace_cobalt_clock_register(clock->name, *clk_id);
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(cobalt_clock_register);
 
 void cobalt_clock_deregister(struct xnclock *clock)
 {
+       trace_cobalt_clock_deregister(clock->name, clock->id);
        clear_bit(clock->id, cobalt_clock_extids);
        smp_mb__after_clear_bit();
        external_clocks[clock->id] = NULL;
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index ece465f..66dc7b0 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -572,6 +572,92 @@ TRACE_EVENT(cobalt_psem_unlink,
        TP_printk("name=%s", __get_str(name))
 );
 
+DECLARE_EVENT_CLASS(cobalt_clock_timespec,
+       TP_PROTO(clockid_t clk_id, const struct timespec *val),
+       TP_ARGS(clk_id, val),
+
+       TP_STRUCT__entry(
+               __field(clockid_t, clk_id)
+               __timespec_fields(val)
+       ),
+
+       TP_fast_assign(
+               __entry->clk_id = clk_id;
+               __assign_timespec(val, val);
+       ),
+
+       TP_printk("clock_id=%d timeval=(%ld.%09ld)",
+                 __entry->clk_id,
+                 __timespec_args(val)
+       )
+);
+
+DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_getres,
+       TP_PROTO(clockid_t clk_id, const struct timespec *res),
+       TP_ARGS(clk_id, res)
+);
+
+DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_gettime,
+       TP_PROTO(clockid_t clk_id, const struct timespec *time),
+       TP_ARGS(clk_id, time)
+);
+
+DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_settime,
+       TP_PROTO(clockid_t clk_id, const struct timespec *time),
+       TP_ARGS(clk_id, time)
+);
+
+#define cobalt_print_timer_flags(__flags)                      \
+       __print_flags(__flags, "|",                             \
+                     {TIMER_ABSTIME, "TIMER_ABSTIME"})
+
+TRACE_EVENT(cobalt_clock_nanosleep,
+       TP_PROTO(clockid_t clk_id, int flags, const struct timespec *time),
+       TP_ARGS(clk_id, flags, time),
+
+       TP_STRUCT__entry(
+               __field(clockid_t, clk_id)
+               __field(int, flags)
+               __timespec_fields(time)
+       ),
+
+       TP_fast_assign(
+               __entry->clk_id = clk_id;
+               __entry->flags = flags;
+               __assign_timespec(time, time);
+       ),
+
+       TP_printk("clock_id=%d flags=%#x(%s) rqt=(%ld.%09ld)",
+                 __entry->clk_id,
+                 __entry->flags, cobalt_print_timer_flags(__entry->flags),
+                 __timespec_args(time)
+       )
+);
+
+DECLARE_EVENT_CLASS(cobalt_clock_ident,
+       TP_PROTO(const char *name, clockid_t clk_id),
+       TP_ARGS(name, clk_id),
+       TP_STRUCT__entry(
+               __string(name, name)
+               __field(clockid_t, clk_id)
+       ),
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->clk_id = clk_id;
+       ),
+       TP_printk("name=%s, id=%#x", __get_str(name), __entry->clk_id)
+);
+
+DEFINE_EVENT(cobalt_clock_ident, cobalt_clock_register,
+       TP_PROTO(const char *name, clockid_t clk_id),
+       TP_ARGS(name, clk_id)
+);
+
+DEFINE_EVENT(cobalt_clock_ident, cobalt_clock_deregister,
+       TP_PROTO(const char *name, clockid_t clk_id),
+       TP_ARGS(name, clk_id)
+);
+
 #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