From 51f804ec315888553a0104fe691af89216c127e8 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Fri, 22 May 2020 18:02:06 -0400 Subject: [PATCH] bytecode: initialize all contexts on event notifier group creation Rename `lttng_session_context_init()` to `lttng_context_init_all()` so to reuse the code. Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers Change-Id: If80745677db993c1b38e158785886180d2e60d26 --- include/lttng/ust-events.h | 4 ++-- liblttng-ust/Makefile.am | 1 + liblttng-ust/context-internal.h | 32 ++++++++++++++++++++++++++++++++ liblttng-ust/lttng-context.c | 9 ++++++++- liblttng-ust/lttng-events.c | 9 ++++++++- 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 liblttng-ust/context-internal.h diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 41164ac3..4e3163c4 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -712,8 +712,6 @@ int lttng_channel_disable(struct lttng_channel *channel); int lttng_attach_context(struct lttng_ust_context *context_param, union ust_args *uargs, struct lttng_ctx **ctx, struct lttng_session *session); -int lttng_session_context_init(struct lttng_ctx **ctx); - void lttng_transport_register(struct lttng_transport *transport); void lttng_transport_unregister(struct lttng_transport *transport); @@ -850,6 +848,8 @@ int lttng_enabler_attach_exclusion(struct lttng_enabler *enabler, void lttng_enabler_event_link_bytecode(struct lttng_event *event, struct lttng_enabler *enabler); void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime); +int lttng_session_context_init(struct lttng_ctx **ctx); + #ifdef __cplusplus } diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am index bd05dfb8..98fb2153 100644 --- a/liblttng-ust/Makefile.am +++ b/liblttng-ust/Makefile.am @@ -60,6 +60,7 @@ liblttng_ust_runtime_la_SOURCES = \ lttng-ust-statedump-provider.h \ ust_lib.c \ ust_lib.h \ + context-internal.h \ context-provider-internal.h \ tracepoint-internal.h \ ust-events-internal.h \ diff --git a/liblttng-ust/context-internal.h b/liblttng-ust/context-internal.h new file mode 100644 index 00000000..79c88644 --- /dev/null +++ b/liblttng-ust/context-internal.h @@ -0,0 +1,32 @@ +#ifndef _LTTNG_UST_CONTEXT_INTERNAL_H +#define _LTTNG_UST_CONTEXT_INTERNAL_H + +/* + * ust-events-internal.h + * + * Copyright 2020 (c) - Francis Deslauriers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +int lttng_context_init_all(struct lttng_ctx **ctx); + +#endif /* _LTTNG_UST_CONTEXT_INTERNAL_H */ diff --git a/liblttng-ust/lttng-context.c b/liblttng-ust/lttng-context.c index fc564b6a..c457d3e1 100644 --- a/liblttng-ust/lttng-context.c +++ b/liblttng-ust/lttng-context.c @@ -31,6 +31,8 @@ #include #include +#include "context-internal.h" + /* * The filter implementation requires that two consecutive "get" for the * same context performed by the same thread return the same result. @@ -400,7 +402,7 @@ field_error: return ret; } -int lttng_session_context_init(struct lttng_ctx **ctx) +int lttng_context_init_all(struct lttng_ctx **ctx) { int ret; @@ -517,3 +519,8 @@ void lttng_context_init(void) void lttng_context_exit(void) { } + +int lttng_session_context_init(struct lttng_ctx **ctx) +{ + return 0; +} diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 5941365a..ac8b2b70 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -63,6 +63,7 @@ #include "lttng-tracer.h" #include "lttng-tracer-core.h" #include "lttng-ust-statedump.h" +#include "context-internal.h" #include "ust-events-internal.h" #include "wait.h" #include "../libringbuffer/shm.h" @@ -154,7 +155,7 @@ struct lttng_session *lttng_session_create(void) session = zmalloc(sizeof(struct lttng_session)); if (!session) return NULL; - if (lttng_session_context_init(&session->ctx)) { + if (lttng_context_init_all(&session->ctx)) { free(session); return NULL; } @@ -179,6 +180,12 @@ struct lttng_event_notifier_group *lttng_event_notifier_group_create(void) if (!event_notifier_group) return NULL; + /* Add all contexts. */ + if (lttng_context_init_all(&event_notifier_group->ctx)) { + free(event_notifier_group); + return NULL; + } + CDS_INIT_LIST_HEAD(&event_notifier_group->enablers_head); CDS_INIT_LIST_HEAD(&event_notifier_group->event_notifiers_head); for (i = 0; i < LTTNG_UST_EVENT_NOTIFIER_HT_SIZE; i++) -- 2.34.1