From: Mathieu Desnoyers Date: Mon, 21 Feb 2022 21:18:04 +0000 (-0500) Subject: Fix: circular dependency between lttng-events and lib counter X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=dc1f2f731fa249ece00555568c1c881ee2aec0dd;p=lttng-modules.git Fix: circular dependency between lttng-events and lib counter lib counter depends on lttng-events (tracer), not the opposite. Use the lttng-counter clients callbacks to remove the circular dependency. Signed-off-by: Mathieu Desnoyers Change-Id: I04cdbfb39deb76884092459cab62227b9f39d85d --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index f1f1f11f..8e21daed 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -249,6 +249,10 @@ struct lttng_kernel_channel_counter_ops_private { bool *overflow, bool *underflow); int (*counter_clear)(struct lttng_kernel_channel_counter *counter, const size_t *dimension_indexes); + int (*counter_get_nr_dimensions)(struct lttng_kernel_channel_counter *counter, + size_t *nr_dimensions); + int (*counter_get_max_nr_elem)(struct lttng_kernel_channel_counter *counter, + size_t *max_nr_elem); /* array of size nr_dimensions */ }; struct lttng_kernel_channel_counter_private { @@ -1129,6 +1133,10 @@ int lttng_kernel_counter_aggregate(struct lttng_kernel_channel_counter *counter, bool *overflow, bool *underflow); int lttng_kernel_counter_clear(struct lttng_kernel_channel_counter *counter, const size_t *dimension_indexes); +int lttng_kernel_counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter, + size_t *nr_dimensions); +int lttng_kernel_counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter, + size_t *max_nr_elem); struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); int lttng_event_notifier_group_create_error_counter( struct file *event_notifier_group_file, diff --git a/src/lttng-counter-client-percpu-32-modular.c b/src/lttng-counter-client-percpu-32-modular.c index 421b04ae..55deadb9 100644 --- a/src/lttng-counter-client-percpu-32-modular.c +++ b/src/lttng-counter-client-percpu-32-modular.c @@ -91,6 +91,16 @@ static int counter_clear(struct lttng_kernel_channel_counter *counter, const siz return lttng_counter_clear(&client_config, counter->priv->counter, dimension_indexes); } +static int counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter, size_t *nr_dimensions) +{ + return lttng_counter_get_nr_dimensions(&client_config, counter->priv->counter, nr_dimensions); +} + +static int counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter, size_t *max_nr_elem) +{ + return lttng_counter_get_max_nr_elem(&client_config, counter->priv->counter, max_nr_elem); +} + static struct lttng_counter_transport lttng_counter_transport = { .name = "counter-per-cpu-32-modular", .owner = THIS_MODULE, @@ -103,6 +113,8 @@ static struct lttng_counter_transport lttng_counter_transport = { .counter_read = counter_read, .counter_aggregate = counter_aggregate, .counter_clear = counter_clear, + .counter_get_nr_dimensions = counter_get_nr_dimensions, + .counter_get_max_nr_elem = counter_get_max_nr_elem, }), .event_counter_add = event_counter_add, }, diff --git a/src/lttng-counter-client-percpu-64-modular.c b/src/lttng-counter-client-percpu-64-modular.c index 6050ebc9..973d6426 100644 --- a/src/lttng-counter-client-percpu-64-modular.c +++ b/src/lttng-counter-client-percpu-64-modular.c @@ -91,6 +91,16 @@ static int counter_clear(struct lttng_kernel_channel_counter *counter, const siz return lttng_counter_clear(&client_config, counter->priv->counter, dimension_indexes); } +static int counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter, size_t *nr_dimensions) +{ + return lttng_counter_get_nr_dimensions(&client_config, counter->priv->counter, nr_dimensions); +} + +static int counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter, size_t *max_nr_elem) +{ + return lttng_counter_get_max_nr_elem(&client_config, counter->priv->counter, max_nr_elem); +} + static struct lttng_counter_transport lttng_counter_transport = { .name = "counter-per-cpu-64-modular", .owner = THIS_MODULE, @@ -103,6 +113,8 @@ static struct lttng_counter_transport lttng_counter_transport = { .counter_read = counter_read, .counter_aggregate = counter_aggregate, .counter_clear = counter_clear, + .counter_get_nr_dimensions = counter_get_nr_dimensions, + .counter_get_max_nr_elem = counter_get_max_nr_elem, }), .event_counter_add = event_counter_add, }, diff --git a/src/lttng-events.c b/src/lttng-events.c index 14605a30..cf4bf34c 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -896,15 +896,14 @@ bool lttng_kernel_event_id_available(struct lttng_event_enabler_common *event_en struct lttng_event_counter_enabler *event_counter_enabler = container_of(event_enabler, struct lttng_event_counter_enabler, parent.parent); struct lttng_kernel_channel_counter *chan = event_counter_enabler->chan; - struct lib_counter *counter = chan->priv->counter; size_t nr_dimensions, max_nr_elem; - if (lttng_counter_get_nr_dimensions(&counter->config, counter, &nr_dimensions)) + if (lttng_kernel_counter_get_nr_dimensions(chan, &nr_dimensions)) return false; WARN_ON_ONCE(nr_dimensions != 1); if (nr_dimensions != 1) return false; - if (lttng_counter_get_max_nr_elem(&counter->config, counter, &max_nr_elem)) + if (lttng_kernel_counter_get_max_nr_elem(chan, &max_nr_elem)) return false; switch (itype) { case LTTNG_KERNEL_ABI_TRACEPOINT: @@ -1541,6 +1540,18 @@ int lttng_kernel_counter_clear(struct lttng_kernel_channel_counter *counter, return counter->ops->priv->counter_clear(counter, dim_indexes); } +int lttng_kernel_counter_get_nr_dimensions(struct lttng_kernel_channel_counter *counter, + size_t *nr_dimensions) +{ + return counter->ops->priv->counter_get_nr_dimensions(counter, nr_dimensions); +} + +int lttng_kernel_counter_get_max_nr_elem(struct lttng_kernel_channel_counter *counter, + size_t *max_nr_elem) +{ + return counter->ops->priv->counter_get_max_nr_elem(counter, max_nr_elem); +} + /* Only used for tracepoints and system calls for now. */ static void register_event(struct lttng_kernel_event_common *event)