X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=include%2Fringbuffer%2Fconfig.h;h=4ce36d18c9fa4af35ec633208616239396cdb51d;hb=8a57ec025ffbe56153748fd69b60118862707182;hp=2019e14cbf4052c1789689c77e3bb59d24169a33;hpb=a775608d0d1d6142c80c26b21ff79bf7e04d8e53;p=lttng-modules.git diff --git a/include/ringbuffer/config.h b/include/ringbuffer/config.h index 2019e14c..4ce36d18 100644 --- a/include/ringbuffer/config.h +++ b/include/ringbuffer/config.h @@ -19,7 +19,8 @@ struct lib_ring_buffer; struct channel; struct lib_ring_buffer_config; -struct lib_ring_buffer_ctx; +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. @@ -35,7 +36,7 @@ struct lib_ring_buffer_client_cb { size_t (*record_header_size) (const struct lib_ring_buffer_config *config, struct 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 */ @@ -156,6 +157,40 @@ struct lib_ring_buffer_config { struct lib_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 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 lib_ring_buffer *buf; /* + * buffer corresponding to processor id + * for this channel + */ + struct lib_ring_buffer_backend_pages *backend_pages; +}; + /* * ring buffer context * @@ -163,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 lib_ring_buffer_ctx_init(struct lttng_kernel_ring_buffer_ctx *ctx, + void *client_priv, size_t data_size, int largest_align, - int cpu, void *priv) + 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; } /* @@ -279,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); }