Cleanup: comment alignment in ring buffer config.h
[lttng-modules.git] / include / ringbuffer / config.h
index a17d22024ddc13f0374e6bb7c18ba6ba0b2eaa27..34f8a5da22e08935c659c8425d47e35184f1a2ff 100644 (file)
 #include <lttng/align.h>
 #include <lttng/tracer-core.h>
 
-struct lib_ring_buffer;
-struct channel;
-struct lib_ring_buffer_config;
-struct lib_ring_buffer_ctx;
+struct lttng_kernel_ring_buffer;
+struct lttng_kernel_ring_buffer_channel;
+struct lttng_kernel_ring_buffer_config;
+struct lttng_kernel_ring_buffer_ctx;
+struct lttng_kernel_ring_buffer_ctx_private;
 
 /*
  * Ring buffer client callbacks. Only used by slow path, never on fast path.
@@ -27,42 +28,42 @@ struct lib_ring_buffer_ctx;
  * provided as inline functions too.  These may simply return 0 if not used by
  * the client.
  */
-struct lib_ring_buffer_client_cb {
+struct lttng_kernel_ring_buffer_client_cb {
        /* Mandatory callbacks */
 
        /* A static inline version is also required for fast path */
-       u64 (*ring_buffer_clock_read) (struct channel *chan);
-       size_t (*record_header_size) (const struct lib_ring_buffer_config *config,
-                                     struct channel *chan, size_t offset,
+       u64 (*ring_buffer_clock_read) (struct lttng_kernel_ring_buffer_channel *chan);
+       size_t (*record_header_size) (const struct lttng_kernel_ring_buffer_config *config,
+                                     struct lttng_kernel_ring_buffer_channel *chan, size_t offset,
                                      size_t *pre_header_padding,
-                                     struct lib_ring_buffer_ctx *ctx,
+                                     struct lttng_kernel_ring_buffer_ctx *ctx,
                                      void *client_ctx);
 
        /* Slow path only, at subbuffer switch */
        size_t (*subbuffer_header_size) (void);
-       void (*buffer_begin) (struct lib_ring_buffer *buf, u64 tsc,
+       void (*buffer_begin) (struct lttng_kernel_ring_buffer *buf, u64 tsc,
                              unsigned int subbuf_idx);
-       void (*buffer_end) (struct lib_ring_buffer *buf, u64 tsc,
+       void (*buffer_end) (struct lttng_kernel_ring_buffer *buf, u64 tsc,
                            unsigned int subbuf_idx, unsigned long data_size);
 
        /* Optional callbacks (can be set to NULL) */
 
        /* Called at buffer creation/finalize */
-       int (*buffer_create) (struct lib_ring_buffer *buf, void *priv,
+       int (*buffer_create) (struct lttng_kernel_ring_buffer *buf, void *priv,
                              int cpu, const char *name);
        /*
         * Clients should guarantee that no new reader handle can be opened
         * after finalize.
         */
-       void (*buffer_finalize) (struct lib_ring_buffer *buf, void *priv, int cpu);
+       void (*buffer_finalize) (struct lttng_kernel_ring_buffer *buf, void *priv, int cpu);
 
        /*
         * Extract header length, payload length and timestamp from event
         * record. Used by buffer iterators. Timestamp is only used by channel
         * iterator.
         */
-       void (*record_get) (const struct lib_ring_buffer_config *config,
-                           struct channel *chan, struct lib_ring_buffer *buf,
+       void (*record_get) (const struct lttng_kernel_ring_buffer_config *config,
+                           struct lttng_kernel_ring_buffer_channel *chan, struct lttng_kernel_ring_buffer *buf,
                            size_t offset, size_t *header_len,
                            size_t *payload_len, u64 *timestamp);
 };
@@ -101,12 +102,14 @@ struct lib_ring_buffer_client_cb {
  *
  * RING_BUFFER_WAKEUP_BY_WRITER directly wakes up readers when a subbuffer is
  * ready to read. Lower latencies before the reader is woken up. Mainly suitable
- * for drivers.
+ * for drivers. Going through an "irq_work" allows triggering this type of wakeup
+ * even from NMI context: the wakeup will be slightly delayed until the next
+ * interrupts are handled.
  *
  * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
  * has the responsibility to perform wakeups.
  */
-struct lib_ring_buffer_config {
+struct lttng_kernel_ring_buffer_config {
        enum {
                RING_BUFFER_ALLOC_PER_CPU,
                RING_BUFFER_ALLOC_GLOBAL,
@@ -142,9 +145,8 @@ struct lib_ring_buffer_config {
        enum {
                RING_BUFFER_WAKEUP_BY_TIMER,    /* wake up performed by timer */
                RING_BUFFER_WAKEUP_BY_WRITER,   /*
-                                                * writer wakes up reader,
-                                                * not lock-free
-                                                * (takes spinlock).
+                                                * writer wakes up reader through
+                                                * irq_work.
                                                 */
        } wakeup;
        /*
@@ -152,7 +154,41 @@ struct lib_ring_buffer_config {
         *   0 and 64 disable the timestamp compression scheme.
         */
        unsigned int tsc_bits;
-       struct lib_ring_buffer_client_cb cb;
+       struct lttng_kernel_ring_buffer_client_cb cb;
+};
+
+/*
+ * ring buffer private context
+ *
+ * Private context passed to lib_ring_buffer_reserve(), lib_ring_buffer_commit(),
+ * lib_ring_buffer_try_discard_reserve(), lib_ring_buffer_align_ctx() and
+ * lib_ring_buffer_write().
+ *
+ * Get struct lttng_kernel_ring_buffer_ctx parent with container_of().
+ */
+
+struct lttng_kernel_ring_buffer_ctx_private {
+       /* input received by lib_ring_buffer_reserve(). */
+       struct lttng_kernel_ring_buffer_channel *chan;                  /* ring buffer channel */
+
+       /* output from lib_ring_buffer_reserve() */
+       int reserve_cpu;                        /* processor id updated by the reserve */
+       size_t slot_size;                       /* size of the reserved slot */
+       unsigned long buf_offset;               /* offset following the record header */
+       unsigned long pre_offset;               /*
+                                                * Initial offset position _before_
+                                                * the record is written. Positioned
+                                                * prior to record header alignment
+                                                * padding.
+                                                */
+       u64 tsc;                                /* time-stamp counter value */
+       unsigned int rflags;                    /* reservation flags */
+
+       struct lttng_kernel_ring_buffer *buf;   /*
+                                                * buffer corresponding to processor id
+                                                * for this channel
+                                                */
+       struct lttng_kernel_ring_buffer_backend_pages *backend_pages;
 };
 
 /*
@@ -162,58 +198,38 @@ struct lib_ring_buffer_config {
  * lib_ring_buffer_try_discard_reserve(), lib_ring_buffer_align_ctx() and
  * lib_ring_buffer_write().
  */
-struct lib_ring_buffer_ctx {
+struct lttng_kernel_ring_buffer_ctx {
+       /* Private ring buffer context, set by reserve callback. */
+       struct lttng_kernel_ring_buffer_ctx_private priv;
+
        /* input received by lib_ring_buffer_reserve(), saved here. */
-       struct channel *chan;           /* channel */
-       void *priv;                     /* client private data */
+       void *client_priv;              /* Ring buffer client private data */
+
        size_t data_size;               /* size of payload */
        int largest_align;              /*
                                         * alignment of the largest element
                                         * in the payload
                                         */
-       int cpu;                        /* processor id */
-
-       /* output from lib_ring_buffer_reserve() */
-       struct lib_ring_buffer *buf;    /*
-                                        * buffer corresponding to processor id
-                                        * for this channel
-                                        */
-       size_t slot_size;               /* size of the reserved slot */
-       unsigned long buf_offset;       /* offset following the record header */
-       unsigned long pre_offset;       /*
-                                        * Initial offset position _before_
-                                        * the record is written. Positioned
-                                        * prior to record header alignment
-                                        * padding.
-                                        */
-       u64 tsc;                        /* time-stamp counter value */
-       unsigned int rflags;            /* reservation flags */
-       /* Cache backend pages pointer chasing. */
-       struct lib_ring_buffer_backend_pages *backend_pages;
+       struct lttng_kernel_probe_ctx *probe_ctx;       /* Probe context */
 };
 
 /**
  * lib_ring_buffer_ctx_init - initialize ring buffer context
  * @ctx: ring buffer context to initialize
- * @chan: channel
- * @priv: client private data
+ * @client_priv: client private data
  * @data_size: size of record data payload. It must be greater than 0.
  * @largest_align: largest alignment within data payload types
- * @cpu: processor id
  */
 static inline
-void lib_ring_buffer_ctx_init(struct lib_ring_buffer_ctx *ctx,
-                             struct channel *chan, void *priv,
+void lib_ring_buffer_ctx_init(struct lttng_kernel_ring_buffer_ctx *ctx,
+                             void *client_priv,
                              size_t data_size, int largest_align,
-                             int cpu)
+                             struct lttng_kernel_probe_ctx *probe_ctx)
 {
-       ctx->chan = chan;
-       ctx->priv = priv;
+       ctx->client_priv = client_priv;
        ctx->data_size = data_size;
        ctx->largest_align = largest_align;
-       ctx->cpu = cpu;
-       ctx->rflags = 0;
-       ctx->backend_pages = NULL;
+       ctx->probe_ctx = probe_ctx;
 }
 
 /*
@@ -278,10 +294,10 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
  * @ctx: ring buffer context.
  */
 static inline
-void lib_ring_buffer_align_ctx(struct lib_ring_buffer_ctx *ctx,
+void lib_ring_buffer_align_ctx(struct lttng_kernel_ring_buffer_ctx *ctx,
                           size_t alignment)
 {
-       ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
+       ctx->priv.buf_offset += lib_ring_buffer_align(ctx->priv.buf_offset,
                                                 alignment);
 }
 
@@ -290,7 +306,7 @@ void lib_ring_buffer_align_ctx(struct lib_ring_buffer_ctx *ctx,
  * Used internally to check for valid configurations at channel creation.
  */
 static inline
-int lib_ring_buffer_check_config(const struct lib_ring_buffer_config *config,
+int lib_ring_buffer_check_config(const struct lttng_kernel_ring_buffer_config *config,
                             unsigned int switch_timer_interval,
                             unsigned int read_timer_interval)
 {
This page took 0.026139 seconds and 4 git commands to generate.