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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Apr 26 15:09:17 2014 +0200

cobalt/posix: introduce kernel tracepoints (WIP)

---

 kernel/cobalt/posix/nsem.c         |   16 +-
 kernel/cobalt/posix/sem.c          |   38 ++-
 kernel/cobalt/posix/thread.c       |   95 ++++--
 kernel/cobalt/trace/cobalt-posix.h |  578 ++++++++++++++++++++++++++++++++++++
 4 files changed, 696 insertions(+), 31 deletions(-)

diff --git a/kernel/cobalt/posix/nsem.c b/kernel/cobalt/posix/nsem.c
index e719560..f771ca5 100644
--- a/kernel/cobalt/posix/nsem.c
+++ b/kernel/cobalt/posix/nsem.c
@@ -24,13 +24,15 @@
 #include <cobalt/kernel/tree.h>
 #include "internal.h"
 #include "sem.h"
+#include "thread.h"
+#include <trace/events/cobalt-posix.h>
 
 DEFINE_XNLOCK(nsem_lock);
 
 struct nsem {
        struct cobalt_sem *sem;
        struct cobalt_sem_shadow __user *usem;
-       unsigned refs;
+       unsigned int refs;
        struct xnid id;
 };
 
@@ -47,7 +49,7 @@ static struct nsem *nsem_search(struct cobalt_process *cc, 
xnhandle_t handle)
 
 static struct cobalt_sem_shadow __user *
 nsem_open(struct cobalt_process *cc, struct cobalt_sem_shadow __user *ushadow, 
-       const char *name, int oflags, mode_t mode, unsigned value)
+       const char *name, int oflags, mode_t mode, unsigned int value)
 {
        struct cobalt_sem_shadow shadow;
        struct cobalt_sem *sem;
@@ -142,6 +144,8 @@ nsem_open(struct cobalt_process *cc, struct 
cobalt_sem_shadow __user *ushadow,
                xnlock_put_irqrestore(&nsem_lock, s);
        }
 
+       trace_cobalt_psem_open(name, handle, oflags, mode, value);
+
        return u->usem;
 }
 
@@ -206,8 +210,11 @@ int cobalt_sem_open(struct cobalt_sem_shadow __user 
*__user *u_addr,
                return -EINVAL;
 
        usm = nsem_open(cc, usm, name, oflags, mode, value);
-       if (IS_ERR(usm))
+       if (IS_ERR(usm)) {
+               trace_cobalt_psem_open_failed(name, oflags, mode,
+                                             value, PTR_ERR(usm));
                return PTR_ERR(usm);
+       }
 
        __xn_put_user(usm, u_addr);
 
@@ -224,6 +231,7 @@ int cobalt_sem_close(struct cobalt_sem_shadow __user *usm)
                return -EPERM;
 
        handle = cobalt_get_handle_from_user(&usm->handle);
+       trace_cobalt_psem_close(handle);
 
        return nsem_close(cc, handle);
 }
@@ -241,6 +249,8 @@ int cobalt_sem_unlink(const char __user *u_name)
        if (len >= sizeof(name))
                return -ENAMETOOLONG;
 
+       trace_cobalt_psem_unlink(name);
+
        if (name[0] != '/')
                return -EINVAL;
 
diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index 5865b5c..8d6b4ed 100644
--- a/kernel/cobalt/posix/sem.c
+++ b/kernel/cobalt/posix/sem.c
@@ -37,6 +37,7 @@
 #include "thread.h"
 #include "clock.h"
 #include "sem.h"
+#include <trace/events/cobalt-posix.h>
 
 #define SEM_NAMED    0x80000000
 
@@ -94,12 +95,16 @@ cobalt_sem_init_inner(const char *name, struct 
cobalt_sem_shadow *sm,
        int ret, sflags;
        spl_t s;
 
-       if ((flags & SEM_PULSE) != 0 && value > 0)
-               return ERR_PTR(-EINVAL);
+       if ((flags & SEM_PULSE) != 0 && value > 0) {
+               ret = -EINVAL;
+               goto out;
+       }
 
        sem = xnmalloc(sizeof(*sem));
-       if (sem == NULL)
-               return ERR_PTR(-ENOSPC);
+       if (sem == NULL) {
+               ret = -ENOSPC;
+               goto out;
+       }
 
        ksformat(sem->name, sizeof(sem->name), "%s", name);
 
@@ -168,13 +173,17 @@ cobalt_sem_init_inner(const char *name, struct 
cobalt_sem_shadow *sm,
                sm->datp_offset = -sm->datp_offset;
        xnlock_put_irqrestore(&nklock, s);
 
+       trace_cobalt_psem_init(sem->name, sem->handle, flags, value);
+
        return sem;
 
-  err_lock_put:
+err_lock_put:
        xnlock_put_irqrestore(&nklock, s);
        xnheap_free(&sys_ppd->sem_heap, datp);
-  err_free_sem:
+err_free_sem:
        xnfree(sem);
+out:
+       trace_cobalt_psem_init_failed(name, flags, value, ret);
 
        return ERR_PTR(ret);
 }
@@ -689,6 +698,7 @@ int cobalt_sem_post(struct cobalt_sem_shadow __user *u_sem)
        xnhandle_t handle;
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
+       trace_cobalt_psem_post(handle);
 
        return sem_post(handle);
 }
