add custom probes support and update tracepoints
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Fri, 16 Apr 2010 14:27:47 +0000 (10:27 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Mon, 19 Apr 2010 23:30:33 +0000 (19:30 -0400)
15 files changed:
include/Makefile.am
include/ust/core.h [new file with mode: 0644]
include/ust/type-serializer.h [new file with mode: 0644]
include/ust/ust.h
libust-initializer.c
libust/Makefile.am
libust/buffers.c
libust/buffers.h
libust/header-inline.h
libust/marker.c
libust/serialize.c
libust/tracer.h
libust/tracercore.h
libust/type-serializer.c [new file with mode: 0644]
tests/hello/tp.h

index 7249bf2f137927bb9c1200d2fdd8153efb3452d5..5a8b075f528bfb7bde1a1a14f8130c9d604450cc 100644 (file)
@@ -7,6 +7,8 @@ nobase_include_HEADERS = \
        ust/probe.h \
        ust/ust.h \
        ust/tracectl.h \
+       ust/core.h \
+       ust/type-serializer.h \
        ust/kcompat/kcompat.h \
        ust/kcompat/compiler.h \
        ust/kcompat/disable.h \
diff --git a/include/ust/core.h b/include/ust/core.h
new file mode 100644 (file)
index 0000000..27c7e6d
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef UST_CORE_H
+#define UST_CORE_H
+
+#if defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT)
+
+/*
+ * Calculate the offset needed to align the type.
+ * size_of_type must be non-zero.
+ */
+static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type)
+{
+       size_t alignment = min(sizeof(void *), size_of_type);
+       return (alignment - align_drift) & (alignment - 1);
+}
+/* Default arch alignment */
+#define LTT_ALIGN
+
+static inline int ltt_get_alignment(void)
+{
+       return sizeof(void *);
+}
+
+#else
+
+static inline unsigned int ltt_align(size_t align_drift,
+                size_t size_of_type)
+{
+       return 0;
+}
+
+#define LTT_ALIGN __attribute__((packed))
+
+static inline int ltt_get_alignment(void)
+{
+       return 0;
+}
+#endif /* defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT) */
+
+#endif /* UST_CORE_H */
diff --git a/include/ust/type-serializer.h b/include/ust/type-serializer.h
new file mode 100644 (file)
index 0000000..8457a47
--- /dev/null
@@ -0,0 +1,181 @@
+#ifndef _LTT_TYPE_SERIALIZER_H
+#define _LTT_TYPE_SERIALIZER_H
+
+//ust// #include "tracer.h"
+#include <ust/marker.h>
+#include <ust/core.h>
+
+/*
+ * largest_align must be non-zero, equal to the minimum between the largest type
+ * and sizeof(void *).
+ */
+extern void _ltt_specialized_trace(const struct marker *mdata, void *probe_data,
+               void *serialize_private, unsigned int data_size,
+               unsigned int largest_align);
+
+/*
+ * Statically check that 0 < largest_align < sizeof(void *) to make sure it is
+ * dumb-proof. It will make sure 0 is changed into 1 and unsigned long long is
+ * changed into sizeof(void *) on 32-bit architectures.
+ */
+static inline void ltt_specialized_trace(const struct marker *mdata,
+               void *probe_data,
+               void *serialize_private, unsigned int data_size,
+               unsigned int largest_align)
+{
+       largest_align = min_t(unsigned int, largest_align, sizeof(void *));
+       largest_align = max_t(unsigned int, largest_align, 1);
+       _ltt_specialized_trace(mdata, probe_data, serialize_private, data_size,
+               largest_align);
+}
+
+/*
+ * Type serializer definitions.
+ */
+
+/*
+ * Return size of structure without end-of-structure padding.
+ */
+#define serialize_sizeof(type) offsetof(typeof(type), end_field)
+
+struct serialize_long_int {
+       unsigned long f1;
+       unsigned int f2;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_int_int_long {
+       unsigned int f1;
+       unsigned int f2;
+       unsigned long f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_int_int_short {
+       unsigned int f1;
+       unsigned int f2;
+       unsigned short f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_long {
+       unsigned long f1;
+       unsigned long f2;
+       unsigned long f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_int {
+       unsigned long f1;
+       unsigned long f2;
+       unsigned int f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_short_char {
+       unsigned long f1;
+       unsigned long f2;
+       unsigned short f3;
+       unsigned char f4;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_short {
+       unsigned long f1;
+       unsigned long f2;
+       unsigned short f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_short_char {
+       unsigned long f1;
+       unsigned short f2;
+       unsigned char f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_short {
+       unsigned long f1;
+       unsigned short f2;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_char {
+       unsigned long f1;
+       unsigned char f2;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_sizet_int {
+       size_t f1;
+       unsigned int f2;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_sizet_int {
+       unsigned long f1;
+       unsigned long f2;
+       size_t f3;
+       unsigned int f4;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_sizet_int_int {
+       unsigned long f1;
+       unsigned long f2;
+       size_t f3;
+       unsigned int f4;
+       unsigned int f5;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_l4421224411111 {
+       unsigned long f1;
+       uint32_t f2;
+       uint32_t f3;
+       uint16_t f4;
+       uint8_t f5;
+       uint16_t f6;
+       uint16_t f7;
+       uint32_t f8;
+       uint32_t f9;
+       uint8_t f10;
+       uint8_t f11;
+       uint8_t f12;
+       uint8_t f13;
+       uint8_t f14;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_l214421224411111 {
+       unsigned long f1;
+       uint16_t f2;
+       uint8_t f3;
+       uint32_t f4;
+       uint32_t f5;
+       uint16_t f6;
+       uint8_t f7;
+       uint16_t f8;
+       uint16_t f9;
+       uint32_t f10;
+       uint32_t f11;
+       uint8_t f12;
+       uint8_t f13;
+       uint8_t f14;
+       uint8_t f15;
+       uint8_t f16;
+       uint8_t end_field[0];
+} LTT_ALIGN;
+
+struct serialize_l4412228 {
+       unsigned long f1;
+       uint32_t f2;
+       uint32_t f3;
+       uint8_t f4;
+       uint16_t f5;
+       uint16_t f6;
+       uint16_t f7;
+       uint64_t f8;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+#endif /* _LTT_TYPE_SERIALIZER_H */
index aa66b061ead25f974eba42f30832d7463c506b07..47e5b6efa9826e48e7cc2f190f55c0ac34d35048 100644 (file)
@@ -24,5 +24,7 @@
 #include <ust/processor.h>
 #include <ust/tracepoint.h>
 #include <ust/probe.h>
+#include <ust/type-serializer.h>
+#include <ust/core.h>
 
 #endif /* UST_H */
index 1bf709e3f5e7b16cc04519859f85c7bdf6c9548c..ec39932e9879706e4681df47f20408f7b2095c94 100644 (file)
@@ -18,7 +18,7 @@
  * avoid this.
  */
 
-DECLARE_TRACE(ust_dummytp, TPPROTO(void), TPARGS());
+DECLARE_TRACE(ust_dummytp, TP_PROTO(void), TP_ARGS());
 DEFINE_TRACE(ust_dummytp);
 
 void dummy_libust_initializer_func(void)
index 529d4b0cdd704e2f6abd483c70abef3c5d5e5a53..2de58574f0acb7fc7f6d14c423990748f6ce5b60 100644 (file)
@@ -20,7 +20,8 @@ libust_la_SOURCES = \
        tracectl.c \
        $(top_builddir)/libustcomm/multipoll.c \
        tracerconst.h \
-       header-inline.h
+       header-inline.h \
+       type-serializer.c
 
 libust_la_LDFLAGS = -no-undefined -version-info 0:0:0
 
index b7002dedf32c0c63353bd637f221a6f045de898a..ef62a305e9ca6e8feb0aff1a500e31bfabc1646d 100644 (file)
@@ -1213,12 +1213,14 @@ static int ltt_relay_try_reserve_slow(struct ust_channel *chan, struct ust_buffe
  * Return : -ENOSPC if not enough space, else returns 0.
  * It will take care of sub-buffer switching.
  */
-int ltt_reserve_slot_lockless_slow(struct ust_trace *trace,
-               struct ust_channel *chan, void **transport_data,
-               size_t data_size, size_t *slot_size, long *buf_offset, u64 *tsc,
-               unsigned int *rflags, int largest_align, int cpu)
+int ltt_reserve_slot_lockless_slow(struct ust_channel *chan,
+               struct ust_trace *trace, size_t data_size,
+               int largest_align, int cpu,
+               struct ust_buffer **ret_buf,
+               size_t *slot_size, long *buf_offset,
+               u64 *tsc, unsigned int *rflags)
 {
-       struct ust_buffer *buf = chan->buf[cpu];
+       struct ust_buffer *buf = *ret_buf = chan->buf[cpu];
        struct ltt_reserve_switch_offsets offsets;
 
        offsets.size = 0;
@@ -1296,8 +1298,7 @@ static void __attribute__((destructor)) ust_buffers_exit(void)
        ltt_transport_unregister(&ust_relay_transport);
 }
 
-size_t ltt_write_event_header_slow(struct ust_trace *trace,
-               struct ust_channel *channel,
+size_t ltt_write_event_header_slow(struct ust_channel *channel,
                struct ust_buffer *buf, long buf_offset,
                u16 eID, u32 event_size,
                u64 tsc, unsigned int rflags)
index d3267e102ca5e56a8b6da731ce778790d002f3f7..ca78796fbc9aa7e2aa28f2c4a0fcb9db73cbc7c7 100644 (file)
@@ -104,10 +104,12 @@ struct ust_buffer {
  */
 enum force_switch_mode { FORCE_ACTIVE, FORCE_FLUSH };
 
-extern int ltt_reserve_slot_lockless_slow(struct ust_trace *trace,
-               struct ust_channel *ltt_channel, void **transport_data,
-               size_t data_size, size_t *slot_size, long *buf_offset, u64 *tsc,
-               unsigned int *rflags, int largest_align, int cpu);
+extern int ltt_reserve_slot_lockless_slow(struct ust_channel *chan,
+               struct ust_trace *trace, size_t data_size,
+               int largest_align, int cpu,
+               struct ust_buffer **ret_buf,
+               size_t *slot_size, long *buf_offset,
+               u64 *tsc, unsigned int *rflags);
 
 extern void ltt_force_switch_lockless_slow(struct ust_buffer *buf,
                enum force_switch_mode mode);
@@ -351,12 +353,14 @@ static __inline__ int ltt_relay_try_reserve(
        return 0;
 }
 
-static __inline__ int ltt_reserve_slot(struct ust_trace *trace,
-               struct ust_channel *chan, void **transport_data,
-               size_t data_size, size_t *slot_size, long *buf_offset, u64 *tsc,
-               unsigned int *rflags, int largest_align, int cpu)
+static __inline__ int ltt_reserve_slot(struct ust_channel *chan,
+                                      struct ust_trace *trace, size_t data_size,
+                                      int largest_align, int cpu,
+                                      struct ust_buffer **ret_buf,
+                                      size_t *slot_size, long *buf_offset, u64 *tsc,
+                                      unsigned int *rflags)
 {
-       struct ust_buffer *buf = chan->buf[cpu];
+       struct ust_buffer *buf = *ret_buf = chan->buf[cpu];
        long o_begin, o_end, o_old;
        size_t before_hdr_pad;
 
@@ -400,9 +404,10 @@ static __inline__ int ltt_reserve_slot(struct ust_trace *trace,
        *buf_offset = o_begin + before_hdr_pad;
        return 0;
 slow_path:
-       return ltt_reserve_slot_lockless_slow(trace, chan,
-               transport_data, data_size, slot_size, buf_offset, tsc,
-               rflags, largest_align, cpu);
+       return ltt_reserve_slot_lockless_slow(chan, trace, data_size,
+                                             largest_align, cpu, ret_buf,
+                                             slot_size, buf_offset, tsc,
+                                             rflags);
 }
 
 /*
index c22a1c3b595acea94d9e6ce359f10587570022f7..04abaa9d3c0dfd1354475d0e06b216af87dcb8a9 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef UST_HEADER_INLINE_H
 #define UST_HEADER_INLINE_H
 
-#include "tracercore.h"
+#include <ust/core.h>
 
 /*
  * ust_get_header_size
index d2fee49c9c2c5076de75b6b407efc7f657933b99..fd16860ecf85a9c070f6df1ee4d751bbae89c5d2 100644 (file)
@@ -577,36 +577,36 @@ static int set_marker(struct marker_entry *entry, struct marker *elem,
        smp_wmb();
        elem->ptype = entry->ptype;
 
-//ust//        if (elem->tp_name && (active ^ _imv_read(elem->state))) {
-//ust//                WARN_ON(!elem->tp_cb);
-//ust//                /*
-//ust//                 * It is ok to directly call the probe registration because type
-//ust//                 * checking has been done in the __trace_mark_tp() macro.
-//ust//                 */
-//ust//
-//ust//                if (active) {
-//ust//                        /*
-//ust//                         * try_module_get should always succeed because we hold
-//ust//                         * markers_mutex to get the tp_cb address.
-//ust//                         */
+       if (elem->tp_name && (active ^ _imv_read(elem->state))) {
+               WARN_ON(!elem->tp_cb);
+               /*
+                * It is ok to directly call the probe registration because type
+                * checking has been done in the __trace_mark_tp() macro.
+                */
+
+               if (active) {
+                       /*
+                        * try_module_get should always succeed because we hold
+                        * markers_mutex to get the tp_cb address.
+                        */
 //ust//                        ret = try_module_get(__module_text_address(
 //ust//                                (unsigned long)elem->tp_cb));
 //ust//                        BUG_ON(!ret);
-//ust//                        ret = tracepoint_probe_register_noupdate(
-//ust//                                elem->tp_name,
-//ust//                                elem->tp_cb);
-//ust//                } else {
-//ust//                        ret = tracepoint_probe_unregister_noupdate(
-//ust//                                elem->tp_name,
-//ust//                                elem->tp_cb);
-//ust//                        /*
-//ust//                         * tracepoint_probe_update_all() must be called
-//ust//                         * before the module containing tp_cb is unloaded.
-//ust//                         */
+                       ret = tracepoint_probe_register_noupdate(
+                               elem->tp_name,
+                               elem->tp_cb);
+               } else {
+                       ret = tracepoint_probe_unregister_noupdate(
+                               elem->tp_name,
+                               elem->tp_cb);
+                       /*
+                        * tracepoint_probe_update_all() must be called
+                        * before the module containing tp_cb is unloaded.
+                        */
 //ust//                        module_put(__module_text_address(
 //ust//                                (unsigned long)elem->tp_cb));
-//ust//                }
-//ust//        }
+               }
+       }
        elem->state__imv = active;
 
        return ret;
@@ -620,24 +620,24 @@ static int set_marker(struct marker_entry *entry, struct marker *elem,
  */
 static void disable_marker(struct marker *elem)
 {
-//ust//        int ret;
-//ust//
-//ust//        /* leave "call" as is. It is known statically. */
-//ust//        if (elem->tp_name && _imv_read(elem->state)) {
-//ust//                WARN_ON(!elem->tp_cb);
-//ust//                /*
-//ust//                 * It is ok to directly call the probe registration because type
-//ust//                 * checking has been done in the __trace_mark_tp() macro.
-//ust//                 */
-//ust//                ret = tracepoint_probe_unregister_noupdate(elem->tp_name,
-//ust//                        elem->tp_cb);
-//ust//                WARN_ON(ret);
-//ust//                /*
-//ust//                 * tracepoint_probe_update_all() must be called
-//ust//                 * before the module containing tp_cb is unloaded.
-//ust//                 */
+       int ret;
+
+       /* leave "call" as is. It is known statically. */
+       if (elem->tp_name && _imv_read(elem->state)) {
+               WARN_ON(!elem->tp_cb);
+               /*
+                * It is ok to directly call the probe registration because type
+                * checking has been done in the __trace_mark_tp() macro.
+                */
+               ret = tracepoint_probe_unregister_noupdate(elem->tp_name,
+                       elem->tp_cb);
+               WARN_ON(ret);
+               /*
+                * tracepoint_probe_update_all() must be called
+                * before the module containing tp_cb is unloaded.
+                */
 //ust//                module_put(__module_text_address((unsigned long)elem->tp_cb));
-//ust//        }
+       }
        elem->state__imv = 0;
        elem->single.func = __mark_empty_function;
        /* Update the function before setting the ptype */
@@ -746,7 +746,7 @@ static void marker_update_probes(void)
        /* Markers in modules. */
 //ust//        module_update_markers();
        lib_update_markers();
-//ust//        tracepoint_probe_update_all();
+       tracepoint_probe_update_all();
        /* Update immediate values */
        core_imv_update();
 //ust//        module_imv_update(); /* FIXME: need to port for libs? */
index 4c23e8dd02451d46d6b8de34c418d40e872bc9f3..d3c8cdb3d54b4dbe5dc97e810243cb705d685680 100644 (file)
 #include <stdint.h>
 #include <stdio.h>
 
-#include <ust/kernelcompat.h>
 #define _LGPL_SOURCE
 #include <urcu-bp.h>
 #include <urcu/rculist.h>
 
+#include <ust/kernelcompat.h>
+#include <ust/core.h>
 #include "buffers.h"
 #include "tracer.h"
 //#include "list.h"
@@ -50,11 +51,6 @@ enum ltt_type {
        LTT_TYPE_NONE,
 };
 
-static int ust_get_cpu(void)
-{
-       return sched_getcpu();
-}
-
 #define LTT_ATTRIBUTE_NETWORK_BYTE_ORDER (1<<1)
 
 /*
@@ -689,10 +685,9 @@ notrace void ltt_vtrace(const struct marker *mdata, void *probe_data,
                }
 
                /* reserve space : header and data */
-               ret = ltt_reserve_slot(trace, channel, &transport_data,
-                                       data_size, &slot_size, &buf_offset,
-                                       &tsc, &rflags,
-                                       largest_align, cpu);
+               ret = ltt_reserve_slot(channel, trace, data_size, largest_align,
+                                       cpu, &buf, &slot_size, &buf_offset,
+                                       &tsc, &rflags);
                if (unlikely(ret < 0))
                        continue; /* buffer full */
 
@@ -701,8 +696,7 @@ notrace void ltt_vtrace(const struct marker *mdata, void *probe_data,
 //ust//                buf = ((struct rchan *)channel->trans_channel_data)->buf[cpu];
                buf = channel->buf[cpu];
                /* Out-of-order write : header and data */
-               buf_offset = ltt_write_event_header(trace,
-                                       channel, buf, buf_offset,
+               buf_offset = ltt_write_event_header(channel, buf, buf_offset,
                                        eID, data_size, tsc, rflags);
                ltt_write_event_data(buf, buf_offset, &closure,
                                        serialize_private,
index cc3974e2a9d45ef0febc077b153ffa7637fe2ad3..dc2d62fffe66b359c70c3d145355bc4af01b1c3d 100644 (file)
@@ -241,8 +241,7 @@ static __inline__ size_t ltt_subbuffer_header_size(void)
        return offsetof(struct ltt_subbuffer_header, header_end);
 }
 
-extern size_t ltt_write_event_header_slow(struct ust_trace *trace,
-               struct ust_channel *channel,
+extern size_t ltt_write_event_header_slow(struct ust_channel *channel,
                struct ust_buffer *buf, long buf_offset,
                u16 eID, u32 event_size,
                u64 tsc, unsigned int rflags);
@@ -264,8 +263,7 @@ extern size_t ltt_write_event_header_slow(struct ust_trace *trace,
  *
  * returns : offset where the event data must be written.
  */
-static __inline__ size_t ltt_write_event_header(struct ust_trace *trace,
-               struct ust_channel *chan,
+static __inline__ size_t ltt_write_event_header(struct ust_channel *chan,
                struct ust_buffer *buf, long buf_offset,
                u16 eID, u32 event_size,
                u64 tsc, unsigned int rflags)
@@ -283,7 +281,7 @@ static __inline__ size_t ltt_write_event_header(struct ust_trace *trace,
        return buf_offset;
 
 slow_path:
-       return ltt_write_event_header_slow(trace, chan, buf, buf_offset,
+       return ltt_write_event_header_slow(chan, buf, buf_offset,
                                eID, event_size, tsc, rflags);
 }
 
@@ -338,6 +336,21 @@ static __inline__ void ltt_write_trace_header(struct ust_trace *trace,
        header->freq_scale = trace->freq_scale;
 }
 
+static __inline__ int ust_get_cpu(void)
+{
+#ifndef UST_VALGRIND
+       return sched_getcpu();
+#else
+       /* Valgrind does not support the sched_getcpu() vsyscall.
+        * It causes it to detect a segfault in the program and stop it.
+        * So if we want to check libust with valgrind, we have to refrain
+        * from using this call. TODO: it would probably be better to return
+        * other values too, to better test it.
+        */
+       return 0;
+#endif
+}
+
 
 /*
  * Size reserved for high priority events (interrupts, NMI, BH) at the end of a
index 2f3d7c4a3b9fc93c9a85e6eac544a889f00947c8..52f75ec82352fca4ebddb7fde5245ecb39aef14d 100644 (file)
@@ -52,39 +52,4 @@ extern ltt_run_filter_functor ltt_run_filter;
 extern void ltt_filter_register(ltt_run_filter_functor func);
 extern void ltt_filter_unregister(void);
 
-#if defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT)
-
-/*
- * Calculate the offset needed to align the type.
- * size_of_type must be non-zero.
- */
-static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type)
-{
-       size_t alignment = min(sizeof(void *), size_of_type);
-       return (alignment - align_drift) & (alignment - 1);
-}
-/* Default arch alignment */
-#define LTT_ALIGN
-
-static inline int ltt_get_alignment(void)
-{
-       return sizeof(void *);
-}
-
-#else
-
-static inline unsigned int ltt_align(size_t align_drift,
-                size_t size_of_type)
-{
-       return 0;
-}
-
-#define LTT_ALIGN __attribute__((packed))
-
-static inline int ltt_get_alignment(void)
-{
-       return 0;
-}
-#endif /* defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT) */
-
 #endif /* UST_TRACERCORE_H */
diff --git a/libust/type-serializer.c b/libust/type-serializer.c
new file mode 100644 (file)
index 0000000..3ee54eb
--- /dev/null
@@ -0,0 +1,111 @@
+/**
+ * ltt-type-serializer.c
+ *
+ * LTTng specialized type serializer.
+ *
+ * Copyright Mathieu Desnoyers, 2008.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+#include <urcu/rculist.h>
+#include <ust/type-serializer.h>
+#include <ust/core.h>
+#include "tracer.h"
+
+notrace
+void _ltt_specialized_trace(const struct marker *mdata, void *probe_data,
+               void *serialize_private, unsigned int data_size,
+               unsigned int largest_align)
+{
+       int ret;
+       uint16_t eID;
+       size_t slot_size;
+       unsigned int chan_index;
+       struct ust_buffer *buf;
+       struct ust_channel *chan;
+       struct ust_trace *trace;
+       u64 tsc;
+       long buf_offset;
+       int cpu;
+       unsigned int rflags;
+
+       /*
+        * If we get here, it's probably because we have useful work to do.
+        */
+       if (unlikely(ltt_traces.num_active_traces == 0))
+               return;
+
+       rcu_read_lock();
+       cpu = ust_get_cpu();
+
+       /* Force volatile access. */
+       STORE_SHARED(ltt_nesting, LOAD_SHARED(ltt_nesting) + 1);
+
+       /*
+        * asm volatile and "memory" clobber prevent the compiler from moving
+        * instructions out of the ltt nesting count. This is required to ensure
+        * that probe side-effects which can cause recursion (e.g. unforeseen
+        * traps, divisions by 0, ...) are triggered within the incremented
+        * nesting count section.
+        */
+       barrier();
+       eID = mdata->event_id;
+       chan_index = mdata->channel_id;
+
+       /*
+        * Iterate on each trace, typically small number of active traces,
+        * list iteration with prefetch is usually slower.
+        */
+       list_for_each_entry_rcu(trace, &ltt_traces.head, list) {
+               if (unlikely(!trace->active))
+                       continue;
+//ust//                if (unlikely(!ltt_run_filter(trace, eID)))
+//ust//                        continue;
+#ifdef CONFIG_LTT_DEBUG_EVENT_SIZE
+               rflags = LTT_RFLAG_ID_SIZE;
+#else
+               if (unlikely(eID >= LTT_FREE_EVENTS))
+                       rflags = LTT_RFLAG_ID;
+               else
+                       rflags = 0;
+#endif
+               /*
+                * Skip channels added after trace creation.
+                */
+               if (unlikely(chan_index >= trace->nr_channels))
+                       continue;
+               chan = &trace->channels[chan_index];
+               if (!chan->active)
+                       continue;
+
+               /* reserve space : header and data */
+               ret = ltt_reserve_slot(chan, trace, data_size, largest_align,
+                                      cpu, &buf, &slot_size, &buf_offset, &tsc,
+                                      &rflags);
+               if (unlikely(ret < 0))
+                       continue; /* buffer full */
+
+               /* Out-of-order write : header and data */
+               buf_offset = ltt_write_event_header(chan, buf,
+                                                   buf_offset, eID, data_size,
+                                                   tsc, rflags);
+               if (data_size) {
+                       buf_offset += ltt_align(buf_offset, largest_align);
+                       ust_buffers_write(buf, buf_offset,
+                                       serialize_private, data_size);
+                       buf_offset += data_size;
+               }
+               /* Out-of-order commit */
+               ltt_commit_slot(chan, buf, buf_offset, data_size, slot_size);
+       }
+       /*
+        * asm volatile and "memory" clobber prevent the compiler from moving
+        * instructions out of the ltt nesting count. This is required to ensure
+        * that probe side-effects which can cause recursion (e.g. unforeseen
+        * traps, divisions by 0, ...) are triggered within the incremented
+        * nesting count section.
+        */
+       barrier();
+       STORE_SHARED(ltt_nesting, LOAD_SHARED(ltt_nesting) - 1);
+       rcu_read_unlock();
+}
index f7d07ae5e29bd1664c4fb6a8fb5e4ef52329a29d..f34f305410e082668a2fc42981c2509e90469f21 100644 (file)
@@ -18,5 +18,5 @@
 #include <ust/tracepoint.h>
 
 DECLARE_TRACE(hello_tptest,
-             TPPROTO(int anint),
-             TPARGS(anint));
+             TP_PROTO(int anint),
+             TP_ARGS(anint));
This page took 0.035247 seconds and 4 git commands to generate.