Introduce struct lttng_event_enabler_session_common
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 10 Jan 2022 21:19:27 +0000 (16:19 -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: Ia160e559525f9276512506271742703804be6c9b

include/lttng/events-internal.h
src/lttng-abi.c
src/lttng-events.c
src/lttng-syscalls.c

index 59fc015f62f76c8925998764b3aa3878ccfb1e57..79c8f8f062fcf520bddb8796afc35c4d13d62d11 100644 (file)
@@ -275,8 +275,13 @@ struct lttng_event_enabler_common {
        bool published;                 /* published in list. */
 };
 
-struct lttng_event_recorder_enabler {
+struct lttng_event_enabler_session_common {
        struct lttng_event_enabler_common parent;
+       struct lttng_kernel_channel_common *chan;
+};
+
+struct lttng_event_recorder_enabler {
+       struct lttng_event_enabler_session_common parent;
        struct lttng_kernel_channel_buffer *chan;
 };
 
@@ -612,13 +617,6 @@ int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *
                struct lttng_kernel_probe_ctx *probe_ctx,
                void *event_filter_ctx);
 
-static inline
-struct lttng_event_enabler_common *lttng_event_recorder_enabler_as_enabler(
-               struct lttng_event_recorder_enabler *event_recorder_enabler)
-{
-       return &event_recorder_enabler->parent;
-}
-
 static inline
 struct lttng_event_enabler_common *lttng_event_notifier_enabler_as_enabler(
                struct lttng_event_notifier_enabler *event_notifier_enabler)
@@ -633,7 +631,7 @@ struct lttng_event_ht *lttng_get_event_ht_from_enabler(struct lttng_event_enable
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                return &event_recorder_enabler->chan->parent.session->priv->events_ht;
        }
        case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
@@ -654,7 +652,7 @@ struct list_head *lttng_get_event_list_head_from_enabler(struct lttng_event_enab
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                return &event_recorder_enabler->chan->parent.session->priv->events;
        }
        case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
index 06cb53249cd04a902fc7f596f9b7114305e97040..afc024ed60290cc6e4f13d764da121691758193d 100644 (file)
@@ -1931,9 +1931,9 @@ int lttng_abi_create_event(struct file *channel_file,
                 * We tolerate no failure path after event creation. It
                 * will stay invariant for the rest of the session.
                 */
-               event = lttng_kernel_event_create(&event_enabler->parent, NULL);
+               event = lttng_kernel_event_create(&event_enabler->parent.parent, NULL);
                WARN_ON_ONCE(IS_ERR(event));
-               lttng_event_enabler_destroy(&event_enabler->parent);
+               lttng_event_enabler_destroy(&event_enabler->parent.parent);
                if (IS_ERR(event)) {
                        ret = PTR_ERR(event);
                        goto event_error;
@@ -2722,12 +2722,12 @@ long lttng_event_recorder_enabler_ioctl(struct file *file, unsigned int cmd, uns
        }
        case LTTNG_KERNEL_ABI_OLD_ENABLE:
        case LTTNG_KERNEL_ABI_ENABLE:
-               return lttng_event_enabler_enable(&event_enabler->parent);
+               return lttng_event_enabler_enable(&event_enabler->parent.parent);
        case LTTNG_KERNEL_ABI_OLD_DISABLE:
        case LTTNG_KERNEL_ABI_DISABLE:
-               return lttng_event_enabler_disable(&event_enabler->parent);
+               return lttng_event_enabler_disable(&event_enabler->parent.parent);
        case LTTNG_KERNEL_ABI_FILTER:
-               return lttng_event_enabler_attach_filter_bytecode(&event_enabler->parent,
+               return lttng_event_enabler_attach_filter_bytecode(&event_enabler->parent.parent,
                        (struct lttng_kernel_abi_filter_bytecode __user *) arg);
        case LTTNG_KERNEL_ABI_ADD_CALLSITE:
                return -EINVAL;
index 73f591fd9e56702ac2d73c9ae10a8c6069408735..3f19e834ad259137685fe3565a229d070a3f3498 100644 (file)
@@ -869,7 +869,7 @@ bool lttng_kernel_event_id_available(struct lttng_event_enabler_common *event_en
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                struct lttng_kernel_channel_buffer *chan = event_recorder_enabler->chan;
 
                switch (itype) {
@@ -911,7 +911,7 @@ struct lttng_kernel_event_common *lttng_kernel_event_alloc(struct lttng_event_en
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                struct lttng_kernel_event_recorder *event_recorder;
                struct lttng_kernel_event_recorder_private *event_recorder_priv;
                struct lttng_kernel_channel_buffer *chan = event_recorder_enabler->chan;
@@ -1936,7 +1936,7 @@ bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_en
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                struct lttng_kernel_event_recorder *event_recorder =
                        container_of(event, struct lttng_kernel_event_recorder, parent);
 
@@ -1977,7 +1977,7 @@ bool lttng_event_enabler_desc_match_event(struct lttng_event_enabler_common *eve
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                struct lttng_kernel_event_recorder *event_recorder =
                        container_of(event, struct lttng_kernel_event_recorder, parent);
 
@@ -2017,7 +2017,7 @@ bool lttng_event_enabler_event_name_match_event(struct lttng_event_enabler_commo
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                struct lttng_kernel_event_recorder *event_recorder =
                        container_of(event, struct lttng_kernel_event_recorder, parent);
 
@@ -2272,14 +2272,16 @@ struct lttng_event_recorder_enabler *lttng_event_recorder_enabler_create(
        event_enabler = kzalloc(sizeof(*event_enabler), GFP_KERNEL);
        if (!event_enabler)
                return NULL;
-       event_enabler->parent.enabler_type = LTTNG_EVENT_ENABLER_TYPE_RECORDER;
-       event_enabler->parent.format_type = format_type;
-       INIT_LIST_HEAD(&event_enabler->parent.filter_bytecode_head);
-       memcpy(&event_enabler->parent.event_param, event_param,
-               sizeof(event_enabler->parent.event_param));
+       event_enabler->parent.parent.enabler_type = LTTNG_EVENT_ENABLER_TYPE_RECORDER;
+       event_enabler->parent.parent.format_type = format_type;
+       INIT_LIST_HEAD(&event_enabler->parent.parent.filter_bytecode_head);
+       memcpy(&event_enabler->parent.parent.event_param, event_param,
+               sizeof(event_enabler->parent.parent.event_param));
        event_enabler->chan = chan;
+       event_enabler->parent.chan = &chan->parent;
+
        /* ctx left NULL */
-       event_enabler->parent.enabled = 0;
+       event_enabler->parent.parent.enabled = 0;
        return event_enabler;
 }
 
@@ -2287,8 +2289,8 @@ void lttng_event_enabler_session_add(struct lttng_kernel_session *session,
                struct lttng_event_recorder_enabler *event_enabler)
 {
        mutex_lock(&sessions_mutex);
-       list_add(&event_enabler->parent.node, &session->priv->enablers_head);
-       event_enabler->parent.published = true;
+       list_add(&event_enabler->parent.parent.node, &session->priv->enablers_head);
+       event_enabler->parent.parent.published = true;
        lttng_session_lazy_sync_event_enablers(session);
        mutex_unlock(&sessions_mutex);
 }
@@ -2392,7 +2394,7 @@ void lttng_event_enabler_destroy(struct lttng_event_enabler_common *event_enable
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
 
                kfree(event_recorder_enabler);
                break;
@@ -2682,7 +2684,7 @@ void lttng_event_enabler_sync(struct lttng_event_enabler_common *event_enabler)
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                lttng_session_lazy_sync_event_enablers(event_recorder_enabler->chan->parent.session);
                break;
        }
index 827ca1d3848baa75daad3a6b7c4b0aa89a571376..fb7b32e150a9ca4a4c72637c20cde7643f39780f 100644 (file)
@@ -494,7 +494,7 @@ struct lttng_kernel_syscall_table *get_syscall_table_from_enabler(struct lttng_e
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *event_recorder_enabler =
-                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                return &event_recorder_enabler->chan->priv->parent.syscall_table;
        }
        case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
@@ -539,7 +539,7 @@ void lttng_syscall_event_enabler_create_event(struct lttng_event_enabler_common
        case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
        {
                struct lttng_event_recorder_enabler *syscall_event_recorder_enabler =
-                       container_of(syscall_event_enabler, struct lttng_event_recorder_enabler, parent);
+                       container_of(syscall_event_enabler, struct lttng_event_recorder_enabler, parent.parent);
                struct lttng_event_recorder_enabler *event_recorder_enabler;
                struct lttng_kernel_abi_event ev;
 
@@ -571,9 +571,9 @@ void lttng_syscall_event_enabler_create_event(struct lttng_event_enabler_common
                WARN_ON_ONCE(!event_recorder_enabler);
                if (!event_recorder_enabler)
                        return;
-               event = _lttng_kernel_event_create(&event_recorder_enabler->parent, desc);
+               event = _lttng_kernel_event_create(&event_recorder_enabler->parent.parent, desc);
                WARN_ON_ONCE(IS_ERR(event));
-               lttng_event_enabler_destroy(&event_recorder_enabler->parent);
+               lttng_event_enabler_destroy(&event_recorder_enabler->parent.parent);
                if (IS_ERR(event)) {
                        printk(KERN_INFO "Unable to create event recorder %s\n", desc->event_name);
                        return;
This page took 0.033363 seconds and 4 git commands to generate.