Rename "tsc" to "timestamp"
[lttng-modules.git] / include / ringbuffer / frontend_internal.h
index fa186823a7db39304da918229e378de77eb5e05e..39dbbf080cc9d23558607727d62ca8af12d270ae 100644 (file)
@@ -71,62 +71,63 @@ unsigned long subbuf_index(unsigned long offset, struct lttng_kernel_ring_buffer
 }
 
 /*
- * Last TSC comparison functions. Check if the current TSC overflows tsc_bits
- * bits from the last TSC read. When overflows are detected, the full 64-bit
- * timestamp counter should be written in the record header. Reads and writes
- * last_tsc atomically.
+ * Last timestamp comparison functions. Check if the current timestamp
+ * overflows timestamp_bits bits from the last timestamp read. When
+ * overflows are detected, the full 64-bit timestamp counter should be
+ * written in the record header. Reads and writes last_timestamp
+ * atomically.
  */
 
 #if (BITS_PER_LONG == 32)
 static inline
-void save_last_tsc(const struct lib_ring_buffer_config *config,
-                  struct lib_ring_buffer *buf, u64 tsc)
+void save_last_timestamp(const struct lttng_kernel_ring_buffer_config *config,
+                  struct lttng_kernel_ring_buffer *buf, u64 timestamp)
 {
-       if (config->tsc_bits == 0 || config->tsc_bits == 64)
+       if (config->timestamp_bits == 0 || config->timestamp_bits == 64)
                return;
 
        /*
         * Ensure the compiler performs this update in a single instruction.
         */
-       v_set(config, &buf->last_tsc, (unsigned long)(tsc >> config->tsc_bits));
+       v_set(config, &buf->last_timestamp, (unsigned long)(timestamp >> config->timestamp_bits));
 }
 
 static inline
-int last_tsc_overflow(const struct lib_ring_buffer_config *config,
-                     struct lib_ring_buffer *buf, u64 tsc)
+int last_timestamp_overflow(const struct lttng_kernel_ring_buffer_config *config,
+                     struct lttng_kernel_ring_buffer *buf, u64 timestamp)
 {
-       unsigned long tsc_shifted;
+       unsigned long timestamp_shifted;
 
-       if (config->tsc_bits == 0 || config->tsc_bits == 64)
+       if (config->timestamp_bits == 0 || config->timestamp_bits == 64)
                return 0;
 
-       tsc_shifted = (unsigned long)(tsc >> config->tsc_bits);
-       if (unlikely(tsc_shifted
-                    - (unsigned long)v_read(config, &buf->last_tsc)))
+       timestamp_shifted = (unsigned long)(timestamp >> config->timestamp_bits);
+       if (unlikely(timestamp_shifted
+                    - (unsigned long)v_read(config, &buf->last_timestamp)))
                return 1;
        else
                return 0;
 }
 #else
 static inline
-void save_last_tsc(const struct lib_ring_buffer_config *config,
-                  struct lib_ring_buffer *buf, u64 tsc)
+void save_last_timestamp(const struct lttng_kernel_ring_buffer_config *config,
+                  struct lttng_kernel_ring_buffer *buf, u64 timestamp)
 {
-       if (config->tsc_bits == 0 || config->tsc_bits == 64)
+       if (config->timestamp_bits == 0 || config->timestamp_bits == 64)
                return;
 
-       v_set(config, &buf->last_tsc, (unsigned long)tsc);
+       v_set(config, &buf->last_timestamp, (unsigned long)timestamp);
 }
 
 static inline