@@ -698,6 +708,7 @@ int cobalt_sem_wait(struct cobalt_sem_shadow __user *u_sem)
        xnhandle_t handle;
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
+       trace_cobalt_psem_wait(handle);
 
        return sem_wait(handle);
 }
@@ -708,6 +719,7 @@ int cobalt_sem_timedwait(struct cobalt_sem_shadow __user 
*u_sem,
        xnhandle_t handle;
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
+       trace_cobalt_psem_timedwait(handle);
 
        return sem_timedwait(handle, u_ts);
 }
@@ -717,6 +729,7 @@ int cobalt_sem_trywait(struct cobalt_sem_shadow __user 
*u_sem)
        xnhandle_t handle;
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
+       trace_cobalt_psem_trywait(handle);
 
        return sem_trywait(handle);
 }
@@ -724,13 +737,14 @@ int cobalt_sem_trywait(struct cobalt_sem_shadow __user 
*u_sem)
 int cobalt_sem_getvalue(struct cobalt_sem_shadow __user *u_sem, int __user 
*u_sval)
 {
        xnhandle_t handle;
-       int err, sval;
+       int ret, sval;
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
 
-       err = sem_getvalue(handle, &sval);
-       if (err < 0)
-               return err;
+       ret = sem_getvalue(handle, &sval);
+       trace_cobalt_psem_getvalue(handle, ret ? -1 : sval);
+       if (ret)
+               return ret;
 
        return __xn_safe_copy_to_user(u_sval, &sval, sizeof(sval));
 }
@@ -743,6 +757,8 @@ int cobalt_sem_destroy(struct cobalt_sem_shadow __user 
*u_sem)
        if (__xn_safe_copy_from_user(&sm, u_sem, sizeof(sm)))
                return -EFAULT;
 
+       trace_cobalt_psem_destroy(sm.handle);
+
        err = sem_destroy(&sm);
        if (err < 0)
                return err;
@@ -778,6 +794,7 @@ int cobalt_sem_broadcast_np(struct cobalt_sem_shadow __user 
*u_sem)
        int err;
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
+       trace_cobalt_psem_broadcast(u_sem->handle);
 
        xnlock_get_irqsave(&nklock, s);
        sm = xnregistry_lookup(handle, NULL);
