From: Mathieu Desnoyers Date: Wed, 3 Nov 2021 18:59:51 +0000 (-0400) Subject: Refactoring: introduce list head from enabler getter X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=546cb5f29a6b43d6240f21a1a2d1a38b2919f966;p=lttng-modules.git Refactoring: introduce list head from enabler getter Signed-off-by: Mathieu Desnoyers Change-Id: Ib97b1063ccc63d2c1dbeb6f4ea204667afce9a1a --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index ee052dd1..21d887f0 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -614,6 +614,27 @@ struct lttng_event_ht *lttng_get_event_ht_from_enabler(struct lttng_event_enable } } +static inline +struct list_head *lttng_get_event_list_head_from_enabler(struct lttng_event_enabler_common *event_enabler) +{ + switch (event_enabler->enabler_type) { + case LTTNG_EVENT_ENABLER_TYPE_RECORDER: + { + struct lttng_event_recorder_enabler *event_recorder_enabler = + container_of(event_enabler, struct lttng_event_recorder_enabler, parent); + return &event_recorder_enabler->chan->parent.session->priv->events; + } + case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER: + { + struct lttng_event_notifier_enabler *event_notifier_enabler = + container_of(event_enabler, struct lttng_event_notifier_enabler, parent); + return &event_notifier_enabler->group->event_notifiers_head; + } + default: + return NULL; + } +} + int lttng_context_init(void); void lttng_context_exit(void); int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p, diff --git a/src/lttng-events.c b/src/lttng-events.c index 7f7748dc..fa151acf 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -2231,9 +2231,9 @@ static int lttng_event_enabler_ref_events(struct lttng_event_recorder_enabler *event_enabler) { struct lttng_kernel_channel_buffer *chan = event_enabler->chan; - struct lttng_kernel_session *session = event_enabler->chan->parent.session; struct lttng_event_enabler_common *base_enabler = lttng_event_recorder_enabler_as_enabler(event_enabler); struct lttng_kernel_event_recorder_private *event_recorder_priv; + struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(&event_enabler->parent); if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_ABI_SYSCALL && base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL && @@ -2253,7 +2253,7 @@ int lttng_event_enabler_ref_events(struct lttng_event_recorder_enabler *event_en lttng_create_event_if_missing(&event_enabler->parent); /* For each event matching event_enabler in session event list. */ - list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node) { + list_for_each_entry(event_recorder_priv, event_list_head, parent.node) { struct lttng_kernel_event_recorder *event_recorder = event_recorder_priv->pub; struct lttng_enabler_ref *enabler_ref; @@ -2295,6 +2295,7 @@ int lttng_event_notifier_enabler_ref_event_notifiers( struct lttng_event_notifier_group *event_notifier_group = event_notifier_enabler->group; struct lttng_event_enabler_common *base_enabler = lttng_event_notifier_enabler_as_enabler(event_notifier_enabler); struct lttng_kernel_event_notifier_private *event_notifier_priv; + struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(&event_notifier_enabler->parent); if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_ABI_SYSCALL && base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL && @@ -2316,7 +2317,7 @@ int lttng_event_notifier_enabler_ref_event_notifiers( lttng_create_event_if_missing(&event_notifier_enabler->parent); /* Link the created event_notifier with its associated enabler. */ - list_for_each_entry(event_notifier_priv, &event_notifier_group->event_notifiers_head, parent.node) { + list_for_each_entry(event_notifier_priv, event_list_head, parent.node) { struct lttng_kernel_event_notifier *event_notifier = event_notifier_priv->pub; struct lttng_enabler_ref *enabler_ref;