-int last_tsc_overflow(const struct lib_ring_buffer_config *config,
-                     struct lib_ring_buffer *buf, u64 tsc)
+int last_timestamp_overflow(const struct lttng_kernel_ring_buffer_config *config,
+                     struct lttng_kernel_ring_buffer *buf, u64 timestamp)
 {
-       if (config->tsc_bits == 0 || config->tsc_bits == 64)
+       if (config->timestamp_bits == 0 || config->timestamp_bits == 64)
                return 0;
 
-       if (unlikely((tsc - v_read(config, &buf->last_tsc))
-                    >> config->tsc_bits))
+       if (unlikely((timestamp - v_read(config, &buf->last_timestamp))
+                    >> config->timestamp_bits))
                return 1;
        else
                return 0;
@@ -138,29 +139,29 @@ int lib_ring_buffer_reserve_slow(struct lttng_kernel_ring_buffer_ctx *ctx,
                void *client_ctx);
 
 extern
-void lib_ring_buffer_switch_slow(struct lib_ring_buffer *buf,
+void lib_ring_buffer_switch_slow(struct lttng_kernel_ring_buffer *buf,
                                 enum switch_mode mode);
 
 extern
-void lib_ring_buffer_check_deliver_slow(const struct lib_ring_buffer_config *config,
-                                  struct lib_ring_buffer *buf,
+void lib_ring_buffer_check_deliver_slow(const struct lttng_kernel_ring_buffer_config *config,
+                                  struct lttng_kernel_ring_buffer *buf,
                                   struct lttng_kernel_ring_buffer_channel *chan,
                                   unsigned long offset,
                                   unsigned long commit_count,
                                   unsigned long idx,
-                                  u64 tsc);
+                                  const struct lttng_kernel_ring_buffer_ctx *ctx);
 
 extern
-void lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf);
+void lib_ring_buffer_switch_remote(struct lttng_kernel_ring_buffer *buf);
 extern
-void lib_ring_buffer_switch_remote_empty(struct lib_ring_buffer *buf);
+void lib_ring_buffer_switch_remote_empty(struct lttng_kernel_ring_buffer *buf);
 extern
-void lib_ring_buffer_clear(struct lib_ring_buffer *buf);
+void lib_ring_buffer_clear(struct lttng_kernel_ring_buffer *buf);
 
 /* Buffer write helpers */
 
 static inline
-void lib_ring_buffer_reserve_push_reader(struct lib_ring_buffer *buf,
+void lib_ring_buffer_reserve_push_reader(struct lttng_kernel_ring_buffer *buf,
                                         struct lttng_kernel_ring_buffer_channel *chan,
                                         unsigned long offset)
 {
@@ -197,10 +198,10 @@ void lib_ring_buffer_reserve_push_reader(struct lib_ring_buffer *buf,
  * algorithm guarantees.
  */
 static inline
-void lib_ring_buffer_clear_reader(struct lib_ring_buffer *buf,
+void lib_ring_buffer_clear_reader(struct lttng_kernel_ring_buffer *buf,
                                  struct lttng_kernel_ring_buffer_channel *chan)
 {
-       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       const struct lttng_kernel_ring_buffer_config *config = &chan->backend.config;
        unsigned long offset, consumed_old, consumed_new;
 
        do {
@@ -215,16 +216,16 @@ void lib_ring_buffer_clear_reader(struct lib_ring_buffer *buf,
 }
 
 static inline
-int lib_ring_buffer_pending_data(const struct lib_ring_buffer_config *config,
-                                struct lib_ring_buffer *buf,
+int lib_ring_buffer_pending_data(const struct lttng_kernel_ring_buffer_config *config,
+                                struct lttng_kernel_ring_buffer *buf,
                                 struct lttng_kernel_ring_buffer_channel *chan)
 {
        return !!subbuf_offset(v_read(config, &buf->offset), chan);
 }
 
 static inline
-unsigned long lib_ring_buffer_get_data_size(const struct lib_ring_buffer_config *config,
-                                           struct lib_ring_buffer *buf,
+unsigned long lib_ring_buffer_get_data_size(const struct lttng_kernel_ring_buffer_config *config,
+                                           struct lttng_kernel_ring_buffer *buf,
                                            unsigned long idx)
 {
        return subbuffer_get_data_size(config, &buf->backend, idx);
@@ -236,8 +237,8 @@ unsigned long lib_ring_buffer_get_data_size(const struct lib_ring_buffer_config
  * This is a very specific ftrace use-case, so we keep this as "internal" API.
  */
 static inline
-int lib_ring_buffer_reserve_committed(const struct lib_ring_buffer_config *config,
-                                     struct lib_ring_buffer *buf,
+int lib_ring_buffer_reserve_committed(const struct lttng_kernel_ring_buffer_config *config,
+                                     struct lttng_kernel_ring_buffer *buf,
                                      struct lttng_kernel_ring_buffer_channel *chan)
 {
        unsigned long offset, idx, commit_count;
@@ -264,20 +265,20 @@ int lib_ring_buffer_reserve_committed(const struct lib_ring_buffer_config *confi
 }
 
 /*
- * Receive end of subbuffer TSC as parameter. It has been read in the
+ * Receive end of subbuffer timestamp as parameter. It has been read in the
  * space reservation loop of either reserve or switch, which ensures it
  * progresses monotonically with event records in the buffer. Therefore,
  * it ensures that the end timestamp of a subbuffer is <= begin
  * timestamp of the following subbuffers.
  */
 static inline
-void lib_ring_buffer_check_deliver(const struct lib_ring_buffer_config *config,
-                                  struct lib_ring_buffer *buf,
+void lib_ring_buffer_check_deliver(const struct lttng_kernel_ring_buffer_config *config,
+                                  struct lttng_kernel_ring_buffer *buf,
                                   struct lttng_kernel_ring_buffer_channel *chan,
                                   unsigned long offset,
                                   unsigned long commit_count,
                                   unsigned long idx,
-                                  u64 tsc)
+                                  const struct lttng_kernel_ring_buffer_ctx *ctx)
 {
        unsigned long old_commit_count = commit_count
                                         - chan->backend.subbuf_size;
@@ -286,7 +287,7 @@ void lib_ring_buffer_check_deliver(const struct lib_ring_buffer_config *config,
        if (unlikely((buf_trunc(offset, chan) >> chan->backend.num_subbuf_order)
                     - (old_commit_count & chan->commit_count_mask) == 0))
                lib_ring_buffer_check_deliver_slow(config, buf, chan, offset,
-                       commit_count, idx, tsc);
+                       commit_count, idx, ctx);
 }
 
 /*
@@ -298,8 +299,8 @@ void lib_ring_buffer_check_deliver(const struct lib_ring_buffer_config *config,
  * useful for crash dump.
  */
 static inline
-void lib_ring_buffer_write_commit_counter(const struct lib_ring_buffer_config *config,
-                                         struct lib_ring_buffer *buf,
+void lib_ring_buffer_write_commit_counter(const struct lttng_kernel_ring_buffer_config *config,
+                                         struct lttng_kernel_ring_buffer *buf,
                                          struct lttng_kernel_ring_buffer_channel *chan,
                                          unsigned long buf_offset,
                                          unsigned long commit_count,
@@ -324,9 +325,9 @@ void lib_ring_buffer_write_commit_counter(const struct lib_ring_buffer_config *c
                v_set(config, &cc_hot->seq, commit_count);
 }
 
-extern int lib_ring_buffer_create(struct lib_ring_buffer *buf,
+extern int lib_ring_buffer_create(struct lttng_kernel_ring_buffer *buf,
                                  struct channel_backend *chanb, int cpu);
-extern void lib_ring_buffer_free(struct lib_ring_buffer *buf);
+extern void lib_ring_buffer_free(struct lttng_kernel_ring_buffer *buf);
 
 /* Keep track of trap nesting inside ring buffer code */
 DECLARE_PER_CPU(unsigned int, lib_ring_buffer_nesting);
This page took 0.027439 seconds and 4 git commands to generate.