fix: file: Rename fcheck lookup_fd_rcu (v5.10.220)
[lttng-modules.git] / include / ringbuffer / frontend_api.h
index 49f0eee27134f7e68b2f9e2613c254a7bcd4974a..e8d77d9588168d48fb6502c43093bd271b5770c5 100644 (file)
@@ -14,7 +14,7 @@
 #define _LIB_RING_BUFFER_FRONTEND_API_H
 
 #include <ringbuffer/frontend.h>
-#include <wrapper/percpu-defs.h>
+#include <linux/percpu-defs.h>
 #include <linux/errno.h>
 #include <linux/prefetch.h>
 
@@ -33,7 +33,7 @@
  * section.
  */
 static inline
-int lib_ring_buffer_get_cpu(const struct lib_ring_buffer_config *config)
+int lib_ring_buffer_get_cpu(const struct lttng_kernel_ring_buffer_config *config)
 {
        int cpu, nesting;
 
@@ -55,10 +55,10 @@ int lib_ring_buffer_get_cpu(const struct lib_ring_buffer_config *config)
  * lib_ring_buffer_put_cpu - Follows ring buffer reserve/commit.
  */
 static inline
-void lib_ring_buffer_put_cpu(const struct lib_ring_buffer_config *config)
+void lib_ring_buffer_put_cpu(const struct lttng_kernel_ring_buffer_config *config)
 {
        barrier();
-       (*lttng_this_cpu_ptr(&lib_ring_buffer_nesting))--;
+       (*this_cpu_ptr(&lib_ring_buffer_nesting))--;
        rcu_read_unlock_sched_notrace();
 }
 
@@ -69,19 +69,19 @@ void lib_ring_buffer_put_cpu(const struct lib_ring_buffer_config *config)
  * returns 0 if reserve ok, or 1 if the slow path must be taken.
  */
 static inline
-int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
+int lib_ring_buffer_try_reserve(const struct lttng_kernel_ring_buffer_config *config,
                                struct lttng_kernel_ring_buffer_ctx *ctx,
                                void *client_ctx,
                                unsigned long *o_begin, unsigned long *o_end,
                                unsigned long *o_old, size_t *before_hdr_pad)
 {
-       struct channel *chan = ctx->priv.chan;
-       struct lib_ring_buffer *buf = ctx->priv.buf;
+       struct lttng_kernel_ring_buffer_channel *chan = ctx->priv.chan;
+       struct lttng_kernel_ring_buffer *buf = ctx->priv.buf;
        *o_begin = v_read(config, &buf->offset);
        *o_old = *o_begin;
 
-       ctx->priv.tsc = lib_ring_buffer_clock_read(chan);
-       if ((int64_t) ctx->priv.tsc == -EIO)
+       ctx->priv.timestamp = lib_ring_buffer_clock_read(chan);
+       if ((int64_t) ctx->priv.timestamp == -EIO)
                return 1;
 
        /*
@@ -91,8 +91,8 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
         */
        prefetch(&buf->commit_hot[subbuf_index(*o_begin, chan)]);
 
-       if (last_tsc_overflow(config, buf, ctx->priv.tsc))
-               ctx->priv.rflags |= RING_BUFFER_RFLAG_FULL_TSC;
+       if (last_timestamp_overflow(config, buf, ctx->priv.timestamp))
+               ctx->priv.rflags |= RING_BUFFER_RFLAG_FULL_TIMESTAMP;
 
        if (unlikely(subbuf_offset(*o_begin, chan) == 0))
                return 1;
@@ -128,7 +128,8 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
  * @ctx: ring buffer context. (input and output) Must be already initialized.
  *
  * Atomic wait-free slot reservation. The reserved space starts at the context
- * "pre_offset". Its length is "slot_size". The associated time-stamp is "tsc".
+ * "pre_offset". Its length is "slot_size". The associated time-stamp is
+ * "timestamp".
  *
  * Return :
  *  0 on success.
@@ -139,12 +140,12 @@ int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
  */
 
 static inline
-int lib_ring_buffer_reserve(const struct lib_ring_buffer_config *config,
+int lib_ring_buffer_reserve(const struct lttng_kernel_ring_buffer_config *config,
                            struct lttng_kernel_ring_buffer_ctx *ctx,
                            void *client_ctx)
 {
-       struct channel *chan = ctx->priv.chan;
-       struct lib_ring_buffer *buf;
+       struct lttng_kernel_ring_buffer_channel *chan = ctx->priv.chan;
+       struct lttng_kernel_ring_buffer *buf;
        unsigned long o_begin, o_end, o_old;
        size_t before_hdr_pad = 0;
 
@@ -171,12 +172,12 @@ int lib_ring_buffer_reserve(const struct lib_ring_buffer_config *config,
                goto slow_path;
 
        /*
-        * Atomically update last_tsc. This update races against concurrent
-        * atomic updates, but the race will always cause supplementary full TSC
-        * record headers, never the opposite (missing a full TSC record header
-        * when it would be needed).
+        * Atomically update last_timestamp. This update races against concurrent
+        * atomic updates, but the race will always cause supplementary
+        * full timestamp record headers, never the opposite (missing a
+        * full timestamp record header when it would be needed).
         */
-       save_last_tsc(config, ctx->priv.buf, ctx->priv.tsc);
+       save_last_timestamp(config, ctx->priv.buf, ctx->priv.timestamp);
 
        /*
         * Push the reader if necessary
@@ -211,8 +212,8 @@ slow_path:
  * disabled, for RING_BUFFER_SYNC_PER_CPU configuration.
  */
 static inline
-void lib_ring_buffer_switch(const struct lib_ring_buffer_config *config,
-                           struct lib_ring_buffer *buf, enum switch_mode mode)
+void lib_ring_buffer_switch(const struct lttng_kernel_ring_buffer_config *config,
+                           struct lttng_kernel_ring_buffer *buf, enum switch_mode mode)
 {
        lib_ring_buffer_switch_slow(buf, mode);
 }
@@ -228,11 +229,11 @@ void lib_ring_buffer_switch(const struct lib_ring_buffer_config *config,
  * specified sub-buffer, and delivers it if necessary.
  */
 static inline
-void lib_ring_buffer_commit(const struct lib_ring_buffer_config *config,
+void lib_ring_buffer_commit(const struct lttng_kernel_ring_buffer_config *config,
                            const struct lttng_kernel_ring_buffer_ctx *ctx)
 {
-       struct channel *chan = ctx->priv.chan;
-       struct lib_ring_buffer *buf = ctx->priv.buf;
+       struct lttng_kernel_ring_buffer_channel *chan = ctx->priv.chan;
+       struct lttng_kernel_ring_buffer *buf = ctx->priv.buf;
        unsigned long offset_end = ctx->priv.buf_offset;
        unsigned long endidx = subbuf_index(offset_end - 1, chan);
        unsigned long commit_count;
@@ -280,7 +281,7 @@ void lib_ring_buffer_commit(const struct lib_ring_buffer_config *config,
        commit_count = v_read(config, &cc_hot->cc);
 
        lib_ring_buffer_check_deliver(config, buf, chan, offset_end - 1,
-                                     commit_count, endidx, ctx->priv.tsc);
+                                     commit_count, endidx, ctx);
        /*
         * Update used size at each commit. It's needed only for extracting
         * ring_buffer buffers from vmcore, after crash.
@@ -300,25 +301,26 @@ void lib_ring_buffer_commit(const struct lib_ring_buffer_config *config,
  * Returns 0 upon success, -EPERM if the record cannot be discarded.
  */
 static inline
-int lib_ring_buffer_try_discard_reserve(const struct lib_ring_buffer_config *config,
+int lib_ring_buffer_try_discard_reserve(const struct lttng_kernel_ring_buffer_config *config,
                                        const struct lttng_kernel_ring_buffer_ctx *ctx)
 {
-       struct lib_ring_buffer *buf = ctx->priv.buf;
+       struct lttng_kernel_ring_buffer *buf = ctx->priv.buf;
        unsigned long end_offset = ctx->priv.pre_offset + ctx->priv.slot_size;
 
        /*
         * We need to ensure that if the cmpxchg succeeds and discards the
-        * record, the next record will record a full TSC, because it cannot
-        * rely on the last_tsc associated with the discarded record to detect
-        * overflows. The only way to ensure this is to set the last_tsc to 0
-        * (assuming no 64-bit TSC overflow), which forces to write a 64-bit
-        * timestamp in the next record.
+        * record, the next record will record a full timestamp, because
+        * it cannot rely on the last_timestamp associated with the
+        * discarded record to detect overflows. The only way to ensure
+        * this is to set the last_timestamp to 0 (assuming no 64-bit
+        * timestamp overflow), which forces to write a 64-bit timestamp in
+        * the next record.
         *
-        * Note: if discard fails, we must leave the TSC in the record header.
-        * It is needed to keep track of TSC overflows for the following
-        * records.
+        * Note: if discard fails, we must leave the timestamp in the
+        * record header. It is needed to keep track of timestamp
+        * overflows for the following records.
         */
-       save_last_tsc(config, buf, 0ULL);
+       save_last_timestamp(config, buf, 0ULL);
 
        if (likely(v_cmpxchg(config, &buf->offset, end_offset, ctx->priv.pre_offset)
                   != end_offset))
@@ -328,29 +330,29 @@ int lib_ring_buffer_try_discard_reserve(const struct lib_ring_buffer_config *con
 }
 
 static inline
-void channel_record_disable(const struct lib_ring_buffer_config *config,
-                           struct channel *chan)
+void channel_record_disable(const struct lttng_kernel_ring_buffer_config *config,
+                           struct lttng_kernel_ring_buffer_channel *chan)
 {
        atomic_inc(&chan->record_disabled);
 }
 
 static inline
-void channel_record_enable(const struct lib_ring_buffer_config *config,
-                          struct channel *chan)
+void channel_record_enable(const struct lttng_kernel_ring_buffer_config *config,
+                          struct lttng_kernel_ring_buffer_channel *chan)
 {
        atomic_dec(&chan->record_disabled);
 }
 
 static inline
-void lib_ring_buffer_record_disable(const struct lib_ring_buffer_config *config,
-                                   struct lib_ring_buffer *buf)
+void lib_ring_buffer_record_disable(const struct lttng_kernel_ring_buffer_config *config,
+                                   struct lttng_kernel_ring_buffer *buf)
 {
        atomic_inc(&buf->record_disabled);
 }
 
 static inline
-void lib_ring_buffer_record_enable(const struct lib_ring_buffer_config *config,
-                                  struct lib_ring_buffer *buf)
+void lib_ring_buffer_record_enable(const struct lttng_kernel_ring_buffer_config *config,
+                                  struct lttng_kernel_ring_buffer *buf)
 {
        atomic_dec(&buf->record_disabled);
 }
This page took 0.028254 seconds and 4 git commands to generate.