From: Mathieu Desnoyers Date: Sat, 6 Apr 2013 00:58:48 +0000 (-0400) Subject: Optimisation: only fix pending events once per lazy update X-Git-Tag: v2.2.0-rc2~20 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5f733922ed1e2db5b397292ede81303a9e538a08;p=lttng-ust.git Optimisation: only fix pending events once per lazy update Suggested-by: Yang Wang Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index d3702517..4cc507a0 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -527,7 +527,7 @@ void synchronize_trace(void); int lttng_probe_register(struct lttng_probe_desc *desc); void lttng_probe_unregister(struct lttng_probe_desc *desc); -int lttng_fix_pending_event_desc(const struct lttng_event_desc *desc); +int lttng_fix_pending_events(void); int lttng_probes_init(void); void lttng_probes_exit(void); int lttng_find_context(struct lttng_ctx *ctx, const char *name); diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index ca858730..e4faf605 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -635,12 +635,9 @@ int lttng_enabler_ref_events(struct lttng_enabler *enabler) /* * Called at library load: connect the probe on all enablers matching * this event. - * called with session mutex held. - * TODO: currently, for each desc added, we iterate on all event desc - * (inefficient). We should create specific code that only target the - * added desc. + * Called with session mutex held. */ -int lttng_fix_pending_event_desc(const struct lttng_event_desc *desc) +int lttng_fix_pending_events(void) { struct lttng_session *session; diff --git a/liblttng-ust/lttng-probes.c b/liblttng-ust/lttng-probes.c index b1d5fe28..f028ccab 100644 --- a/liblttng-ust/lttng-probes.c +++ b/liblttng-ust/lttng-probes.c @@ -80,7 +80,6 @@ void lttng_lazy_probe_register(struct lttng_probe_desc *desc) { struct lttng_probe_desc *iter; struct cds_list_head *probe_list; - int i; /* * Each provider enforce that every event name begins with the @@ -114,19 +113,6 @@ void lttng_lazy_probe_register(struct lttng_probe_desc *desc) desc_added: DBG("just registered probe %s containing %u events", desc->provider, desc->nr_events); - /* - * fix the events awaiting probe load. - */ - for (i = 0; i < desc->nr_events; i++) { - const struct lttng_event_desc *ed; - int ret; - - ed = desc->event_desc[i]; - DBG("Registered event probe \"%s\" with signature \"%s\"", - ed->name, ed->signature); - ret = lttng_fix_pending_event_desc(ed); - assert(!ret); - } } /* @@ -136,6 +122,7 @@ static void fixup_lazy_probes(void) { struct lttng_probe_desc *iter, *tmp; + int ret; lazy_nesting++; cds_list_for_each_entry_safe(iter, tmp, @@ -144,6 +131,8 @@ void fixup_lazy_probes(void) iter->lazy = 0; cds_list_del(&iter->lazy_init_head); } + ret = lttng_fix_pending_events(); + assert(!ret); lazy_nesting--; }