Removing NO_IPI ifdef for memory barrier. The smp_wmb should be used all the time...
[ust.git] / libust / serialize.c
index 7f9ce5ad44f2a4f80cd77c68ca593fe0096120c8..32df0b96ddbae05c9b4c1765444684418e20980f 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/core.h>
+#include <ust/clock.h>
 #include "buffers.h"
 #include "tracer.h"
-//#include "list.h"
 #include "usterr.h"
+#include "ust_snprintf.h"
 
 enum ltt_type {
        LTT_TYPE_SIGNED_INT,
@@ -49,11 +50,6 @@ enum ltt_type {
        LTT_TYPE_NONE,
 };
 
-static int ust_get_cpu(void)
-{
-       return sched_getcpu();
-}
-
 #define LTT_ATTRIBUTE_NETWORK_BYTE_ORDER (1<<1)
 
 /*
@@ -537,7 +533,7 @@ notrace size_t ltt_serialize_data(struct ust_buffer *buf, size_t buf_offset,
                        ++fmt;                  /* skip first '%' */
                        if (*fmt == '%')        /* Escaped %% */
                                break;
-                       fmt = parse_c_type(fmt, &c_size, &c_type);
+                       fmt = parse_c_type(fmt, &c_size, &c_type, NULL);
                        /*
                         * Output c types if no trace types has been
                         * specified.
@@ -622,11 +618,11 @@ notrace void ltt_vtrace(const struct marker *mdata, void *probe_data,
                return;
 
        rcu_read_lock(); //ust// rcu_read_lock_sched_notrace();
-//ust//        cpu = smp_processor_id();
        cpu = ust_get_cpu();
-//ust//        __get_cpu_var(ltt_nesting)++;
-       /* FIXME: should nesting be per-cpu? */
-       ltt_nesting++;
+
+       /* Force volatile access. */
+       STORE_SHARED(ltt_nesting, LOAD_SHARED(ltt_nesting) + 1);
+       barrier();
 
        pdata = (struct ltt_active_marker *)probe_data;
        eID = mdata->event_id;
@@ -688,10 +684,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 */
 
@@ -700,8 +695,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,
@@ -709,10 +703,12 @@ notrace void ltt_vtrace(const struct marker *mdata, void *probe_data,
                va_end(args_copy);
                /* Out-of-order commit */
                ltt_commit_slot(channel, buf, buf_offset, data_size, slot_size);
-               DBG("just commited event at offset %ld and size %zd", buf_offset, slot_size);
+               DBG("just commited event (%s/%s) at offset %ld and size %zd", mdata->channel, mdata->name, buf_offset, slot_size);
        }
-//ust//        __get_cpu_var(ltt_nesting)--;
-       ltt_nesting--;
+
+       barrier();
+       STORE_SHARED(ltt_nesting, LOAD_SHARED(ltt_nesting) - 1);
+
        rcu_read_unlock(); //ust// rcu_read_unlock_sched_notrace();
 }
 
@@ -808,7 +804,7 @@ int serialize_to_text(char *outbuf, int bufsize, const char *fmt, va_list ap)
                outbuf = &false_buf;
                bufsize = 1;
        }
-       result = vsnprintf(outbuf, bufsize, new_fmt, ap);
+       result = ust_safe_vsnprintf(outbuf, bufsize, new_fmt, ap);
 
        return result;
 }
This page took 0.02414 seconds and 4 git commands to generate.