Fix: x86-64 accept instrumentation
[lttng-modules.git] / lib / ringbuffer / ring_buffer_frontend.c
index 017d30f5ddf673c36f2932d2fe83581a35bea50c..89eefe96bdd05baafe93ddb776aff84e84c24d15 100644 (file)
@@ -63,6 +63,7 @@
 #include <wrapper/atomic.h>
 #include <wrapper/kref.h>
 #include <wrapper/percpu-defs.h>
+#include <wrapper/timer.h>
 
 /*
  * Internal structure representing offsets to use at a sub-buffer switch.
@@ -281,7 +282,7 @@ static void switch_buffer_timer(unsigned long data)
                lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
 
        if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
-               mod_timer_pinned(&buf->switch_timer,
+               lttng_mod_timer_pinned(&buf->switch_timer,
                                 jiffies + chan->switch_timer_interval);
        else
                mod_timer(&buf->switch_timer,
@@ -298,7 +299,12 @@ static void lib_ring_buffer_start_switch_timer(struct lib_ring_buffer *buf)
 
        if (!chan->switch_timer_interval || buf->switch_timer_enabled)
                return;
-       init_timer(&buf->switch_timer);
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               lttng_init_timer_pinned(&buf->switch_timer);
+       else
+               init_timer(&buf->switch_timer);
+
        buf->switch_timer.function = switch_buffer_timer;
        buf->switch_timer.expires = jiffies + chan->switch_timer_interval;
        buf->switch_timer.data = (unsigned long)buf;
@@ -341,7 +347,7 @@ static void read_buffer_timer(unsigned long data)
        }
 
        if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
-               mod_timer_pinned(&buf->read_timer,
+               lttng_mod_timer_pinned(&buf->read_timer,
                                 jiffies + chan->read_timer_interval);
        else
                mod_timer(&buf->read_timer,
@@ -361,7 +367,11 @@ static void lib_ring_buffer_start_read_timer(struct lib_ring_buffer *buf)
            || buf->read_timer_enabled)
                return;
 
-       init_timer(&buf->read_timer);
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               lttng_init_timer_pinned(&buf->read_timer);
+       else
+               init_timer(&buf->read_timer);
+
        buf->read_timer.function = read_buffer_timer;
        buf->read_timer.expires = jiffies + chan->read_timer_interval;
        buf->read_timer.data = (unsigned long)buf;
@@ -904,15 +914,6 @@ int lib_ring_buffer_snapshot(struct lib_ring_buffer *buf,
        unsigned long consumed_cur, write_offset;
        int finalized;
 
-       /*
-        * First, ensure we perform a "final" flush onto the stream.  This will
-        * ensure we create a packet of padding if we encounter an empty
-        * packet. This ensures the time-stamps right before the snapshot is
-        * used as end of packet timestamp.
-        */
-       if (!buf->quiescent)
-               _lib_ring_buffer_switch_remote(buf, SWITCH_FLUSH);
-
 retry:
        finalized = ACCESS_ONCE(buf->finalized);
        /*
@@ -1615,11 +1616,17 @@ void lib_ring_buffer_switch_slow(struct lib_ring_buffer *buf, enum switch_mode m
 }
 EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_slow);
 
+struct switch_param {
+       struct lib_ring_buffer *buf;
+       enum switch_mode mode;
+};
+
 static void remote_switch(void *info)
 {
-       struct lib_ring_buffer *buf = info;
+       struct switch_param *param = info;
+       struct lib_ring_buffer *buf = param->buf;
 
-       lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+       lib_ring_buffer_switch_slow(buf, param->mode);
 }
 
 static void _lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf,
@@ -1628,6 +1635,7 @@ static void _lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf,
        struct channel *chan = buf->backend.chan;
        const struct lib_ring_buffer_config *config = &chan->backend.config;
        int ret;
+       struct switch_param param;
 
        /*
         * With global synchronization we don't need to use the IPI scheme.
@@ -1648,8 +1656,10 @@ static void _lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf,
         * switch.
         */
        get_online_cpus();
+       param.buf = buf;
+       param.mode = mode;
        ret = smp_call_function_single(buf->backend.cpu,
-                                remote_switch, buf, 1);
+                                remote_switch, &param, 1);
        if (ret) {
                /* Remote CPU is offline, do it ourself. */
                lib_ring_buffer_switch_slow(buf, mode);
@@ -1663,6 +1673,13 @@ void lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf)
 }
 EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_remote);
 
+/* Switch sub-buffer even if current sub-buffer is empty. */
+void lib_ring_buffer_switch_remote_empty(struct lib_ring_buffer *buf)
+{
+       _lib_ring_buffer_switch_remote(buf, SWITCH_FLUSH);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_remote_empty);
+
 /*
  * Returns :
  * 0 if ok
This page took 0.027115 seconds and 4 git commands to generate.