strcat(name, desc->event_name);
}
+static
+void lttng_event_enabler_unsync(struct lttng_event_enabler *event_enabler)
+{
+ cds_list_move(&event_enabler->node,
+ &event_enabler->chan->parent->session->priv->unsync_enablers_head);
+}
+
+static
+void lttng_session_unsync_enablers(struct lttng_ust_session *session)
+{
+ cds_list_splice(&session->priv->sync_enablers_head,
+ &session->priv->unsync_enablers_head);
+ CDS_INIT_LIST_HEAD(&session->priv->sync_enablers_head);
+}
+
+static
+void lttng_event_notifier_enabler_unsync(struct lttng_event_notifier_enabler *event_notifier_enabler)
+{
+ cds_list_move(&event_notifier_enabler->node,
+ &event_notifier_enabler->group->unsync_enablers_head);
+}
+
+static
+void lttng_event_notifier_group_unsync_enablers(struct lttng_event_notifier_group *event_notifier_group)
+{
+ cds_list_splice(&event_notifier_group->sync_enablers_head,
+ &event_notifier_group->unsync_enablers_head);
+ CDS_INIT_LIST_HEAD(&event_notifier_group->sync_enablers_head);
+}
+
/*
* Called with ust lock held.
*/
CDS_INIT_LIST_HEAD(&session->priv->chan_head);
CDS_INIT_LIST_HEAD(&session->priv->events_head);
CDS_INIT_LIST_HEAD(&session->priv->enums_head);
- CDS_INIT_LIST_HEAD(&session->priv->enablers_head);
+ CDS_INIT_LIST_HEAD(&session->priv->unsync_enablers_head);
+ CDS_INIT_LIST_HEAD(&session->priv->sync_enablers_head);
for (i = 0; i < LTTNG_UST_EVENT_HT_SIZE; i++)
CDS_INIT_HLIST_HEAD(&session->priv->events_ht.table[i]);
for (i = 0; i < LTTNG_UST_ENUM_HT_SIZE; i++)
return NULL;
}
- CDS_INIT_LIST_HEAD(&event_notifier_group->enablers_head);
+ CDS_INIT_LIST_HEAD(&event_notifier_group->sync_enablers_head);
+ CDS_INIT_LIST_HEAD(&event_notifier_group->unsync_enablers_head);
CDS_INIT_LIST_HEAD(&event_notifier_group->event_notifiers_head);
for (i = 0; i < LTTNG_UST_EVENT_NOTIFIER_HT_SIZE; i++)
CDS_INIT_HLIST_HEAD(&event_notifier_group->event_notifiers_ht.table[i]);
lttng_ust_urcu_synchronize_rcu(); /* Wait for in-flight events to complete */
lttng_ust_tp_probe_prune_release_queue();
cds_list_for_each_entry_safe(event_enabler, event_tmpenabler,
- &session->priv->enablers_head, node)
+ &session->priv->unsync_enablers_head, node)
+ lttng_event_enabler_destroy(event_enabler);
+ cds_list_for_each_entry_safe(event_enabler, event_tmpenabler,
+ &session->priv->sync_enablers_head, node)
lttng_event_enabler_destroy(event_enabler);
cds_list_for_each_entry_safe(event_recorder_priv, tmpevent_recorder_priv,
&session->priv->events_head, node)
lttng_ust_urcu_synchronize_rcu();
cds_list_for_each_entry_safe(notifier_enabler, tmpnotifier_enabler,
- &event_notifier_group->enablers_head, node)
+ &event_notifier_group->sync_enablers_head, node)
+ lttng_event_notifier_enabler_destroy(notifier_enabler);
+ cds_list_for_each_entry_safe(notifier_enabler, tmpnotifier_enabler,
+ &event_notifier_group->unsync_enablers_head, node)
lttng_event_notifier_enabler_destroy(notifier_enabler);
cds_list_for_each_entry_safe(event_notifier_priv, tmpevent_notifier_priv,
struct lttng_ust_session_private *session_priv;
cds_list_for_each_entry(session_priv, &sessions, node) {
+ /*
+ * New probes have appeared, we need to re-sync all
+ * enablers.
+ */
+ lttng_session_unsync_enablers(session_priv->pub);
lttng_session_lazy_sync_event_enablers(session_priv->pub);
}
return 0;
struct lttng_event_notifier_group *event_notifier_group;
cds_list_for_each_entry(event_notifier_group, &event_notifier_groups, node) {
+ /*
+ * New probes have appeared, we need to re-sync all
+ * enablers.
+ */
+ lttng_event_notifier_group_unsync_enablers(event_notifier_group);
lttng_event_notifier_group_sync_enablers(event_notifier_group);
}
return 0;
event_enabler->chan = chan;
/* ctx left NULL */
event_enabler->base.enabled = 0;
- cds_list_add(&event_enabler->node, &event_enabler->chan->parent->session->priv->enablers_head);
+ cds_list_add(&event_enabler->node, &event_enabler->chan->parent->session->priv->unsync_enablers_head);
lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session);
return event_enabler;
event_notifier_enabler->group = event_notifier_group;
cds_list_add(&event_notifier_enabler->node,
- &event_notifier_group->enablers_head);
+ &event_notifier_group->unsync_enablers_head);
lttng_event_notifier_group_sync_enablers(event_notifier_group);
int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler)
{
lttng_event_enabler_as_enabler(event_enabler)->enabled = 1;
+ lttng_event_enabler_unsync(event_enabler);
lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session);
return 0;
int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler)
{
lttng_event_enabler_as_enabler(event_enabler)->enabled = 0;
+ lttng_event_enabler_unsync(event_enabler);
lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session);
return 0;
{
_lttng_enabler_attach_filter_bytecode(
lttng_event_enabler_as_enabler(event_enabler), bytecode);
-
+ lttng_event_enabler_unsync(event_enabler);
lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session);
return 0;
}
{
_lttng_enabler_attach_exclusion(
lttng_event_enabler_as_enabler(event_enabler), excluder);
-
+ lttng_event_enabler_unsync(event_enabler);
lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent->session);
return 0;
}
struct lttng_event_notifier_enabler *event_notifier_enabler)
{
lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)->enabled = 1;
+ lttng_event_notifier_enabler_unsync(event_notifier_enabler);
lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
return 0;
struct lttng_event_notifier_enabler *event_notifier_enabler)
{
lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)->enabled = 0;
+ lttng_event_notifier_enabler_unsync(event_notifier_enabler);
lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
return 0;
_lttng_enabler_attach_filter_bytecode(
lttng_event_notifier_enabler_as_enabler(event_notifier_enabler),
bytecode);
-
+ lttng_event_notifier_enabler_unsync(event_notifier_enabler);
lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
return 0;
}
/* Take ownership of bytecode */
*bytecode = NULL;
event_notifier_enabler->num_captures++;
-
+ lttng_event_notifier_enabler_unsync(event_notifier_enabler);
lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
return 0;
}
_lttng_enabler_attach_exclusion(
lttng_event_notifier_enabler_as_enabler(event_notifier_enabler),
excluder);
-
+ lttng_event_notifier_enabler_unsync(event_notifier_enabler);
lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
return 0;
}
{
struct lttng_event_enabler *event_enabler;
struct lttng_ust_event_recorder_private *event_recorder_priv;
+ struct cds_list_head iter_list;
+
+ /*
+ * lttng_event_enabler_ref_event_recorders can cause lazy probes
+ * to add items to the unsync_enablers_head list. Iterate on a
+ * local copy of that list until it is stable (empty).
+ */
+ do {
+ CDS_INIT_LIST_HEAD(&iter_list);
+ cds_list_splice(&session->priv->unsync_enablers_head, &iter_list);
+ CDS_INIT_LIST_HEAD(&session->priv->unsync_enablers_head);
+ cds_list_for_each_entry(event_enabler, &iter_list, node)
+ lttng_event_enabler_ref_event_recorders(event_enabler);
+ cds_list_splice(&iter_list, &session->priv->sync_enablers_head);
+ } while (!cds_list_empty(&session->priv->unsync_enablers_head));
- cds_list_for_each_entry(event_enabler, &session->priv->enablers_head, node)
- lttng_event_enabler_ref_event_recorders(event_enabler);
/*
* For each event, if at least one of its enablers is enabled,
* and its channel and session transient states are enabled, we
{
struct lttng_event_notifier_enabler *event_notifier_enabler;
struct lttng_ust_event_notifier_private *event_notifier_priv;
+ struct cds_list_head iter_list;
- cds_list_for_each_entry(event_notifier_enabler, &event_notifier_group->enablers_head, node)
- lttng_event_notifier_enabler_ref_event_notifiers(event_notifier_enabler);
+ /*
+ * lttng_event_notifier_enabler_ref_event_notifiers can cause
+ * lazy probes to add items to the unsync_enablers_head list.
+ * Iterate on a local copy of that list until it is stable
+ * (empty).
+ */
+ do {
+ CDS_INIT_LIST_HEAD(&iter_list);
+ cds_list_splice(&event_notifier_group->unsync_enablers_head, &iter_list);
+ CDS_INIT_LIST_HEAD(&event_notifier_group->unsync_enablers_head);
+ cds_list_for_each_entry(event_notifier_enabler, &iter_list, node)
+ lttng_event_notifier_enabler_ref_event_notifiers(event_notifier_enabler);
+ cds_list_splice(&iter_list, &event_notifier_group->sync_enablers_head);
+ } while (!cds_list_empty(&event_notifier_group->unsync_enablers_head));
/*
* For each event_notifier, if at least one of its enablers is enabled,