Introduce struct lttng_kernel_event_session_common_private
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 10 Jan 2022 21:31:34 +0000 (16:31 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 15 Jul 2024 20:58:48 +0000 (16:58 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibaab6a0a8ce60bbc5ac212106c5c75a8a16d7e2c

include/lttng/events-internal.h
src/lttng-events.c
src/lttng-ring-buffer-client.h
src/probes/lttng-kprobes.c

index 79c8f8f062fcf520bddb8796afc35c4d13d62d11..7210f3caf8447cee26451147e97dd0e7ab9815e5 100644 (file)
@@ -100,12 +100,18 @@ struct lttng_kernel_event_common_private {
        } u;
 };
 
-struct lttng_kernel_event_recorder_private {
+struct lttng_kernel_event_session_common_private {
        struct lttng_kernel_event_common_private parent;
 
-       struct lttng_kernel_event_recorder *pub;        /* Public event interface */
        struct lttng_kernel_ctx *ctx;
-       unsigned int id;
+       struct lttng_kernel_channel_common *chan;
+       uint64_t id;                                    /* Event id */
+};
+
+struct lttng_kernel_event_recorder_private {
+       struct lttng_kernel_event_session_common_private parent;
+
+       struct lttng_kernel_event_recorder *pub;        /* Public event interface */
        unsigned int metadata_dumped:1;
 };
 
index 3f19e834ad259137685fe3565a229d070a3f3498..6ac97be576d2207b5cc9335845638c2e0df99def 100644 (file)
@@ -359,7 +359,7 @@ void lttng_session_destroy(struct lttng_kernel_session *session)
                ret = lttng_syscalls_unregister_syscall_table(&chan_priv->parent.syscall_table);
                WARN_ON(ret);
        }
-       list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node)
+       list_for_each_entry(event_recorder_priv, &session->priv->events, parent.parent.node)
                _lttng_event_unregister(&event_recorder_priv->pub->parent);
        synchronize_trace();    /* Wait for in-flight events to complete */
        list_for_each_entry(chan_priv, &session->priv->chan, node) {
@@ -368,7 +368,7 @@ void lttng_session_destroy(struct lttng_kernel_session *session)
        }
        list_for_each_entry_safe(event_enabler, tmp_event_enabler, &session->priv->enablers_head, node)
                lttng_event_enabler_destroy(event_enabler);
-       list_for_each_entry_safe(event_recorder_priv, tmpevent_recorder_priv, &session->priv->events, parent.node)
+       list_for_each_entry_safe(event_recorder_priv, tmpevent_recorder_priv, &session->priv->events, parent.parent.node)
                _lttng_event_destroy(&event_recorder_priv->pub->parent);
        list_for_each_entry_safe(chan_priv, tmpchan_priv, &session->priv->chan, node) {
                BUG_ON(chan_priv->channel_type == METADATA_CHANNEL);
@@ -559,7 +559,7 @@ int lttng_session_metadata_regenerate(struct lttng_kernel_session *session)
                chan_priv->metadata_dumped = 0;
        }
 
-       list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node) {
+       list_for_each_entry(event_recorder_priv, &session->priv->events, parent.parent.node) {
                event_recorder_priv->metadata_dumped = 0;
        }
 
@@ -925,18 +925,19 @@ struct lttng_kernel_event_common *lttng_kernel_event_alloc(struct lttng_event_en
                        return NULL;
                }
                event_recorder_priv->pub = event_recorder;
-               event_recorder_priv->parent.pub = &event_recorder->parent;
+               event_recorder_priv->parent.parent.pub = &event_recorder->parent;
                event_recorder->priv = event_recorder_priv;
-               event_recorder->parent.priv = &event_recorder_priv->parent;
+               event_recorder->parent.priv = &event_recorder_priv->parent.parent;
 
                event_recorder->parent.type = LTTNG_KERNEL_EVENT_TYPE_RECORDER;
                event_recorder->parent.run_filter = lttng_kernel_interpret_event_filter;
-               event_recorder->priv->parent.instrumentation = itype;
-               INIT_LIST_HEAD(&event_recorder->priv->parent.filter_bytecode_runtime_head);
-               INIT_LIST_HEAD(&event_recorder->priv->parent.enablers_ref_head);
+               event_recorder->priv->parent.parent.instrumentation = itype;
+               INIT_LIST_HEAD(&event_recorder->priv->parent.parent.filter_bytecode_runtime_head);
+               INIT_LIST_HEAD(&event_recorder->priv->parent.parent.enablers_ref_head);
 
                event_recorder->chan = chan;
-               event_recorder->priv->id = chan->priv->free_event_id++;
+               event_recorder->priv->parent.chan = &chan->parent;
+               event_recorder->priv->parent.id = chan->priv->free_event_id++;
                return &event_recorder->parent;
        }
        case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
