X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttng-ring-buffer-client.h;h=aad7955f8accfcdea845b14858b431adab3cf69c;hb=2bc89292c6ac6030a7498a798671cca921ae61df;hp=48d304293b95c4f7baa84ee44784810928f1ce77;hpb=cc62f29ec5d5149ae6dba1a9acb538e06da07a94;p=lttng-modules.git diff --git a/lttng-ring-buffer-client.h b/lttng-ring-buffer-client.h index 48d30429..aad7955f 100644 --- a/lttng-ring-buffer-client.h +++ b/lttng-ring-buffer-client.h @@ -1,33 +1,20 @@ -/* +/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) + * * lttng-ring-buffer-client.h * * LTTng lib ring buffer client template. * * Copyright (C) 2010-2012 Mathieu Desnoyers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; only - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include -#include -#include /* for wrapper_vmalloc_sync_all() */ +#include +#include /* for wrapper_vmalloc_sync_mappings() */ #include -#include -#include -#include +#include +#include +#include #define LTTNG_COMPACT_EVENT_BITS 5 #define LTTNG_COMPACT_TSC_BITS 27 @@ -100,7 +87,8 @@ size_t ctx_get_aligned_size(size_t offset, struct lttng_ctx *ctx, } static inline -void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len) +void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len, + struct lttng_channel *chan, struct lib_ring_buffer_ctx *bufctx) { int i; size_t offset = 0; @@ -109,8 +97,13 @@ void ctx_get_struct_size(struct lttng_ctx *ctx, size_t *ctx_len) *ctx_len = 0; return; } - for (i = 0; i < ctx->nr_fields; i++) - offset += ctx->fields[i].get_size(offset); + for (i = 0; i < ctx->nr_fields; i++) { + if (ctx->fields[i].get_size) + offset += ctx->fields[i].get_size(offset); + if (ctx->fields[i].get_size_arg) + offset += ctx->fields[i].get_size_arg(offset, + &ctx->fields[i], bufctx, chan); + } *ctx_len = offset; } @@ -198,7 +191,7 @@ size_t record_header_size(const struct lib_ring_buffer_config *config, return offset - orig_offset; } -#include +#include static void lttng_write_event_header_slow(const struct lib_ring_buffer_config *config, @@ -486,9 +479,10 @@ static int client_stream_id(const struct lib_ring_buffer_config *config, struct lib_ring_buffer *buf, uint64_t *stream_id) { - struct packet_header *header = client_packet_header(config, buf); - *stream_id = header->stream_id; + struct channel *chan = buf->backend.chan; + struct lttng_channel *lttng_chan = channel_get_private(chan); + *stream_id = lttng_chan->id; return 0; } @@ -517,8 +511,7 @@ int client_instance_id(const struct lib_ring_buffer_config *config, struct lib_ring_buffer *buf, uint64_t *id) { - struct packet_header *header = client_packet_header(config, buf); - *id = header->stream_instance_id; + *id = buf->backend.cpu; return 0; } @@ -630,15 +623,15 @@ int lttng_event_reserve(struct lib_ring_buffer_ctx *ctx, struct lttng_client_ctx client_ctx; int ret, cpu; - /* Compute internal size of context structures. */ - ctx_get_struct_size(lttng_chan->ctx, &client_ctx.packet_context_len); - ctx_get_struct_size(event->ctx, &client_ctx.event_context_len); - cpu = lib_ring_buffer_get_cpu(&client_config); if (unlikely(cpu < 0)) return -EPERM; ctx->cpu = cpu; + /* Compute internal size of context structures. */ + ctx_get_struct_size(lttng_chan->ctx, &client_ctx.packet_context_len, lttng_chan, ctx); + ctx_get_struct_size(event->ctx, &client_ctx.event_context_len, lttng_chan, ctx); + switch (lttng_chan->header_type) { case 1: /* compact */ if (event_id > 30) @@ -773,7 +766,7 @@ static int __init lttng_ring_buffer_client_init(void) * This vmalloc sync all also takes care of the lib ring buffer * vmalloc'd module pages when it is built as a module into LTTng. */ - wrapper_vmalloc_sync_all(); + wrapper_vmalloc_sync_mappings(); lttng_transport_register(<tng_relay_transport); return 0; } @@ -788,6 +781,10 @@ static void __exit lttng_ring_buffer_client_exit(void) module_exit(lttng_ring_buffer_client_exit); MODULE_LICENSE("GPL and additional rights"); -MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_AUTHOR("Mathieu Desnoyers "); MODULE_DESCRIPTION("LTTng ring buffer " RING_BUFFER_MODE_TEMPLATE_STRING " client"); +MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "." + __stringify(LTTNG_MODULES_MINOR_VERSION) "." + __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION) + LTTNG_MODULES_EXTRAVERSION);