Combine event recorder and notifier destroy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 22 Apr 2021 17:20:04 +0000 (13:20 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 Apr 2021 14:58:56 +0000 (10:58 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8a7e18d98286ddc1bf132cd39039658c9b669f51

include/lttng/events.h
src/lttng-bytecode.c
src/lttng-events.c

index b9586a0a43bcc0bd9031bd175ed51c907c9c7fd8..ee16fc2fc97cb37fd2f5bd8f604d4cc1199cd71a 100644 (file)
@@ -1087,8 +1087,7 @@ void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_des
                struct lttng_kernel_ctx *ctx,
                struct list_head *instance_bytecode_runtime_head,
                struct list_head *enabler_bytecode_runtime_head);
-void lttng_free_event_filter_runtime(struct lttng_kernel_event_recorder *event);
-void lttng_free_event_notifier_filter_runtime(struct lttng_kernel_event_notifier *event_notifier);
+void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event);
 
 int lttng_probes_init(void);
 
index cd95e59ed14b1fd453251501b6eb198c3640939a..5e4f8b3c74171061272fde6ab39d25b8e58bbc3d 100644 (file)
@@ -624,23 +624,12 @@ void lttng_free_enabler_filter_bytecode(struct lttng_enabler *enabler)
        }
 }
 
-void lttng_free_event_filter_runtime(struct lttng_kernel_event_recorder *event_recorder)
+void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event)
 {
        struct bytecode_runtime *runtime, *tmp;
 
        list_for_each_entry_safe(runtime, tmp,
-                       &event_recorder->priv->parent.filter_bytecode_runtime_head, p.node) {
-               kfree(runtime->data);
-               kfree(runtime);
-       }
-}
-
-void lttng_free_event_notifier_filter_runtime(struct lttng_kernel_event_notifier *event_notifier)
-{
-       struct bytecode_runtime *runtime, *tmp;
-
-       list_for_each_entry_safe(runtime, tmp,
-                       &event_notifier->priv->parent.filter_bytecode_runtime_head, p.node) {
+                       &event->priv->filter_bytecode_runtime_head, p.node) {
                kfree(runtime->data);
                kfree(runtime);
        }
index 3000e856f56e9634cf985e84afe9db2c2fb7a1d1..0c5b49d981bb6a864061277c282d4d24fc78877c 100644 (file)
@@ -69,8 +69,7 @@ static void lttng_event_enabler_destroy(struct lttng_event_enabler *event_enable
 static void lttng_event_notifier_enabler_destroy(struct lttng_event_notifier_enabler *event_notifier_enabler);
 static void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group *event_notifier_group);
 
-static void _lttng_event_destroy(struct lttng_kernel_event_recorder *event);
-static void _lttng_event_notifier_destroy(struct lttng_kernel_event_notifier *event_notifier);
+static void _lttng_event_destroy(struct lttng_kernel_event_common *event);
 static void _lttng_channel_destroy(struct lttng_channel *chan);
 static int _lttng_event_unregister(struct lttng_kernel_event_recorder *event);
 static int _lttng_event_notifier_unregister(struct lttng_kernel_event_notifier *event_notifier);
@@ -357,7 +356,7 @@ void lttng_session_destroy(struct lttng_session *session)
                        &session->enablers_head, node)
                lttng_event_enabler_destroy(event_enabler);
        list_for_each_entry_safe(event_recorder_priv, tmpevent_recorder_priv, &session->events, node)