@@ -1500,7 +1501,7 @@ void _lttng_event_destroy(struct lttng_kernel_event_common *event)
                default:
                        WARN_ON_ONCE(1);
                }
-               list_del(&event_recorder->priv->parent.node);
+               list_del(&event_recorder->priv->parent.parent.node);
                kmem_cache_free(event_recorder_private_cache, event_recorder->priv);
                kmem_cache_free(event_recorder_cache, event_recorder);
                break;
@@ -3450,7 +3451,7 @@ int _lttng_fields_metadata_statedump(struct lttng_kernel_session *session,
                                   struct lttng_kernel_event_recorder *event_recorder)
 {
        const char *prev_field_name = NULL;
-       const struct lttng_kernel_event_desc *desc = event_recorder->priv->parent.desc;
+       const struct lttng_kernel_event_desc *desc = event_recorder->priv->parent.parent.desc;
        int ret = 0;
        int i;
 
@@ -3493,10 +3494,10 @@ int _lttng_event_recorder_metadata_statedump(struct lttng_kernel_event_common *e
        ret = lttng_metadata_printf(session,
                "event {\n"
                "       name = \"%s\";\n"
-               "       id = %u;\n"
+               "       id = %llu;\n"
                "       stream_id = %u;\n",
-               event_recorder->priv->parent.desc->event_name,
-               event_recorder->priv->id,
+               event_recorder->priv->parent.parent.desc->event_name,
+               event_recorder->priv->parent.id,
                event_recorder->chan->priv->id);
        if (ret)
                goto end;
@@ -3928,7 +3929,7 @@ skip_session:
                        goto end;
        }
 
-       list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node) {
+       list_for_each_entry(event_recorder_priv, &session->priv->events, parent.parent.node) {
                ret = _lttng_event_recorder_metadata_statedump(&event_recorder_priv->pub->parent);
                if (ret)
                        goto end;
index a1753e986ae3fd68582cdc29e0c7b48a9329a5a6..40afa1f1cd7c9fd9f614afdbfbaf2a33b9c5bf9c 100644 (file)
@@ -616,7 +616,7 @@ int lttng_event_reserve(struct lttng_kernel_ring_buffer_ctx *ctx)
        cpu = lib_ring_buffer_get_cpu(&client_config);
        if (unlikely(cpu < 0))
                return -EPERM;
-       event_id = event_recorder->priv->id;
+       event_id = (uint32_t)event_recorder->priv->parent.id;
        memset(&ctx->priv, 0, sizeof(ctx->priv));
        ctx->priv.chan = lttng_chan->priv->rb_chan;
        ctx->priv.reserve_cpu = cpu;
index 27d2898f971926857cb37f9d8c7040c4cf6bf66a..20d7877314873bb70d7bef37745befe5d3d2fd76 100644 (file)
@@ -33,10 +33,8 @@ int lttng_kprobes_event_handler_pre(struct kprobe *p, struct pt_regs *regs)
        switch (event->type) {
        case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
        {
-               struct lttng_kernel_event_recorder_private *event_recorder_priv =
-                       container_of(event_priv, struct lttng_kernel_event_recorder_private, parent);
                struct lttng_kernel_event_recorder *event_recorder =
-                       event_recorder_priv->pub;
+                       container_of(event, struct lttng_kernel_event_recorder, parent);
                struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
 
                if (unlikely(!LTTNG_READ_ONCE(chan->parent.session->active)))
This page took 0.032481 seconds and 4 git commands to generate.