From: Mathieu Desnoyers Date: Wed, 3 Nov 2021 16:20:32 +0000 (-0400) Subject: Refactoring: combine common code into lttng_create_event_if_missing X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8839618b7286bd8d3da59ed3fe3831851ace3454;p=lttng-modules.git Refactoring: combine common code into lttng_create_event_if_missing Signed-off-by: Mathieu Desnoyers Change-Id: I9df1460471e3d9ce51ae0cba1b607493b5964acc --- diff --git a/src/lttng-events.c b/src/lttng-events.c index b9452e05..181fdefa 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -2201,20 +2201,19 @@ void lttng_create_syscall_event_if_missing(struct lttng_event_enabler_common *ev } /* - * Create struct lttng_kernel_event_recorder if it is missing and present in the list of - * tracepoint probes. + * Create event if it is missing and present in the list of tracepoint probes. * Should be called with sessions mutex held. */ static -void lttng_create_event_if_missing(struct lttng_event_recorder_enabler *event_enabler) +void lttng_create_event_if_missing(struct lttng_event_enabler_common *event_enabler) { - switch (event_enabler->parent.event_param.instrumentation) { + switch (event_enabler->event_param.instrumentation) { case LTTNG_KERNEL_ABI_TRACEPOINT: - lttng_create_tracepoint_event_if_missing(&event_enabler->parent); + lttng_create_tracepoint_event_if_missing(event_enabler); break; case LTTNG_KERNEL_ABI_SYSCALL: - lttng_create_syscall_event_if_missing(&event_enabler->parent); + lttng_create_syscall_event_if_missing(event_enabler); break; default: @@ -2251,7 +2250,7 @@ int lttng_event_enabler_ref_events(struct lttng_event_recorder_enabler *event_en } /* First ensure that probe events are created for this enabler. */ - lttng_create_event_if_missing(event_enabler); + 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, node) { @@ -2286,29 +2285,6 @@ int lttng_event_enabler_ref_events(struct lttng_event_recorder_enabler *event_en return 0; } -/* - * Create struct lttng_kernel_event_notifier if it is missing and present in the list of - * tracepoint probes. - * Should be called with sessions mutex held. - */ -static -void lttng_create_event_notifier_if_missing(struct lttng_event_notifier_enabler *event_notifier_enabler) -{ - switch (event_notifier_enabler->parent.event_param.instrumentation) { - case LTTNG_KERNEL_ABI_TRACEPOINT: - lttng_create_tracepoint_event_if_missing(&event_notifier_enabler->parent); - break; - - case LTTNG_KERNEL_ABI_SYSCALL: - lttng_create_syscall_event_if_missing(&event_notifier_enabler->parent); - break; - - default: - WARN_ON_ONCE(1); - break; - } -} - /* * Create event_notifiers associated with a event_notifier enabler (if not already present). */ @@ -2337,7 +2313,7 @@ int lttng_event_notifier_enabler_ref_event_notifiers( } /* First ensure that probe event_notifiers are created for this enabler. */ - lttng_create_event_notifier_if_missing(event_notifier_enabler); + 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, node) {