-               _lttng_event_destroy(event_recorder_priv->pub);
+               _lttng_event_destroy(&event_recorder_priv->pub->parent);
        list_for_each_entry_safe(chan, tmpchan, &session->chan, list) {
                BUG_ON(chan->channel_type == METADATA_CHANNEL);
                _lttng_channel_destroy(chan);
@@ -412,7 +411,7 @@ void lttng_event_notifier_group_destroy(
 
        list_for_each_entry_safe(event_notifier_priv, tmpevent_notifier_priv,
                        &event_notifier_group->event_notifiers_head, node)
-               _lttng_event_notifier_destroy(event_notifier_priv->pub);
+               _lttng_event_destroy(&event_notifier_priv->pub->parent);
 
        if (event_notifier_group->error_counter) {
                struct lttng_counter *error_counter = event_notifier_group->error_counter;
@@ -1568,89 +1567,93 @@ int _lttng_event_notifier_unregister(
  * Only used internally at session destruction.
  */
 static
-void _lttng_event_destroy(struct lttng_kernel_event_recorder *event_recorder)
+void _lttng_event_destroy(struct lttng_kernel_event_common *event)
 {
-       struct lttng_kernel_event_common_private *event_priv = &event_recorder->priv->parent;
+       struct lttng_kernel_event_common_private *event_priv = event->priv;
        struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
 
-       switch (event_priv->instrumentation) {
-       case LTTNG_KERNEL_ABI_TRACEPOINT:
-               lttng_event_desc_put(event_priv->desc);
-               break;
+       lttng_free_event_filter_runtime(event);
+       /* Free event enabler refs */
+       list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
+                                &event_priv->enablers_ref_head, node)
+               kfree(enabler_ref);
 
-       case LTTNG_KERNEL_ABI_KPROBE:
-               module_put(event_priv->desc->owner);
-               lttng_kprobes_destroy_event_private(event_recorder);
-               break;
+       switch (event->type) {
+       case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+       {
+               struct lttng_kernel_event_recorder *event_recorder =
+                       container_of(event, struct lttng_kernel_event_recorder, parent);
 
-       case LTTNG_KERNEL_ABI_KRETPROBE:
-               module_put(event_priv->desc->owner);
-               lttng_kretprobes_destroy_private(event_recorder);
-               break;
+               switch (event_priv->instrumentation) {
+               case LTTNG_KERNEL_ABI_TRACEPOINT:
+                       lttng_event_desc_put(event_priv->desc);
+                       break;
 
-       case LTTNG_KERNEL_ABI_SYSCALL:
-               break;
+               case LTTNG_KERNEL_ABI_KPROBE:
+                       module_put(event_priv->desc->owner);
+                       lttng_kprobes_destroy_event_private(event_recorder);
+                       break;
 
-       case LTTNG_KERNEL_ABI_UPROBE:
-               module_put(event_priv->desc->owner);
-               lttng_uprobes_destroy_event_private(event_recorder);
-               break;
+               case LTTNG_KERNEL_ABI_KRETPROBE:
+                       module_put(event_priv->desc->owner);
+                       lttng_kretprobes_destroy_private(event_recorder);
+                       break;
 
-       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
-       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
-       default:
-               WARN_ON_ONCE(1);
-       }
-       list_del(&event_recorder->priv->node);
-       lttng_free_event_filter_runtime(event_recorder);
-       /* Free event enabler refs */
-       list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
-                                &event_priv->enablers_ref_head, node)
-               kfree(enabler_ref);
-       kmem_cache_free(event_recorder_private_cache, event_recorder->priv);
-       kmem_cache_free(event_recorder_cache, event_recorder);
-}
+               case LTTNG_KERNEL_ABI_SYSCALL:
+                       break;
 
-/*
- * Only used internally at session destruction.
- */
-static
-void _lttng_event_notifier_destroy(struct lttng_kernel_event_notifier *event_notifier)
-{
-       struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
+               case LTTNG_KERNEL_ABI_UPROBE:
+                       module_put(event_priv->desc->owner);
+                       lttng_uprobes_destroy_event_private(event_recorder);
+                       break;
 
-       switch (event_notifier->priv->parent.instrumentation) {
-       case LTTNG_KERNEL_ABI_TRACEPOINT:
-               lttng_event_desc_put(event_notifier->priv->parent.desc);
+               case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+               case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
+               default:
+                       WARN_ON_ONCE(1);
+               }
+               list_del(&event_recorder->priv->node);
+               kmem_cache_free(event_recorder_private_cache, event_recorder->priv);
+               kmem_cache_free(event_recorder_cache, event_recorder);
                break;
+       }
+       case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+       {
+               struct lttng_kernel_event_notifier *event_notifier =
+                       container_of(event, struct lttng_kernel_event_notifier, parent);
 
-       case LTTNG_KERNEL_ABI_KPROBE:
-               module_put(event_notifier->priv->parent.desc->owner);
-               lttng_kprobes_destroy_event_notifier_private(event_notifier);
-               break;
+               switch (event_notifier->priv->parent.instrumentation) {
+               case LTTNG_KERNEL_ABI_TRACEPOINT:
+                       lttng_event_desc_put(event_notifier->priv->parent.desc);
+                       break;
 
-       case LTTNG_KERNEL_ABI_SYSCALL:
-               break;
+               case LTTNG_KERNEL_ABI_KPROBE:
+                       module_put(event_notifier->priv->parent.desc->owner);
+                       lttng_kprobes_destroy_event_notifier_private(event_notifier);
+                       break;
 
-       case LTTNG_KERNEL_ABI_UPROBE:
-               module_put(event_notifier->priv->parent.desc->owner);
-               lttng_uprobes_destroy_event_notifier_private(event_notifier);
-               break;
+               case LTTNG_KERNEL_ABI_SYSCALL:
+                       break;
 
-       case LTTNG_KERNEL_ABI_KRETPROBE:        /* Fall-through */
-       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
-       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
+               case LTTNG_KERNEL_ABI_UPROBE:
+                       module_put(event_notifier->priv->parent.desc->owner);
+                       lttng_uprobes_destroy_event_notifier_private(event_notifier);
+                       break;
+
+               case LTTNG_KERNEL_ABI_KRETPROBE:        /* Fall-through */
+               case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+               case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
+               default:
+                       WARN_ON_ONCE(1);
+               }
+               list_del(&event_notifier->priv->node);
+               kmem_cache_free(event_notifier_private_cache, event_notifier->priv);
+               kmem_cache_free(event_notifier_cache, event_notifier);
+               break;
+       }
        default:
                WARN_ON_ONCE(1);
        }
-       list_del(&event_notifier->priv->node);
-       lttng_free_event_notifier_filter_runtime(event_notifier);
-       /* Free event enabler refs */
-       list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
-                                &event_notifier->priv->parent.enablers_ref_head, node)
-               kfree(enabler_ref);
-       kmem_cache_free(event_notifier_private_cache, event_notifier->priv);
-       kmem_cache_free(event_notifier_cache, event_notifier);
 }
 
 struct lttng_id_tracker *get_tracker(struct lttng_session *session,
This page took 0.032449 seconds and 4 git commands to generate.