Unregister tracepoint probes when not needed
[lttng-ust.git] / libringbuffer / ring_buffer_frontend.c
index 6f94040e9b186ca9a2788c3875d9d453bddde8c6..6719626c2d5672d1f4b32b1800e79f3fdd98f672 100644 (file)
@@ -58,6 +58,7 @@
 #include <fcntl.h>
 #include <urcu/compiler.h>
 #include <urcu/ref.h>
+#include <urcu/tls-compat.h>
 #include <helper.h>
 
 #include "smp.h"
@@ -102,7 +103,7 @@ struct switch_offsets {
                     switch_old_end:1;
 };
 
-__thread unsigned int lib_ring_buffer_nesting;
+DEFINE_URCU_TLS(unsigned int, lib_ring_buffer_nesting);
 
 /*
  * TODO: this is unused. Errors are saved within the ring buffer.
@@ -1232,6 +1233,19 @@ int lib_ring_buffer_try_switch_slow(enum switch_mode mode,
         */
        if (mode == SWITCH_FLUSH || off > 0) {
                if (caa_unlikely(off == 0)) {
+                       /*
+                        * A final flush that encounters an empty
+                        * sub-buffer cannot switch buffer if a
+                        * reader is located within this sub-buffer.
+                        * Anyway, the purpose of final flushing of a
+                        * sub-buffer at offset 0 is to handle the case
+                        * of entirely empty stream.
+                        */
+                       if (caa_unlikely(subbuf_trunc(offsets->begin, chan)
+                                        - subbuf_trunc((unsigned long)
+                                            uatomic_read(&buf->consumed), chan)
+                                       >= chan->backend.buf_size))
+                               return -1;
                        /*
                         * The client does not save any header information.
                         * Don't switch empty subbuffer on finalize, because it
@@ -1558,5 +1572,5 @@ int lib_ring_buffer_reserve_slow(struct lttng_ust_lib_ring_buffer_ctx *ctx)
  */
 void lttng_fixup_ringbuffer_tls(void)
 {
-       asm volatile ("" : : "m" (lib_ring_buffer_nesting));
+       asm volatile ("" : : "m" (URCU_TLS(lib_ring_buffer_nesting)));
 }
This page took 0.024484 seconds and 4 git commands to generate.