Fix: circular dependency between lttng-events and lib counter
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Feb 2022 21:18:04 +0000 (16:18 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 15 Jul 2024 20:58:48 +0000 (16:58 -0400)
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 <mathieu.desnoyers@efficios.com>
Change-Id: I04cdbfb39deb76884092459cab62227b9f39d85d

include/lttng/events-internal.h
src/lttng-counter-client-percpu-32-modular.c
src/lttng-counter-client-percpu-64-modular.c
src/lttng-events.c

index f1f1f11f651ad586e11aadf4eaa8a67b48d6532b..8e21daed175ce1d28072edce6e865442fc48d8d1 100644 (file)
@@ -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,
index 421b04ae4d28db329edcf0a30c936f8faf581ec8..55deadb923ddf1d5da3b4a7912c6505fb0f26e75 100644 (file)
@@ -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,
        },
index 6050ebc9045a788e4d23e7b9a58f9b111d2a475e..973d6426424c510b212c8fe3a30539aeea0ca941 100644 (file)
@@ -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,
        },
index 14605a30e2405fcec445be835127378a4dee7168..cf4bf34cb1b591e6123274c2ffe2c338395ba6a9 100644 (file)
@@ -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)
This page took 0.029903 seconds and 4 git commands to generate.