From: Mathieu Desnoyers Date: Mon, 8 Nov 2021 20:48:01 +0000 (-0500) Subject: Refactoring: combine common code into lttng_sync_event_list X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d867a0dfd6665c1ea7c54c0b94c7e5d1432435f3;p=lttng-ust.git Refactoring: combine common code into lttng_sync_event_list Signed-off-by: Mathieu Desnoyers Change-Id: Ifd4c36c171e5dc39852cf03a47b3310faf590c49 --- diff --git a/src/lib/lttng-ust/lttng-events.c b/src/lib/lttng-ust/lttng-events.c index c42576f2..8904d77d 100644 --- a/src/lib/lttng-ust/lttng-events.c +++ b/src/lib/lttng-ust/lttng-events.c @@ -77,8 +77,7 @@ void lttng_session_lazy_sync_event_enablers(struct lttng_ust_session *session); static void lttng_session_sync_event_enablers(struct lttng_ust_session *session); static -void lttng_event_notifier_group_sync_enablers( - struct lttng_event_notifier_group *event_notifier_group); +void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group *event_notifier_group); static void lttng_event_enabler_sync(struct lttng_event_enabler_common *event_enabler); @@ -2126,18 +2125,14 @@ bool lttng_get_event_enabled_state(struct lttng_ust_event_common *event) } } - -/* - * lttng_session_sync_event_enablers should be called just before starting a - * session. - */ static -void lttng_session_sync_event_enablers(struct lttng_ust_session *session) +void lttng_sync_event_list(struct cds_list_head *event_enabler_list, + struct cds_list_head *event_list) { - struct lttng_event_enabler_common *event_enabler; struct lttng_ust_event_common_private *event_priv; + struct lttng_event_enabler_common *event_enabler; - cds_list_for_each_entry(event_enabler, &session->priv->enablers_head, node) + cds_list_for_each_entry(event_enabler, event_enabler_list, node) lttng_event_enabler_ref_events(event_enabler); /* @@ -2145,7 +2140,7 @@ void lttng_session_sync_event_enablers(struct lttng_ust_session *session) * and its channel and session transient states are enabled, we * enable the event, else we disable it. */ - cds_list_for_each_entry(event_priv, &session->priv->events_head, node) { + cds_list_for_each_entry(event_priv, event_list, node) { bool enabled = lttng_get_event_enabled_state(event_priv->pub); CMM_STORE_SHARED(event_priv->pub->enabled, enabled); @@ -2167,39 +2162,14 @@ void lttng_session_sync_event_enablers(struct lttng_ust_session *session) lttng_ust_tp_probe_prune_release_queue(); } +/* + * lttng_session_sync_event_enablers should be called just before starting a + * session. + */ static -void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group *event_notifier_group) +void lttng_session_sync_event_enablers(struct lttng_ust_session *session) { - struct lttng_event_enabler_common *event_enabler; - struct lttng_ust_event_common_private *event_priv; - - cds_list_for_each_entry(event_enabler, &event_notifier_group->enablers_head, node) - lttng_event_enabler_ref_events(event_enabler); - - /* - * For each event_notifier, if at least one of its enablers is enabled, - * we enable the event_notifier, else we disable it. - */ - cds_list_for_each_entry(event_priv, &event_notifier_group->event_notifiers_head, node) { - bool enabled = lttng_get_event_enabled_state(event_priv->pub); - - CMM_STORE_SHARED(event_priv->pub->enabled, enabled); - /* - * Sync tracepoint registration with event_notifier enabled - * state. - */ - if (enabled) { - if (!event_priv->registered) - register_event(event_priv->pub); - } else { - if (event_priv->registered) - unregister_event(event_priv->pub); - } - - lttng_event_sync_filter_state(event_priv->pub); - lttng_event_sync_capture_state(event_priv->pub); - } - lttng_ust_tp_probe_prune_release_queue(); + lttng_sync_event_list(&session->priv->enablers_head, &session->priv->events_head); } /* @@ -2217,6 +2187,12 @@ void lttng_session_lazy_sync_event_enablers(struct lttng_ust_session *session) lttng_session_sync_event_enablers(session); } +static +void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group *event_notifier_group) +{ + lttng_sync_event_list(&event_notifier_group->enablers_head, &event_notifier_group->event_notifiers_head); +} + static void lttng_event_enabler_sync(struct lttng_event_enabler_common *event_enabler) { @@ -2226,7 +2202,7 @@ void lttng_event_enabler_sync(struct lttng_event_enabler_common *event_enabler) { struct lttng_event_enabler_session_common *event_enabler_session = caa_container_of(event_enabler, struct lttng_event_enabler_session_common, parent); - lttng_session_lazy_sync_event_enablers(event_enabler_session->chan->session); + lttng_session_sync_event_enablers(event_enabler_session->chan->session); break; } case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER: