Cleanup: Move lib/ringbuffer/ headers to include/ringbuffer/
[lttng-modules.git] / lib / ringbuffer / ring_buffer_frontend.c
index 90c665d6e7104c186cfe12ef63bdd399b13ba16e..fca37fbc3a5b143a08cb55b94f762bf664fb7187 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1)
+/* SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only)
  *
  * ring_buffer_frontend.c
  *
 #include <linux/percpu.h>
 #include <asm/cacheflush.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 <ringbuffer/config.h>
+#include <ringbuffer/backend.h>
+#include <ringbuffer/frontend.h>
+#include <ringbuffer/iterator.h>
+#include <ringbuffer/nohz.h>
 #include <wrapper/atomic.h>
 #include <wrapper/kref.h>
 #include <wrapper/percpu-defs.h>
@@ -978,8 +978,6 @@ void *channel_destroy(struct channel *chan)
                                config->cb.buffer_finalize(buf,
                                                           chan->backend.priv,
                                                           cpu);
-                       if (buf->backend.allocated)
-                               lib_ring_buffer_set_quiescent(buf);
                        /*
                         * Perform flush before writing to finalized.
                         */
@@ -992,8 +990,6 @@ void *channel_destroy(struct channel *chan)
 
                if (config->cb.buffer_finalize)
                        config->cb.buffer_finalize(buf, chan->backend.priv, -1);
-               if (buf->backend.allocated)
-                       lib_ring_buffer_set_quiescent(buf);
                /*
                 * Perform flush before writing to finalized.
                 */
@@ -1502,12 +1498,13 @@ void lib_ring_buffer_print_buffer_errors(struct lib_ring_buffer *buf,
                                                       cpu);
 }
 
+#ifdef LTTNG_RING_BUFFER_COUNT_EVENTS
 static
-void lib_ring_buffer_print_errors(struct channel *chan,
-                                 struct lib_ring_buffer *buf, int cpu)
+void lib_ring_buffer_print_records_count(struct channel *chan,
+                                        struct lib_ring_buffer *buf,
+                                        int cpu)
 {
        const struct lib_ring_buffer_config *config = &chan->backend.config;
-       void *priv = chan->backend.priv;
 
        if (!strcmp(chan->backend.name, "relay-metadata")) {
                printk(KERN_DEBUG "ring buffer %s: %lu records written, "
@@ -1521,7 +1518,26 @@ void lib_ring_buffer_print_errors(struct channel *chan,
                        chan->backend.name, cpu,
                        v_read(config, &buf->records_count),
                        v_read(config, &buf->records_overrun));
+       }
+}
+#else
+static
+void lib_ring_buffer_print_records_count(struct channel *chan,
+                                        struct lib_ring_buffer *buf,
+                                        int cpu)
+{
+}
+#endif
 
+static
+void lib_ring_buffer_print_errors(struct channel *chan,
+                                 struct lib_ring_buffer *buf, int cpu)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       void *priv = chan->backend.priv;
+
+       lib_ring_buffer_print_records_count(chan, buf, cpu);
+       if (strcmp(chan->backend.name, "relay-metadata")) {
                if (v_read(config, &buf->records_lost_full)
                    || v_read(config, &buf->records_lost_wrap)
                    || v_read(config, &buf->records_lost_big))
@@ -1941,6 +1957,16 @@ void lib_ring_buffer_switch_remote_empty(struct lib_ring_buffer *buf)
 }
 EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_remote_empty);
 
+void lib_ring_buffer_clear(struct lib_ring_buffer *buf)
+{
+       struct lib_ring_buffer_backend *bufb = &buf->backend;
+       struct channel *chan = bufb->chan;
+
+       lib_ring_buffer_switch_remote(buf);
+       lib_ring_buffer_clear_reader(buf, chan);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_clear);
+
 /*
  * Returns :
  * 0 if ok
This page took 0.024224 seconds and 4 git commands to generate.