From: Mathieu Desnoyers Date: Mon, 10 Jan 2022 21:19:27 +0000 (-0500) Subject: Introduce struct lttng_event_enabler_session_common X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4a46ca395aca45e63cf5f06801ad6330a84ec97f;p=lttng-modules.git Introduce struct lttng_event_enabler_session_common Signed-off-by: Mathieu Desnoyers Change-Id: Ia160e559525f9276512506271742703804be6c9b --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index 59fc015f..79c8f8f0 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -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: diff --git a/src/lttng-abi.c b/src/lttng-abi.c index 06cb5324..afc024ed 100644 --- a/src/lttng-abi.c +++ b/src/lttng-abi.c @@ -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; diff --git a/src/lttng-events.c b/src/lttng-events.c index 73f591fd..3f19e834 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -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; } diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 827ca1d3..fb7b32e1 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -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;