Implement structure, compound array/sequence types
[lttng-modules.git] / lib / ringbuffer / ring_buffer_frontend.c
index ae0b9e3986267a8b79e8395d13cd23d55cc357c7..9ebdd5fbeefab0090d4353e42cf768e462b1647e 100644 (file)
 #include <linux/module.h>
 #include <linux/percpu.h>
 
-#include "../../wrapper/ringbuffer/config.h"
-#include "../../wrapper/ringbuffer/backend.h"
-#include "../../wrapper/ringbuffer/frontend.h"
-#include "../../wrapper/ringbuffer/iterator.h"
-#include "../../wrapper/ringbuffer/nohz.h"
-#include "../../wrapper/atomic.h"
+#include <wrapper/ringbuffer/config.h>
+#include <wrapper/ringbuffer/backend.h>
+#include <wrapper/ringbuffer/frontend.h>
+#include <wrapper/ringbuffer/iterator.h>
+#include <wrapper/ringbuffer/nohz.h>
+#include <wrapper/atomic.h>
+#include <wrapper/kref.h>
+#include <wrapper/percpu-defs.h>
 
 /*
  * Internal structure representing offsets to use at a sub-buffer switch.
@@ -498,16 +500,16 @@ static int notrace ring_buffer_tick_nohz_callback(struct notifier_block *nb,
                raw_spin_unlock(&buf->raw_tick_nohz_spinlock);
                break;
        case TICK_NOHZ_STOP:
-               spin_lock(&__get_cpu_var(ring_buffer_nohz_lock));
+               spin_lock(lttng_this_cpu_ptr(&ring_buffer_nohz_lock));
                lib_ring_buffer_stop_switch_timer(buf);
                lib_ring_buffer_stop_read_timer(buf);
-               spin_unlock(&__get_cpu_var(ring_buffer_nohz_lock));
+               spin_unlock(lttng_this_cpu_ptr(&ring_buffer_nohz_lock));
                break;
        case TICK_NOHZ_RESTART:
-               spin_lock(&__get_cpu_var(ring_buffer_nohz_lock));
+               spin_lock(lttng_this_cpu_ptr(&ring_buffer_nohz_lock));
                lib_ring_buffer_start_read_timer(buf);
                lib_ring_buffer_start_switch_timer(buf);
-               spin_unlock(&__get_cpu_var(ring_buffer_nohz_lock));
+               spin_unlock(lttng_this_cpu_ptr(&ring_buffer_nohz_lock));
                break;
        }
 
@@ -792,7 +794,10 @@ int lib_ring_buffer_open_read(struct lib_ring_buffer *buf)
 
        if (!atomic_long_add_unless(&buf->active_readers, 1, 1))
                return -EBUSY;
-       kref_get(&chan->ref);
+       if (!lttng_kref_get(&chan->ref)) {
+               atomic_long_dec(&buf->active_readers);
+               return -EOVERFLOW;
+       }
        lttng_smp_mb__after_atomic();
        return 0;
 }
This page took 0.02325 seconds and 4 git commands to generate.