@@ -802,6 +819,7 @@ int cobalt_sem_inquire(struct cobalt_sem_shadow __user 
*u_sem,
        spl_t s;
 
        handle = cobalt_get_handle_from_user(&u_sem->handle);
+       trace_cobalt_psem_inquire(handle);
 
        nrpids = waitsz / sizeof(pid_t);
 
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 83f58d0..6365c92 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -40,6 +40,9 @@
 #include "signal.h"
 #include "timer.h"
 #include "clock.h"
+#include "sem.h"
+#define CREATE_TRACE_POINTS
+#include <trace/events/cobalt-posix.h>
 
 xnticks_t cobalt_time_slice;
 
@@ -812,18 +815,19 @@ int cobalt_thread_setschedparam_ex(unsigned long pth,
                                   unsigned long __user *u_window_offset,
                                   int __user *u_promoted)
 {
+       struct sched_param_ex param_ex;
        struct cobalt_local_hkey hkey;
        struct cobalt_thread *thread;
-       struct sched_param_ex param;
        int ret, promoted = 0;
 
-       if (__xn_safe_copy_from_user(&param, u_param, sizeof(param)))
+       if (__xn_safe_copy_from_user(&param_ex, u_param, sizeof(param_ex)))
                return -EFAULT;
 
        hkey.u_pth = pth;
        hkey.mm = current->mm;
-       thread = thread_lookup(&hkey);
+       trace_cobalt_pthread_setschedparam(pth, policy, &param_ex);
 
+       thread = thread_lookup(&hkey);
        if (thread == NULL && u_window_offset) {
                thread = cobalt_thread_shadow(current, &hkey, u_window_offset);
                if (IS_ERR(thread))
@@ -833,7 +837,7 @@ int cobalt_thread_setschedparam_ex(unsigned long pth,
        }
 
        if (thread)
-               ret = pthread_setschedparam_ex(thread, policy, &param);
+               ret = pthread_setschedparam_ex(thread, policy, &param_ex);
        else
                ret = -EPERM;
 
@@ -853,9 +857,9 @@ int cobalt_thread_getschedparam_ex(unsigned long pth,
                                   int __user *u_policy,
                                   struct sched_param_ex __user *u_param)
 {
+       struct sched_param_ex param_ex;
        struct cobalt_local_hkey hkey;
        struct cobalt_thread *thread;
-       struct sched_param_ex param;
        int policy, ret;
 
        hkey.u_pth = pth;
@@ -864,14 +868,16 @@ int cobalt_thread_getschedparam_ex(unsigned long pth,
        if (thread == NULL)
                return -ESRCH;
 
-       ret = pthread_getschedparam_ex(thread, &policy, &param);
+       ret = pthread_getschedparam_ex(thread, &policy, &param_ex);
        if (ret)
                return ret;
 
+       trace_cobalt_pthread_getschedparam(pth, policy, &param_ex);
+
        if (__xn_safe_copy_to_user(u_policy, &policy, sizeof(int)))
                return -EFAULT;
 
-       return __xn_safe_copy_to_user(u_param, &param, sizeof(param));
+       return __xn_safe_copy_to_user(u_param, &param_ex, sizeof(param_ex));
 }
 
 /*
@@ -906,6 +912,9 @@ int cobalt_thread_create(unsigned long pth, int policy,
 
        if (__xn_safe_copy_from_user(&param_ex, u_param, sizeof(param_ex)))
                return -EFAULT;
+
+       trace_cobalt_pthread_create(pth, policy, &param_ex);
+
        /*
         * We have been passed the pthread_t identifier the user-space
         * Cobalt library has assigned to our caller; we'll index our
@@ -952,6 +961,7 @@ cobalt_thread_shadow(struct task_struct *p,
        int ret;
 
        param_ex.sched_priority = 0;
+       trace_cobalt_pthread_create(hkey->u_pth, SCHED_NORMAL, &param_ex);
        ret = pthread_create(&thread, SCHED_NORMAL, &param_ex, p);
        if (ret)
                return ERR_PTR(-ret);
@@ -995,18 +1005,24 @@ int cobalt_thread_make_periodic_np(unsigned long pth,
        if (__xn_safe_copy_from_user(&periodt, u_periodt, sizeof(periodt)))
                return -EFAULT;
 
+       trace_cobalt_pthread_make_periodic(pth, clk_id, &startt, &periodt);
+
        return pthread_make_periodic_np(thread, clk_id, &startt, &periodt);
 }
 
 int cobalt_thread_wait_np(unsigned long __user *u_overruns)
 {
-       unsigned long overruns;
+       unsigned long overruns = 0;
        int ret;
 
+       trace_cobalt_pthread_wait_entry(0);
+
        ret = xnthread_wait_period(&overruns);
        if (u_overruns && (ret == 0 || ret == -ETIMEDOUT))
                __xn_put_user(overruns, u_overruns);
 
+       trace_cobalt_pthread_wait_exit(ret, overruns);
+
        return ret;
 }
 
@@ -1014,6 +1030,8 @@ int cobalt_thread_set_mode_np(int clrmask, int setmask, 
int __user *u_mode_r)
 {
        int ret, old;
 
+       trace_cobalt_pthread_set_mode(clrmask, setmask);
+
        ret = pthread_set_mode_np(clrmask, setmask, &old);
        if (ret)
                return ret;
@@ -1040,6 +1058,8 @@ int cobalt_thread_set_name_np(unsigned long pth, const 
char __user *u_name)
        hkey.u_pth = pth;
        hkey.mm = current->mm;
 
+       trace_cobalt_pthread_set_name(pth, name);
+
        xnlock_get_irqsave(&nklock, s);
 
        thread = thread_lookup(&hkey);
@@ -1070,6 +1090,8 @@ int cobalt_thread_probe_np(pid_t pid)
 
        hash = jhash2((u32 *)&pid, sizeof(pid) / sizeof(u32), 0);
 
+       trace_cobalt_pthread_probe(pid);
+
        xnlock_get_irqsave(&nklock, s);
 
        gslot = global_index[hash & (PTHREAD_HSLOTS - 1)];
@@ -1090,6 +1112,8 @@ int cobalt_thread_kill(unsigned long pth, int sig)
        int ret;
        spl_t s;
 
+       trace_cobalt_pthread_kill(pth, sig);
+
        xnlock_get_irqsave(&nklock, s);
 
        hkey.u_pth = pth;
@@ -1111,10 +1135,14 @@ int cobalt_thread_join(unsigned long pth)
        struct cobalt_thread *thread;
        spl_t s;
 
+       trace_cobalt_pthread_join(pth);
+
        xnlock_get_irqsave(&nklock, s);
+
        hkey.u_pth = pth;
        hkey.mm = current->mm;
        thread = thread_lookup(&hkey);
+
        xnlock_put_irqrestore(&nklock, s);
 
        if (thread == NULL)
@@ -1132,6 +1160,8 @@ int cobalt_thread_stat(pid_t pid,
        xnticks_t xtime;
        spl_t s;
 
+       trace_cobalt_pthread_stat(pid);
+
        if (pid == 0) {
                thread = xnshadow_current();
                if (thread == NULL)
@@ -1177,6 +1207,8 @@ int cobalt_thread_extend(struct cobalt_extension *ext,
        struct cobalt_thread *thread = cobalt_current_thread();
        struct xnpersonality *prev;
 
+       trace_cobalt_pthread_extend(thread->hkey.u_pth, ext->core.name);
+
        prev = xnshadow_push_personality(ext->core.muxid);
        if (prev == NULL)
                return -EINVAL;
@@ -1192,6 +1224,8 @@ void cobalt_thread_restrict(void)
 {
        struct cobalt_thread *thread = cobalt_current_thread();
 
+       trace_cobalt_pthread_restrict(thread->hkey.u_pth,
+                     xnthread_personality(&thread->threadbase)->name);
        xnshadow_pop_personality(&cobalt_personality);
        cobalt_set_extref(&thread->extref, NULL, NULL);
 }
@@ -1201,45 +1235,64 @@ EXPORT_SYMBOL_GPL(cobalt_thread_restrict);
 
 int cobalt_sched_min_prio(int policy)
 {
+       int ret;
+
        switch (policy) {
        case SCHED_FIFO:
        case SCHED_RR:
        case SCHED_SPORADIC:
        case SCHED_TP:
        case SCHED_QUOTA:
-               return XNSCHED_FIFO_MIN_PRIO;
+               ret = XNSCHED_FIFO_MIN_PRIO;
+               break;
        case SCHED_COBALT:
-               return XNSCHED_RT_MIN_PRIO;
+               ret = XNSCHED_RT_MIN_PRIO;
+               break;
        case SCHED_NORMAL:
        case SCHED_WEAK:
-               return 0;
+               ret = 0;
+               break;
        default:
-               return -EINVAL;
+               ret = -EINVAL;
        }
+
+       trace_cobalt_sched_min_prio(policy, ret);
+
+       return ret;
 }
 
 int cobalt_sched_max_prio(int policy)
 {
+       int ret;
+
        switch (policy) {
        case SCHED_FIFO:
        case SCHED_RR:
        case SCHED_SPORADIC:
        case SCHED_TP:
        case SCHED_QUOTA:
-               return XNSCHED_FIFO_MAX_PRIO;
+               ret = XNSCHED_FIFO_MAX_PRIO;
+               break;
        case SCHED_COBALT:
-               return XNSCHED_RT_MAX_PRIO;
+               ret = XNSCHED_RT_MAX_PRIO;
+               break;
        case SCHED_NORMAL:
-               return 0;
+               ret = 0;
+               break;
        case SCHED_WEAK:
 #ifdef CONFIG_XENO_OPT_SCHED_WEAK
-               return XNSCHED_FIFO_MAX_PRIO;
+               ret = XNSCHED_FIFO_MAX_PRIO;
 #else
-               return 0;
+               ret 0;
 #endif
+               break;
        default:
-               return -EINVAL;
+               ret = -EINVAL;
        }
+
+       trace_cobalt_sched_max_prio(policy, ret);
+
+       return ret;
 }
 
 int cobalt_sched_yield(void)
@@ -1247,6 +1300,8 @@ int cobalt_sched_yield(void)
        struct cobalt_thread *curr = cobalt_current_thread();
        int ret = 0;
 
+       trace_cobalt_pthread_yield(0);
+
        /* Maybe some extension wants to handle this. */
        if (cobalt_call_extension(sched_yield, &curr->extref, ret) && ret)
                return ret > 0 ? 0 : ret;
@@ -1623,6 +1678,8 @@ int cobalt_sched_setconfig_np(int cpu, int policy,
        union sched_config *buf;
        int ret;
 
+       trace_cobalt_sched_set_config(cpu, policy, len);
+
        if (cpu < 0 || cpu >= NR_CPUS || !cpu_online(cpu))
                return -EINVAL;
 
@@ -1701,6 +1758,8 @@ ssize_t cobalt_sched_getconfig_np(int cpu, int policy,
                ret = -EINVAL;
        }
 
+       trace_cobalt_sched_get_config(cpu, policy, ret);
+
        return ret;
 }
 
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
new file mode 100644
index 0000000..ece465f
--- /dev/null
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -0,0 +1,578 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM cobalt-posix
+
+#if !defined(_TRACE_COBALT_POSIX_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_COBALT_POSIX_H
+
+#include <linux/tracepoint.h>
+
+#define __timespec_fields(__name)                              \
+       __field(__kernel_time_t, tv_sec_##__name)               \
+       __field(long, tv_nsec_##__name)
+
+#define __assign_timespec(__to, __from)                                \
+       do {                                                    \
+               __entry->tv_sec_##__to = (__from)->tv_sec;      \
+               __entry->tv_nsec_##__to = (__from)->tv_nsec;    \
+       } while (0)
+
+#define __timespec_args(__name)                                        \
+       __entry->tv_sec_##__name, __entry->tv_nsec_##__name
+
+#define cobalt_print_sched_policy(__policy)                    \
+       __print_symbolic(__policy,                              \
+                        {SCHED_NORMAL, "normal"},              \
+                        {SCHED_FIFO, "fifo"},                  \
+                        {SCHED_RR, "rr"},                      \
+                        {SCHED_TP, "tp"},                      \
+                        {SCHED_QUOTA, "quota"},                \
+                        {SCHED_SPORADIC, "sporadic"},          \
+                        {SCHED_COBALT, "cobalt"},              \
+                        {SCHED_WEAK, "weak"})
+
+#define cobalt_print_sched_params(__policy, __p_ex)                    \
+({                                                                     \
+       const char *__ret = p->buffer + p->len;                         \
+       switch (__policy) {                                             \
+       case SCHED_QUOTA:                                               \
+               trace_seq_printf(p, "priority=%d, group=%d",            \
+                                (__p_ex)->sched_priority,              \
+                                (__p_ex)->sched_quota_group);          \
+               break;                                                  \
+       case SCHED_TP:                                                  \
+               trace_seq_printf(p, "priority=%d, partition=%d",        \
+                                (__p_ex)->sched_priority,              \
+                                (__p_ex)->sched_tp_partition);         \
+               break;                                                  \
+       case SCHED_NORMAL:                                              \
+               break;                                                  \
+       case SCHED_SPORADIC:                                            \
+               trace_seq_printf(p, "priority=%d, low_priority=%d, "    \
+                                "budget=(%ld.%09ld), period=(%ld.%09ld), "\
+                                "maxrepl=%d",                          \
+                                (__p_ex)->sched_priority,              \
+                                (__p_ex)->sched_ss_low_priority,       \
+                                (__p_ex)->sched_ss_init_budget.tv_sec, \
+                                (__p_ex)->sched_ss_init_budget.tv_nsec, \
+                                (__p_ex)->sched_ss_repl_period.tv_sec, \
+                                (__p_ex)->sched_ss_repl_period.tv_nsec, \
+                                (__p_ex)->sched_ss_max_repl);          \
+               break;                                                  \
+       case SCHED_RR:                                                  \
+       case SCHED_FIFO:                                                \
+       case SCHED_COBALT:                                              \
+       case SCHED_WEAK:                                                \
+       default:                                                        \
+               trace_seq_printf(p, "priority=%d",                      \
+                                (__p_ex)->sched_priority);             \
+               break;                                                  \
+       }                                                               \
+       __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),
+       TP_ARGS(pth, policy, param_ex),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __field(int, policy)
+               __dynamic_array(char, param_ex, sizeof(struct sched_param_ex))
+       ),
+
+       TP_fast_assign(
+               __entry->pth = pth;
+               __entry->policy = policy;
+               memcpy(__get_dynamic_array(param_ex), param_ex, 
sizeof(*param_ex));
+       ),
+
+       TP_printk("pth=%p policy=%d(%s) param={ %s }",
+                 (void *)__entry->pth, __entry->policy,
+                 cobalt_print_sched_policy(__entry->policy),
+                 cobalt_print_sched_params(__entry->policy,
+                                           (struct sched_param_ex *)
+                                           __get_dynamic_array(param_ex))
+       )
+);
+
+DECLARE_EVENT_CLASS(cobalt_void,
+       TP_PROTO(int dummy),
+       TP_ARGS(dummy),
+       TP_STRUCT__entry(
+               __array(char, dummy, 0)
+       ),
+       TP_fast_assign(
+               (void)dummy;
+       ),
+       TP_printk("%s", "")
+);
+
+DEFINE_EVENT(cobalt_posix_schedparam, cobalt_pthread_create,
+       TP_PROTO(unsigned long pth, int policy,
+                struct sched_param_ex *param_ex),
+       TP_ARGS(pth, policy, param_ex)
+);
+
+DEFINE_EVENT(cobalt_posix_schedparam, cobalt_pthread_setschedparam,
+       TP_PROTO(unsigned long pth, int policy,
+                struct sched_param_ex *param_ex),
+       TP_ARGS(pth, policy, param_ex)
+);
+
+DEFINE_EVENT(cobalt_posix_schedparam, cobalt_pthread_getschedparam,
+       TP_PROTO(unsigned long pth, int policy,
+                struct sched_param_ex *param_ex),
+       TP_ARGS(pth, policy, param_ex)
+);
+
+TRACE_EVENT(cobalt_pthread_make_periodic,
+       TP_PROTO(unsigned long pth, clockid_t clk_id,
+                struct timespec *start, struct timespec *period),
+       TP_ARGS(pth, clk_id, start, period),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __field(clockid_t, clk_id)
+               __timespec_fields(start)
+               __timespec_fields(period)
+       ),
+
+       TP_fast_assign(
+               __entry->pth = pth;
+               __entry->clk_id = clk_id;
+               __assign_timespec(start, start);
+               __assign_timespec(period, period);
+       ),
+
+       TP_printk("pth=%p clock_id=%d start=(%ld.%09ld) period=(%ld.%09ld)",
+                 (void *)__entry->pth, __entry->clk_id,
+                 __timespec_args(start),
+                 __timespec_args(period)
+       )
+);
+
+DEFINE_EVENT(cobalt_void, cobalt_pthread_wait_entry,
+       TP_PROTO(int dummy),
+       TP_ARGS(dummy)
+);
+
+TRACE_EVENT(cobalt_pthread_wait_exit,
+       TP_PROTO(int status, unsigned long overruns),
+       TP_ARGS(status, overruns),
+       TP_STRUCT__entry(
+               __field(int, status)
+               __field(unsigned long, overruns)
+       ),
+       TP_fast_assign(
+               __entry->status = status;
+               __entry->overruns = overruns;
+       ),
+       TP_printk("status=%d overruns=%lu",
+                 __entry->status, __entry->overruns)
+);
+
+#define cobalt_print_thread_mode(__mode)                       \
+       __print_flags(__mode, "|",                              \
+                     {PTHREAD_WARNSW, "warnsw"},               \
+                     {PTHREAD_LOCK_SCHED, "lock"},             \
+                     {PTHREAD_DISABLE_LOCKBREAK, "nolockbreak"})
+
+TRACE_EVENT(cobalt_pthread_set_mode,
+       TP_PROTO(int clrmask, int setmask),
+       TP_ARGS(clrmask, setmask),
+       TP_STRUCT__entry(
+               __field(int, clrmask)
+               __field(int, setmask)
+       ),
+       TP_fast_assign(
+               __entry->clrmask = clrmask;
+               __entry->setmask = setmask;
+       ),
+       TP_printk("clrmask=%#x(%s) setmask=%#x(%s)",
+                 __entry->clrmask, cobalt_print_thread_mode(__entry->clrmask),
+                 __entry->setmask, cobalt_print_thread_mode(__entry->setmask))
+);
+
+TRACE_EVENT(cobalt_pthread_set_name,
+       TP_PROTO(unsigned long pth, const char *name),
+       TP_ARGS(pth, name),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __string(name, name)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+               __assign_str(name, name);
+       ),
+       TP_printk("pth=%p name=%s", (void *)__entry->pth, __get_str(name))
+);
+
+DECLARE_EVENT_CLASS(cobalt_posix_pid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(
+               __field(pid_t, pid)
+       ),
+       TP_fast_assign(
+               __entry->pid = pid;
+       ),
+       TP_printk("pid=%d", __entry->pid)
+);
+
+DEFINE_EVENT(cobalt_posix_pid, cobalt_pthread_probe,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid)
+);
+
+DEFINE_EVENT(cobalt_posix_pid, cobalt_pthread_stat,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid)
+);
+
+TRACE_EVENT(cobalt_pthread_kill,
+       TP_PROTO(unsigned long pth, int sig),
+       TP_ARGS(pth, sig),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __field(int, sig)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+               __entry->sig = sig;
+       ),
+       TP_printk("pth=%p sig=%d", (void *)__entry->pth, __entry->sig)
+);
+
+TRACE_EVENT(cobalt_pthread_join,
+       TP_PROTO(unsigned long pth),
+       TP_ARGS(pth),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+       ),
+       TP_printk("pth=%p", (void *)__entry->pth)
+);
+
+TRACE_EVENT(cobalt_pthread_extend,
+       TP_PROTO(unsigned long pth, const char *name),
+       TP_ARGS(pth, name),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __string(name, name)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+               __assign_str(name, name);
+       ),
+       TP_printk("pth=%p +personality=%s", (void *)__entry->pth, 
__get_str(name))
+);
+
+TRACE_EVENT(cobalt_pthread_restrict,
+       TP_PROTO(unsigned long pth, const char *name),
+       TP_ARGS(pth, name),
+       TP_STRUCT__entry(
+               __field(unsigned long, pth)
+               __string(name, name)
+       ),
+       TP_fast_assign(
+               __entry->pth = pth;
+               __assign_str(name, name);
+       ),
+       TP_printk("pth=%p -personality=%s", (void *)__entry->pth, 
__get_str(name))
+);
+
+DEFINE_EVENT(cobalt_void, cobalt_pthread_yield,
+       TP_PROTO(int dummy),
+       TP_ARGS(dummy)
+);
+
+TRACE_EVENT(cobalt_sched_set_config,
+       TP_PROTO(int cpu, int policy, size_t len),
+       TP_ARGS(cpu, policy, len),
+       TP_STRUCT__entry(
+               __field(int, cpu)
+               __field(int, policy)
+               __field(size_t, len)
+       ),
+       TP_fast_assign(
+               __entry->cpu = cpu;
+               __entry->policy = policy;
+               __entry->len = len;
+       ),
+       TP_printk("cpu=%d policy=%d(%s) len=%Zu",
+                 __entry->cpu, __entry->policy,
+                 cobalt_print_sched_policy(__entry->policy),
+                 __entry->len)
+);
+
+TRACE_EVENT(cobalt_sched_get_config,
+       TP_PROTO(int cpu, int policy, size_t rlen),
+       TP_ARGS(cpu, policy, rlen),
+       TP_STRUCT__entry(
+               __field(int, cpu)
+               __field(int, policy)
+               __field(ssize_t, rlen)
+       ),
+       TP_fast_assign(
+               __entry->cpu = cpu;
+               __entry->policy = policy;
+               __entry->rlen = rlen;
+       ),
+       TP_printk("cpu=%d policy=%d(%s) rlen=%Zd",
+                 __entry->cpu, __entry->policy,
+                 cobalt_print_sched_policy(__entry->policy),
+                 __entry->rlen)
+);
+
+DECLARE_EVENT_CLASS(cobalt_posix_prio_bound,
+       TP_PROTO(int policy, int prio),
+       TP_ARGS(policy, prio),
+       TP_STRUCT__entry(
+               __field(int, policy)
+               __field(int, prio)
+       ),
+       TP_fast_assign(
+               __entry->policy = policy;
+               __entry->prio = prio;
+       ),
+       TP_printk("policy=%d(%s) prio=%d",
+                 __entry->policy,
+                 cobalt_print_sched_policy(__entry->policy),
+                 __entry->prio)
+);
+
+DEFINE_EVENT(cobalt_posix_prio_bound, cobalt_sched_min_prio,
+       TP_PROTO(int policy, int prio),
+       TP_ARGS(policy, prio)
+);
+
+DEFINE_EVENT(cobalt_posix_prio_bound, cobalt_sched_max_prio,
+       TP_PROTO(int policy, int prio),
+       TP_ARGS(policy, prio)
+);
+
+DECLARE_EVENT_CLASS(cobalt_posix_sem,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle),
+       TP_STRUCT__entry(
+               __field(xnhandle_t, handle)
+       ),
+       TP_fast_assign(
+               __entry->handle = handle;
+       ),
+       TP_printk("sem=%#lx", __entry->handle)
+);
+
+DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_wait,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_trywait,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_timedwait,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_post,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_destroy,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_broadcast,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_inquire,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+TRACE_EVENT(cobalt_psem_getvalue,
+       TP_PROTO(xnhandle_t handle, int value),
+       TP_ARGS(handle, value),
+       TP_STRUCT__entry(
+               __field(xnhandle_t, handle)
+               __field(int, value)
+       ),
+       TP_fast_assign(
+               __entry->handle = handle;
+               __entry->value = value;
+       ),
+       TP_printk("sem=%#lx value=%d", __entry->handle, __entry->value)
+);
+
+#define cobalt_print_sem_flags(__flags)                                \
+       __print_flags(__flags, "|",                             \
+                        {SEM_FIFO, "fifo"},                    \
+                        {SEM_PULSE, "pulse"},                  \
+                        {SEM_PSHARED, "pshared"},              \
+                        {SEM_REPORT, "report"},                \
+                        {SEM_WARNDEL, "warndel"},              \
+                        {SEM_RAWCLOCK, "rawclock"},            \
+                        {SEM_NOBUSYDEL, "nobusydel"})
+
+TRACE_EVENT(cobalt_psem_init,
+       TP_PROTO(const char *name, xnhandle_t handle,
+                int flags, unsigned int value),
+       TP_ARGS(name, handle, flags, value),
+       TP_STRUCT__entry(
+               __string(name, name)
+               __field(xnhandle_t, handle)
+               __field(int, flags)
+               __field(unsigned int, value)
+       ),
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->handle = handle;
+               __entry->flags = flags;
+               __entry->value = value;
+       ),
+       TP_printk("sem=%#lx(%s) flags=%#x(%s) value=%u",
+                 __entry->handle,
+                 __get_str(name),
+                 __entry->flags,
+                 cobalt_print_sem_flags(__entry->flags),
+                 __entry->value)
+);
+
+TRACE_EVENT(cobalt_psem_init_failed,
+       TP_PROTO(const char *name, int flags, unsigned int value, int status),
+       TP_ARGS(name, flags, value, status),
+       TP_STRUCT__entry(
+               __string(name, name)
+               __field(int, flags)
+               __field(unsigned int, value)
+               __field(int, status)
+       ),
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->flags = flags;
+               __entry->value = value;
+               __entry->status = status;
+       ),
+       TP_printk("name=%s flags=%#x(%s) value=%u error=%d",
+                 __get_str(name),
+                 __entry->flags,
+                 cobalt_print_sem_flags(__entry->flags),
+                 __entry->value, __entry->status)
+);
+
+#define cobalt_print_oflags(__flags)           \
+       __print_flags(__flags,  "|",            \
+                     {O_RDONLY, "rdonly"},     \
+                     {O_WRONLY, "wronly"},     \
+                     {O_RDWR, "rdwr"},         \
+                     {O_CREAT, "creat"},       \
+                     {O_EXCL, "excl"},         \
+                     {O_DIRECT, "direct"},     \
+                     {O_NONBLOCK, "nonblock"}, \
+                     {O_TRUNC, "trunc"})
+
+TRACE_EVENT(cobalt_psem_open,
+       TP_PROTO(const char *name, xnhandle_t handle,
+                int oflags, mode_t mode, unsigned int value),
+       TP_ARGS(name, handle, oflags, mode, value),
+       TP_STRUCT__entry(
+               __string(name, name)
+               __field(xnhandle_t, handle)
+               __field(int, oflags)
+               __field(mode_t, mode)
+               __field(unsigned int, value)
+       ),
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->handle = handle;
+               __entry->oflags = oflags;
+               if (oflags & O_CREAT) {
+                       __entry->mode = mode;
+                       __entry->value = value;
+               } else {
+                       __entry->mode = 0;
+                       __entry->value = 0;
+               }
+       ),
+       TP_printk("named_sem=%#lx=(%s) oflags=%#x(%s) mode=%o value=%u",
+                 __entry->handle, __get_str(name),
+                 __entry->oflags, cobalt_print_oflags(__entry->oflags),
+                 __entry->mode, __entry->value)
+);
+
+TRACE_EVENT(cobalt_psem_open_failed,
+       TP_PROTO(const char *name, int oflags, mode_t mode,
+                unsigned int value, int status),
+        TP_ARGS(name, oflags, mode, value, status),
+       TP_STRUCT__entry(
+               __string(name, name)
+               __field(int, oflags)
+               __field(mode_t, mode)
+               __field(unsigned int, value)
+               __field(int, status)
+       ),
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->oflags = oflags;
+               __entry->status = status;
+               if (oflags & O_CREAT) {
+                       __entry->mode = mode;
+                       __entry->value = value;
+               } else {
+                       __entry->mode = 0;
+                       __entry->value = 0;
+               }
+       ),
+       TP_printk("named_sem=%s oflags=%#x(%s) mode=%o value=%u error=%d",
+                 __get_str(name),
+                 __entry->oflags, cobalt_print_oflags(__entry->oflags),
+                 __entry->mode, __entry->value, __entry->status)
+);
+
+DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_close,
+       TP_PROTO(xnhandle_t handle),
+       TP_ARGS(handle)
+);
+
+TRACE_EVENT(cobalt_psem_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))
+);
+
+#endif /* _TRACE_COBALT_POSIX_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>


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

Reply via email to