Cleanup: implement dedicated file operations for events and enablers
[lttng-modules.git] / src / lttng-events.c
index d1a0706e0b9793b525e5c66212ac23b9e85d0614..6676d5f715d873e7490a6422fbc6809d574ebda9 100644 (file)
@@ -36,6 +36,7 @@
 #include <wrapper/types.h>
 #include <lttng/kernel-version.h>
 #include <lttng/events.h>
+#include <lttng/events-internal.h>
 #include <lttng/lttng-bytecode.h>
 #include <lttng/tracer.h>
 #include <lttng/event-notifier-notification.h>
@@ -52,6 +53,7 @@
 static LIST_HEAD(sessions);
 static LIST_HEAD(event_notifier_groups);
 static LIST_HEAD(lttng_transport_list);
+static LIST_HEAD(lttng_counter_transport_list);
 /*
  * Protect the sessions and metadata caches.
  */
@@ -80,30 +82,31 @@ static
 void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream);
 static
 int _lttng_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_common *type,
+               enum lttng_kernel_string_encoding parent_encoding,
                size_t nesting);
 static
 int _lttng_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting);
 
 void synchronize_trace(void)
 {
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,1,0))
        synchronize_rcu();
 #else
        synchronize_sched();
 #endif
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0))
 #ifdef CONFIG_PREEMPT_RT_FULL
        synchronize_rcu();
 #endif
-#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */
+#else /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0)) */
 #ifdef CONFIG_PREEMPT_RT
        synchronize_rcu();
 #endif
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */
+#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0)) */
 }
 
 void lttng_lock_sessions(void)
@@ -197,6 +200,61 @@ err:
        return NULL;
 }
 
+static
+struct lttng_counter_transport *lttng_counter_transport_find(const char *name)
+{
+       struct lttng_counter_transport *transport;
+
+       list_for_each_entry(transport, &lttng_counter_transport_list, node) {
+               if (!strcmp(transport->name, name))
+                       return transport;
+       }
+       return NULL;
+}
+
+struct lttng_counter *lttng_kernel_counter_create(
+               const char *counter_transport_name,
+               size_t number_dimensions, const size_t *dimensions_sizes)
+{
+       struct lttng_counter *counter = NULL;
+       struct lttng_counter_transport *counter_transport = NULL;
+
+       counter_transport = lttng_counter_transport_find(counter_transport_name);
+       if (!counter_transport) {
+               printk(KERN_WARNING "LTTng: counter transport %s not found.\n",
+                      counter_transport_name);
+               goto notransport;
+       }
+       if (!try_module_get(counter_transport->owner)) {
+               printk(KERN_WARNING "LTTng: Can't lock counter transport module.\n");
+               goto notransport;
+       }
+
+       counter = lttng_kvzalloc(sizeof(struct lttng_counter), GFP_KERNEL);
+       if (!counter)
+               goto nomem;
+
+       /* Create event notifier error counter. */
+       counter->ops = &counter_transport->ops;
+       counter->transport = counter_transport;
+
+       counter->counter = counter->ops->counter_create(
+                       number_dimensions, dimensions_sizes, 0);
+       if (!counter->counter) {
+               goto create_error;
+       }
+
+       return counter;
+
+create_error:
+       lttng_kvfree(counter);
+nomem:
+       if (counter_transport)
+               module_put(counter_transport->owner);
+notransport:
+       return NULL;
+}
+
 struct lttng_event_notifier_group *lttng_event_notifier_group_create(void)
 {
        struct lttng_transport *transport = NULL;
@@ -281,7 +339,7 @@ void lttng_session_destroy(struct lttng_session *session)
        mutex_lock(&sessions_mutex);
        WRITE_ONCE(session->active, 0);
        list_for_each_entry(chan, &session->chan, list) {
-               ret = lttng_syscalls_unregister_event(chan);
+               ret = lttng_syscalls_unregister_channel(chan);
                WARN_ON(ret);
        }
        list_for_each_entry(event, &session->events, list) {
@@ -330,7 +388,7 @@ void lttng_event_notifier_group_destroy(
 
        mutex_lock(&sessions_mutex);
 
-       ret = lttng_syscalls_unregister_event_notifier(event_notifier_group);
+       ret = lttng_syscalls_unregister_event_notifier_group(event_notifier_group);
        WARN_ON(ret);
 
        list_for_each_entry_safe(event_notifier, tmpevent_notifier,
@@ -354,6 +412,15 @@ void lttng_event_notifier_group_destroy(
                        &event_notifier_group->event_notifiers_head, list)
                _lttng_event_notifier_destroy(event_notifier);
 
+       if (event_notifier_group->error_counter) {
+               struct lttng_counter *error_counter = event_notifier_group->error_counter;
+
+               error_counter->ops->counter_destroy(error_counter->counter);
+               module_put(error_counter->transport->owner);
+               lttng_kvfree(error_counter);
+               event_notifier_group->error_counter = NULL;
+       }
+
        event_notifier_group->ops->channel_destroy(event_notifier_group->chan);
        module_put(event_notifier_group->transport->owner);
        list_del(&event_notifier_group->node);
@@ -549,19 +616,22 @@ int lttng_event_enable(struct lttng_event *event)
                goto end;
        }
        switch (event->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-       case LTTNG_KERNEL_SYSCALL:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:       /* Fall-through */
+       case LTTNG_KERNEL_ABI_SYSCALL:
                ret = -EINVAL;
                break;
-       case LTTNG_KERNEL_KPROBE:
-       case LTTNG_KERNEL_UPROBE:
-       case LTTNG_KERNEL_NOOP:
+
+       case LTTNG_KERNEL_ABI_KPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_UPROBE:
                WRITE_ONCE(event->enabled, 1);
                break;
-       case LTTNG_KERNEL_KRETPROBE:
+
+       case LTTNG_KERNEL_ABI_KRETPROBE:
                ret = lttng_kretprobes_event_enable_state(event, 1);
                break;
-       case LTTNG_KERNEL_FUNCTION:     /* Fall-through. */
+
+       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
        default:
                WARN_ON_ONCE(1);
                ret = -EINVAL;
@@ -585,19 +655,23 @@ int lttng_event_disable(struct lttng_event *event)
                goto end;
        }
        switch (event->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-       case LTTNG_KERNEL_SYSCALL:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:       /* Fall-through */
+       case LTTNG_KERNEL_ABI_SYSCALL:
                ret = -EINVAL;
                break;
-       case LTTNG_KERNEL_KPROBE:
-       case LTTNG_KERNEL_UPROBE:
-       case LTTNG_KERNEL_NOOP:
+
+       case LTTNG_KERNEL_ABI_KPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_UPROBE:
                WRITE_ONCE(event->enabled, 0);
                break;
-       case LTTNG_KERNEL_KRETPROBE:
+
+       case LTTNG_KERNEL_ABI_KRETPROBE:
+
                ret = lttng_kretprobes_event_enable_state(event, 0);
                break;
-       case LTTNG_KERNEL_FUNCTION:     /* Fall-through. */
+
+       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
        default:
                WARN_ON_ONCE(1);
                ret = -EINVAL;
@@ -617,17 +691,19 @@ int lttng_event_notifier_enable(struct lttng_event_notifier *event_notifier)
                goto end;
        }
        switch (event_notifier->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-       case LTTNG_KERNEL_SYSCALL:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:       /* Fall-through */
+       case LTTNG_KERNEL_ABI_SYSCALL:
                ret = -EINVAL;
                break;
-       case LTTNG_KERNEL_KPROBE:
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_UPROBE:
                WRITE_ONCE(event_notifier->enabled, 1);
                break;
-       case LTTNG_KERNEL_FUNCTION:
-       case LTTNG_KERNEL_NOOP:
-       case LTTNG_KERNEL_KRETPROBE:
+
+       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+       case LTTNG_KERNEL_ABI_KRETPROBE:        /* Fall-through */
+       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
        default:
                WARN_ON_ONCE(1);
                ret = -EINVAL;
@@ -647,17 +723,19 @@ int lttng_event_notifier_disable(struct lttng_event_notifier *event_notifier)
                goto end;
        }
        switch (event_notifier->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-       case LTTNG_KERNEL_SYSCALL:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:       /* Fall-through */
+       case LTTNG_KERNEL_ABI_SYSCALL:
                ret = -EINVAL;
                break;
-       case LTTNG_KERNEL_KPROBE:
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_UPROBE:
                WRITE_ONCE(event_notifier->enabled, 0);
                break;
-       case LTTNG_KERNEL_FUNCTION:
-       case LTTNG_KERNEL_NOOP:
-       case LTTNG_KERNEL_KRETPROBE:
+
+       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+       case LTTNG_KERNEL_ABI_KRETPROBE:        /* Fall-through */
+       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
        default:
                WARN_ON_ONCE(1);
                ret = -EINVAL;
@@ -737,7 +815,7 @@ void _lttng_channel_destroy(struct lttng_channel *chan)
        chan->ops->channel_destroy(chan->chan);
        module_put(chan->transport->owner);
        list_del(&chan->list);
-       lttng_destroy_context(chan->ctx);
+       lttng_kernel_destroy_context(chan->ctx);
        kfree(chan);
 }
 
@@ -759,15 +837,16 @@ void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream)
        wake_up_interruptible(&stream->read_wait);
 }
 
+
 /*
  * Supports event creation while tracing session is active.
  * Needs to be called with sessions mutex held.
  */
 struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
-                               struct lttng_kernel_event *event_param,
+                               struct lttng_kernel_abi_event *event_param,
                                void *filter,
-                               const struct lttng_event_desc *event_desc,
-                               enum lttng_kernel_instrumentation itype)
+                               const struct lttng_kernel_event_desc *event_desc,
+                               enum lttng_kernel_abi_instrumentation itype)
 {
        struct lttng_session *session = chan->session;
        struct lttng_event *event;
@@ -781,17 +860,19 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
        }
 
        switch (itype) {
-       case LTTNG_KERNEL_TRACEPOINT:
-               event_name = event_desc->name;
-               break;
-       case LTTNG_KERNEL_KPROBE:
-       case LTTNG_KERNEL_UPROBE:
-       case LTTNG_KERNEL_KRETPROBE:
-       case LTTNG_KERNEL_NOOP:
-       case LTTNG_KERNEL_SYSCALL:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
+               event_name = event_desc->event_name;
+               break;
+
+       case LTTNG_KERNEL_ABI_KPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_UPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_KRETPROBE:        /* Fall-through */
+       case LTTNG_KERNEL_ABI_SYSCALL:
                event_name = event_param->name;
                break;
-       case LTTNG_KERNEL_FUNCTION:     /* Fall-through. */
+
+       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
        default:
                WARN_ON_ONCE(1);
                ret = -EINVAL;
@@ -802,8 +883,8 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                LTTNG_EVENT_HT_SIZE, event_name);
        lttng_hlist_for_each_entry(event, head, hlist) {
                WARN_ON_ONCE(!event->desc);
-               if (!strncmp(event->desc->name, event_name,
-                                       LTTNG_KERNEL_SYM_NAME_LEN - 1)
+               if (!strncmp(event->desc->event_name, event_name,
+                                       LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1)
                                && chan == event->chan) {
                        ret = -EEXIST;
                        goto exist;
@@ -819,12 +900,11 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
        event->filter = filter;
        event->id = chan->free_event_id++;
        event->instrumentation = itype;
-       event->evtype = LTTNG_TYPE_EVENT;
        INIT_LIST_HEAD(&event->filter_bytecode_runtime_head);
        INIT_LIST_HEAD(&event->enablers_ref_head);
 
        switch (itype) {
-       case LTTNG_KERNEL_TRACEPOINT:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
                /* Event will be enabled by enabler sync. */
                event->enabled = 0;
                event->registered = 0;
@@ -836,7 +916,8 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                /* Populate lttng_event structure before event registration. */
                smp_wmb();
                break;
-       case LTTNG_KERNEL_KPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:
                /*
                 * Needs to be explicitly enabled after creation, since
                 * we may want to apply filters.
@@ -860,7 +941,8 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                ret = try_module_get(event->desc->owner);
                WARN_ON_ONCE(!ret);
                break;
-       case LTTNG_KERNEL_KRETPROBE:
+
+       case LTTNG_KERNEL_ABI_KRETPROBE:
        {
                struct lttng_event *event_return;
 
@@ -883,6 +965,8 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                event_return->enabled = 0;
                event_return->registered = 1;
                event_return->instrumentation = itype;
+               INIT_LIST_HEAD(&event_return->filter_bytecode_runtime_head);
+               INIT_LIST_HEAD(&event_return->enablers_ref_head);
                /*
                 * Populate lttng_event structure before kretprobe registration.
                 */
@@ -914,8 +998,8 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                list_add(&event_return->list, &chan->session->events);
                break;
        }
-       case LTTNG_KERNEL_NOOP:
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                /*
                 * Needs to be explicitly enabled after creation, since
                 * we may want to apply filters.
@@ -924,24 +1008,24 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                event->registered = 0;
                event->desc = event_desc;
                switch (event_param->u.syscall.entryexit) {
-               case LTTNG_KERNEL_SYSCALL_ENTRYEXIT:
+               case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
                        ret = -EINVAL;
                        goto register_error;
-               case LTTNG_KERNEL_SYSCALL_ENTRY:
+               case LTTNG_KERNEL_ABI_SYSCALL_ENTRY:
                        event->u.syscall.entryexit = LTTNG_SYSCALL_ENTRY;
                        break;
-               case LTTNG_KERNEL_SYSCALL_EXIT:
+               case LTTNG_KERNEL_ABI_SYSCALL_EXIT:
                        event->u.syscall.entryexit = LTTNG_SYSCALL_EXIT;
                        break;
                }
                switch (event_param->u.syscall.abi) {
-               case LTTNG_KERNEL_SYSCALL_ABI_ALL:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL:
                        ret = -EINVAL;
                        goto register_error;
-               case LTTNG_KERNEL_SYSCALL_ABI_NATIVE:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE:
                        event->u.syscall.abi = LTTNG_SYSCALL_ABI_NATIVE;
                        break;
-               case LTTNG_KERNEL_SYSCALL_ABI_COMPAT:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT:
                        event->u.syscall.abi = LTTNG_SYSCALL_ABI_COMPAT;
                        break;
                }
@@ -950,7 +1034,8 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                        goto register_error;
                }
                break;
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_UPROBE:
                /*
                 * Needs to be explicitly enabled after creation, since
                 * we may want to apply filters.
@@ -972,7 +1057,9 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
                ret = try_module_get(event->desc->owner);
                WARN_ON_ONCE(!ret);
                break;
-       case LTTNG_KERNEL_FUNCTION:     /* Fall-through */
+
+       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
        default:
                WARN_ON_ONCE(1);
                ret = -EINVAL;
@@ -999,28 +1086,32 @@ full:
 }
 
 struct lttng_event_notifier *_lttng_event_notifier_create(
-               const struct lttng_event_desc *event_desc,
-               uint64_t token, struct lttng_event_notifier_group *event_notifier_group,
-               struct lttng_kernel_event_notifier *event_notifier_param,
-               void *filter, enum lttng_kernel_instrumentation itype)
+               const struct lttng_kernel_event_desc *event_desc,
+               uint64_t token, uint64_t error_counter_index,
+               struct lttng_event_notifier_group *event_notifier_group,
+               struct lttng_kernel_abi_event_notifier *event_notifier_param,
+               void *filter, enum lttng_kernel_abi_instrumentation itype)
 {
        struct lttng_event_notifier *event_notifier;
+       struct lttng_counter *error_counter;
        const char *event_name;
        struct hlist_head *head;
        int ret;
 
        switch (itype) {
-       case LTTNG_KERNEL_TRACEPOINT:
-               event_name = event_desc->name;
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
+               event_name = event_desc->event_name;
                break;
-       case LTTNG_KERNEL_KPROBE:
-       case LTTNG_KERNEL_UPROBE:
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_KPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_UPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_SYSCALL:
                event_name = event_notifier_param->event.name;
                break;
-       case LTTNG_KERNEL_KRETPROBE:
-       case LTTNG_KERNEL_FUNCTION:
-       case LTTNG_KERNEL_NOOP:
+
+       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);
                ret = -EINVAL;
@@ -1031,8 +1122,8 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
                LTTNG_EVENT_NOTIFIER_HT_SIZE, event_name);
        lttng_hlist_for_each_entry(event_notifier, head, hlist) {
                WARN_ON_ONCE(!event_notifier->desc);
-               if (!strncmp(event_notifier->desc->name, event_name,
-                                       LTTNG_KERNEL_SYM_NAME_LEN - 1)
+               if (!strncmp(event_notifier->desc->event_name, event_name,
+                                       LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1)
                                && event_notifier_group == event_notifier->group
                                && token == event_notifier->user_token) {
                        ret = -EEXIST;
@@ -1048,15 +1139,17 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
 
        event_notifier->group = event_notifier_group;
        event_notifier->user_token = token;
+       event_notifier->error_counter_index = error_counter_index;
+       event_notifier->num_captures = 0;
        event_notifier->filter = filter;
        event_notifier->instrumentation = itype;
-       event_notifier->evtype = LTTNG_TYPE_EVENT;
        event_notifier->send_notification = lttng_event_notifier_notification_send;
        INIT_LIST_HEAD(&event_notifier->filter_bytecode_runtime_head);
+       INIT_LIST_HEAD(&event_notifier->capture_bytecode_runtime_head);
        INIT_LIST_HEAD(&event_notifier->enablers_ref_head);
 
        switch (itype) {
-       case LTTNG_KERNEL_TRACEPOINT:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
                /* Event will be enabled by enabler sync. */
                event_notifier->enabled = 0;
                event_notifier->registered = 0;
@@ -1068,7 +1161,8 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
                /* Populate lttng_event_notifier structure before event registration. */
                smp_wmb();
                break;
-       case LTTNG_KERNEL_KPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:
                /*
                 * Needs to be explicitly enabled after creation, since
                 * we may want to apply filters.
@@ -1092,8 +1186,8 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
                ret = try_module_get(event_notifier->desc->owner);
                WARN_ON_ONCE(!ret);
                break;
-       case LTTNG_KERNEL_NOOP:
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                /*
                 * Needs to be explicitly enabled after creation, since
                 * we may want to apply filters.
@@ -1102,24 +1196,24 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
                event_notifier->registered = 0;
                event_notifier->desc = event_desc;
                switch (event_notifier_param->event.u.syscall.entryexit) {
-               case LTTNG_KERNEL_SYSCALL_ENTRYEXIT:
+               case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
                        ret = -EINVAL;
                        goto register_error;
-               case LTTNG_KERNEL_SYSCALL_ENTRY:
+               case LTTNG_KERNEL_ABI_SYSCALL_ENTRY:
                        event_notifier->u.syscall.entryexit = LTTNG_SYSCALL_ENTRY;
                        break;
-               case LTTNG_KERNEL_SYSCALL_EXIT:
+               case LTTNG_KERNEL_ABI_SYSCALL_EXIT:
                        event_notifier->u.syscall.entryexit = LTTNG_SYSCALL_EXIT;
                        break;
                }
                switch (event_notifier_param->event.u.syscall.abi) {
-               case LTTNG_KERNEL_SYSCALL_ABI_ALL:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL:
                        ret = -EINVAL;
                        goto register_error;
-               case LTTNG_KERNEL_SYSCALL_ABI_NATIVE:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE:
                        event_notifier->u.syscall.abi = LTTNG_SYSCALL_ABI_NATIVE;
                        break;
-               case LTTNG_KERNEL_SYSCALL_ABI_COMPAT:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT:
                        event_notifier->u.syscall.abi = LTTNG_SYSCALL_ABI_COMPAT;
                        break;
                }
@@ -1129,7 +1223,8 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
                        goto register_error;
                }
                break;
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_UPROBE:
                /*
                 * Needs to be explicitly enabled after creation, since
                 * we may want to apply filters.
@@ -1152,8 +1247,10 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
                ret = try_module_get(event_notifier->desc->owner);
                WARN_ON_ONCE(!ret);
                break;
-       case LTTNG_KERNEL_KRETPROBE:
-       case LTTNG_KERNEL_FUNCTION:
+
+       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);
                ret = -EINVAL;
@@ -1162,6 +1259,36 @@ struct lttng_event_notifier *_lttng_event_notifier_create(
 
        list_add(&event_notifier->list, &event_notifier_group->event_notifiers_head);
        hlist_add_head(&event_notifier->hlist, head);
+
+       /*
+        * Clear the error counter bucket. The sessiond keeps track of which
+        * bucket is currently in use. We trust it. The session lock
+        * synchronizes against concurrent creation of the error
+        * counter.
+        */
+       error_counter = event_notifier_group->error_counter;
+       if (error_counter) {
+               size_t dimension_index[1];
+
+               /*
+                * Check that the index is within the boundary of the counter.
+                */
+               if (event_notifier->error_counter_index >= event_notifier_group->error_counter_len) {
+                       printk(KERN_INFO "LTTng: event_notifier: Error counter index out-of-bound: counter-len=%zu, index=%llu\n",
+                               event_notifier_group->error_counter_len, event_notifier->error_counter_index);
+                       ret = -EINVAL;
+                       goto register_error;
+               }
+
+               dimension_index[0] = event_notifier->error_counter_index;
+               ret = error_counter->ops->counter_clear(error_counter->counter, dimension_index);
+               if (ret) {
+                       printk(KERN_INFO "LTTng: event_notifier: Unable to clear error counter bucket %llu\n",
+                               event_notifier->error_counter_index);
+                       goto register_error;
+               }
+       }
+
        return event_notifier;
 
 register_error:
@@ -1172,11 +1299,33 @@ type_error:
        return ERR_PTR(ret);
 }
 
+int lttng_kernel_counter_read(struct lttng_counter *counter,
+               const size_t *dim_indexes, int32_t cpu,
+               int64_t *val, bool *overflow, bool *underflow)
+{
+       return counter->ops->counter_read(counter->counter, dim_indexes,
+                       cpu, val, overflow, underflow);
+}
+
+int lttng_kernel_counter_aggregate(struct lttng_counter *counter,
+               const size_t *dim_indexes, int64_t *val,
+               bool *overflow, bool *underflow)
+{
+       return counter->ops->counter_aggregate(counter->counter, dim_indexes,
+                       val, overflow, underflow);
+}
+
+int lttng_kernel_counter_clear(struct lttng_counter *counter,
+               const size_t *dim_indexes)
+{
+       return counter->ops->counter_clear(counter->counter, dim_indexes);
+}
+
 struct lttng_event *lttng_event_create(struct lttng_channel *chan,
-                               struct lttng_kernel_event *event_param,
+                               struct lttng_kernel_abi_event *event_param,
                                void *filter,
-                               const struct lttng_event_desc *event_desc,
-                               enum lttng_kernel_instrumentation itype)
+                               const struct lttng_kernel_event_desc *event_desc,
+                               enum lttng_kernel_abi_instrumentation itype)
 {
        struct lttng_event *event;
 
@@ -1188,16 +1337,18 @@ struct lttng_event *lttng_event_create(struct lttng_channel *chan,
 }
 
 struct lttng_event_notifier *lttng_event_notifier_create(
-               const struct lttng_event_desc *event_desc,
-               uint64_t id, struct lttng_event_notifier_group *event_notifier_group,
-               struct lttng_kernel_event_notifier *event_notifier_param,
-               void *filter, enum lttng_kernel_instrumentation itype)
+               const struct lttng_kernel_event_desc *event_desc,
+               uint64_t id, uint64_t error_counter_index,
+               struct lttng_event_notifier_group *event_notifier_group,
+               struct lttng_kernel_abi_event_notifier *event_notifier_param,
+               void *filter, enum lttng_kernel_abi_instrumentation itype)
 {
        struct lttng_event_notifier *event_notifier;
 
        mutex_lock(&sessions_mutex);
        event_notifier = _lttng_event_notifier_create(event_desc, id,
-               event_notifier_group, event_notifier_param, filter, itype);
+               error_counter_index, event_notifier_group,
+               event_notifier_param, filter, itype);
        mutex_unlock(&sessions_mutex);
        return event_notifier;
 }
@@ -1206,7 +1357,7 @@ struct lttng_event_notifier *lttng_event_notifier_create(
 static
 void register_event(struct lttng_event *event)
 {
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        int ret = -EINVAL;
 
        if (event->registered)
@@ -1214,21 +1365,24 @@ void register_event(struct lttng_event *event)
 
        desc = event->desc;
        switch (event->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-               ret = lttng_wrapper_tracepoint_probe_register(desc->kname,
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
+               ret = lttng_wrapper_tracepoint_probe_register(desc->event_kname,
                                                  desc->probe_callback,
                                                  event);
                break;
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                ret = lttng_syscall_filter_enable_event(event->chan, event);
                break;
-       case LTTNG_KERNEL_KPROBE:
-       case LTTNG_KERNEL_UPROBE:
-       case LTTNG_KERNEL_KRETPROBE:
-       case LTTNG_KERNEL_NOOP:
+
+       case LTTNG_KERNEL_ABI_KPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_UPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_KRETPROBE:
                ret = 0;
                break;
-       case LTTNG_KERNEL_FUNCTION:     /* Fall-through */
+
+       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
        default:
                WARN_ON_ONCE(1);
        }
@@ -1241,7 +1395,7 @@ void register_event(struct lttng_event *event)
  */
 int _lttng_event_unregister(struct lttng_event *event)
 {
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        int ret = -EINVAL;
 
        if (!event->registered)
@@ -1249,30 +1403,36 @@ int _lttng_event_unregister(struct lttng_event *event)
 
        desc = event->desc;
        switch (event->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-               ret = lttng_wrapper_tracepoint_probe_unregister(event->desc->kname,
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
+               ret = lttng_wrapper_tracepoint_probe_unregister(event->desc->event_kname,
                                                  event->desc->probe_callback,
                                                  event);
                break;
-       case LTTNG_KERNEL_KPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:
                lttng_kprobes_unregister_event(event);
                ret = 0;
                break;
-       case LTTNG_KERNEL_KRETPROBE:
+
+       case LTTNG_KERNEL_ABI_KRETPROBE:
                lttng_kretprobes_unregister(event);
                ret = 0;
                break;
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                ret = lttng_syscall_filter_disable_event(event->chan, event);
                break;
-       case LTTNG_KERNEL_NOOP:
+
+       case LTTNG_KERNEL_ABI_NOOP:
                ret = 0;
                break;
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_UPROBE:
                lttng_uprobes_unregister_event(event);
                ret = 0;
                break;
-       case LTTNG_KERNEL_FUNCTION:     /* Fall-through */
+
+       case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
        default:
                WARN_ON_ONCE(1);
        }
@@ -1285,7 +1445,7 @@ int _lttng_event_unregister(struct lttng_event *event)
 static
 void register_event_notifier(struct lttng_event_notifier *event_notifier)
 {
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        int ret = -EINVAL;
 
        if (event_notifier->registered)
@@ -1293,21 +1453,24 @@ void register_event_notifier(struct lttng_event_notifier *event_notifier)
 
        desc = event_notifier->desc;
        switch (event_notifier->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-               ret = lttng_wrapper_tracepoint_probe_register(desc->kname,
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
+               ret = lttng_wrapper_tracepoint_probe_register(desc->event_kname,
                                                  desc->event_notifier_callback,
                                                  event_notifier);
                break;
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                ret = lttng_syscall_filter_enable_event_notifier(event_notifier);
                break;
-       case LTTNG_KERNEL_KPROBE:
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:           /* Fall-through */
+       case LTTNG_KERNEL_ABI_UPROBE:
                ret = 0;
                break;
-       case LTTNG_KERNEL_KRETPROBE:
-       case LTTNG_KERNEL_FUNCTION:
-       case LTTNG_KERNEL_NOOP:
+
+       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);
        }
@@ -1319,7 +1482,7 @@ static
 int _lttng_event_notifier_unregister(
                struct lttng_event_notifier *event_notifier)
 {
-       const struct lttng_event_desc *desc;
+       const struct lttng_kernel_event_desc *desc;
        int ret = -EINVAL;
 
        if (!event_notifier->registered)
@@ -1327,25 +1490,29 @@ int _lttng_event_notifier_unregister(
 
        desc = event_notifier->desc;
        switch (event_notifier->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-               ret = lttng_wrapper_tracepoint_probe_unregister(event_notifier->desc->kname,
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
+               ret = lttng_wrapper_tracepoint_probe_unregister(event_notifier->desc->event_kname,
                                                  event_notifier->desc->event_notifier_callback,
                                                  event_notifier);
                break;
-       case LTTNG_KERNEL_KPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:
                lttng_kprobes_unregister_event_notifier(event_notifier);
                ret = 0;
                break;
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_UPROBE:
                lttng_uprobes_unregister_event_notifier(event_notifier);
                ret = 0;
                break;
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                ret = lttng_syscall_filter_disable_event_notifier(event_notifier);
                break;
-       case LTTNG_KERNEL_KRETPROBE:
-       case LTTNG_KERNEL_FUNCTION:
-       case LTTNG_KERNEL_NOOP:
+
+       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);
        }
@@ -1360,31 +1527,43 @@ int _lttng_event_notifier_unregister(
 static
 void _lttng_event_destroy(struct lttng_event *event)
 {
+       struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
+
        switch (event->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
                lttng_event_desc_put(event->desc);
                break;
-       case LTTNG_KERNEL_KPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:
                module_put(event->desc->owner);
                lttng_kprobes_destroy_event_private(event);
                break;
-       case LTTNG_KERNEL_KRETPROBE:
+
+       case LTTNG_KERNEL_ABI_KRETPROBE:
                module_put(event->desc->owner);
                lttng_kretprobes_destroy_private(event);
                break;
-       case LTTNG_KERNEL_NOOP:
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                break;
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_UPROBE:
                module_put(event->desc->owner);
                lttng_uprobes_destroy_event_private(event);
                break;
-       case LTTNG_KERNEL_FUNCTION:     /* Fall-through */
+
+       case LTTNG_KERNEL_ABI_FUNCTION:         /* Fall-through */
+       case LTTNG_KERNEL_ABI_NOOP:             /* Fall-through */
        default:
                WARN_ON_ONCE(1);
        }
        list_del(&event->list);
-       lttng_destroy_context(event->ctx);
+       lttng_kernel_destroy_context(event->ctx);
+       lttng_free_event_filter_runtime(event);
+       /* Free event enabler refs */
+       list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
+                                &event->enablers_ref_head, node)
+               kfree(enabler_ref);
        kmem_cache_free(event_cache, event);
 }
 
@@ -1394,27 +1573,38 @@ void _lttng_event_destroy(struct lttng_event *event)
 static
 void _lttng_event_notifier_destroy(struct lttng_event_notifier *event_notifier)
 {
+       struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
+
        switch (event_notifier->instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
                lttng_event_desc_put(event_notifier->desc);
                break;
-       case LTTNG_KERNEL_KPROBE:
+
+       case LTTNG_KERNEL_ABI_KPROBE:
                module_put(event_notifier->desc->owner);
                lttng_kprobes_destroy_event_notifier_private(event_notifier);
                break;
-       case LTTNG_KERNEL_NOOP:
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                break;
-       case LTTNG_KERNEL_UPROBE:
+
+       case LTTNG_KERNEL_ABI_UPROBE:
                module_put(event_notifier->desc->owner);
                lttng_uprobes_destroy_event_notifier_private(event_notifier);
                break;
-       case LTTNG_KERNEL_KRETPROBE:
-       case LTTNG_KERNEL_FUNCTION:
+
+       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->list);
+       lttng_free_event_notifier_filter_runtime(event_notifier);
+       /* Free event enabler refs */
+       list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
+                                &event_notifier->enablers_ref_head, node)
+               kfree(enabler_ref);
        kmem_cache_free(event_notifier_cache, event_notifier);
 }
 
@@ -1693,7 +1883,7 @@ int lttng_match_enabler_name(const char *desc_name,
        return 1;
 }
 
-int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
+int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
                struct lttng_enabler *enabler)
 {
        const char *desc_name, *enabler_name;
@@ -1701,8 +1891,8 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
 
        enabler_name = enabler->event_param.name;
        switch (enabler->event_param.instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
-               desc_name = desc->name;
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
+               desc_name = desc->event_name;
                switch (enabler->format_type) {
                case LTTNG_ENABLER_FORMAT_STAR_GLOB:
                        return lttng_match_enabler_star_glob(desc_name, enabler_name);
@@ -1712,8 +1902,9 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
                        return -EINVAL;
                }
                break;
-       case LTTNG_KERNEL_SYSCALL:
-               desc_name = desc->name;
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
+               desc_name = desc->event_name;
                if (!strncmp(desc_name, "compat_", strlen("compat_"))) {
                        desc_name += strlen("compat_");
                        compat = true;
@@ -1730,13 +1921,13 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
                        return -EINVAL;
                }
                switch (enabler->event_param.u.syscall.entryexit) {
-               case LTTNG_KERNEL_SYSCALL_ENTRYEXIT:
+               case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
                        break;
-               case LTTNG_KERNEL_SYSCALL_ENTRY:
+               case LTTNG_KERNEL_ABI_SYSCALL_ENTRY:
                        if (!entry)
                                return 0;
                        break;
-               case LTTNG_KERNEL_SYSCALL_EXIT:
+               case LTTNG_KERNEL_ABI_SYSCALL_EXIT:
                        if (entry)
                                return 0;
                        break;
@@ -1744,13 +1935,13 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
                        return -EINVAL;
                }
                switch (enabler->event_param.u.syscall.abi) {
-               case LTTNG_KERNEL_SYSCALL_ABI_ALL:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL:
                        break;
-               case LTTNG_KERNEL_SYSCALL_ABI_NATIVE:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE:
                        if (compat)
                                return 0;
                        break;
-               case LTTNG_KERNEL_SYSCALL_ABI_COMPAT:
+               case LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT:
                        if (!compat)
                                return 0;
                        break;
@@ -1758,7 +1949,7 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
                        return -EINVAL;
                }
                switch (enabler->event_param.u.syscall.match) {
-               case LTTNG_KERNEL_SYSCALL_MATCH_NAME:
+               case LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME:
                        switch (enabler->format_type) {
                        case LTTNG_ENABLER_FORMAT_STAR_GLOB:
                                return lttng_match_enabler_star_glob(desc_name, enabler_name);
@@ -1768,12 +1959,13 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
                                return -EINVAL;
                        }
                        break;
-               case LTTNG_KERNEL_SYSCALL_MATCH_NR:
+               case LTTNG_KERNEL_ABI_SYSCALL_MATCH_NR:
                        return -EINVAL; /* Not implemented. */
                default:
                        return -EINVAL;
                }
                break;
+
        default:
                WARN_ON_ONCE(1);
                return -EINVAL;
@@ -1831,8 +2023,8 @@ static
 void lttng_create_tracepoint_event_if_missing(struct lttng_event_enabler *event_enabler)
 {
        struct lttng_session *session = event_enabler->chan->session;
-       struct lttng_probe_desc *probe_desc;
-       const struct lttng_event_desc *desc;
+       struct lttng_kernel_probe_desc *probe_desc;
+       const struct lttng_kernel_event_desc *desc;
        int i;
        struct list_head *probe_list;
 
@@ -1858,7 +2050,7 @@ void lttng_create_tracepoint_event_if_missing(struct lttng_event_enabler *event_
                         */
                        head = utils_borrow_hash_table_bucket(
                                session->events_ht.table, LTTNG_EVENT_HT_SIZE,
-                               desc->name);
+                               desc->event_name);
                        lttng_hlist_for_each_entry(event, head, hlist) {
                                if (event->desc == desc
                                                && event->chan == event_enabler->chan)
@@ -1873,10 +2065,10 @@ void lttng_create_tracepoint_event_if_missing(struct lttng_event_enabler *event_
                         */
                        event = _lttng_event_create(event_enabler->chan,
                                        NULL, NULL, desc,
-                                       LTTNG_KERNEL_TRACEPOINT);
+                                       LTTNG_KERNEL_ABI_TRACEPOINT);
                        if (!event) {
                                printk(KERN_INFO "LTTng: Unable to create event %s\n",
-                                       probe_desc->event_desc[i]->name);
+                                       probe_desc->event_desc[i]->event_name);
                        }
                }
        }
@@ -1886,8 +2078,8 @@ static
 void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifier_enabler *event_notifier_enabler)
 {
        struct lttng_event_notifier_group *event_notifier_group = event_notifier_enabler->group;
-       struct lttng_probe_desc *probe_desc;
-       const struct lttng_event_desc *desc;
+       struct lttng_kernel_probe_desc *probe_desc;
+       const struct lttng_kernel_event_desc *desc;
        int i;
        struct list_head *probe_list;
 
@@ -1913,7 +2105,7 @@ void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifi
                         */
                        head = utils_borrow_hash_table_bucket(
                                event_notifier_group->event_notifiers_ht.table,
-                               LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->name);
+                               LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->event_name);
                        lttng_hlist_for_each_entry(event_notifier, head, hlist) {
                                if (event_notifier->desc == desc
                                                && event_notifier->user_token == event_notifier_enabler->base.user_token)
@@ -1927,11 +2119,12 @@ void lttng_create_tracepoint_event_notifier_if_missing(struct lttng_event_notifi
                         */
                        event_notifier = _lttng_event_notifier_create(desc,
                                event_notifier_enabler->base.user_token,
+                               event_notifier_enabler->error_counter_index,
                                event_notifier_group, NULL, NULL,
-                               LTTNG_KERNEL_TRACEPOINT);
+                               LTTNG_KERNEL_ABI_TRACEPOINT);
                        if (IS_ERR(event_notifier)) {
                                printk(KERN_INFO "Unable to create event_notifier %s\n",
-                                       probe_desc->event_desc[i]->name);
+                                       probe_desc->event_desc[i]->event_name);
                        }
                }
        }
@@ -1942,7 +2135,7 @@ void lttng_create_syscall_event_if_missing(struct lttng_event_enabler *event_ena
 {
        int ret;
 
-       ret = lttng_syscalls_register_event(event_enabler->chan, NULL);
+       ret = lttng_syscalls_register_event(event_enabler, NULL);
        WARN_ON_ONCE(ret);
 }
 
@@ -1966,12 +2159,14 @@ static
 void lttng_create_event_if_missing(struct lttng_event_enabler *event_enabler)
 {
        switch (event_enabler->base.event_param.instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
                lttng_create_tracepoint_event_if_missing(event_enabler);
                break;
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                lttng_create_syscall_event_if_missing(event_enabler);
                break;
+
        default:
                WARN_ON_ONCE(1);
                break;
@@ -1991,15 +2186,18 @@ int lttng_event_enabler_ref_events(struct lttng_event_enabler *event_enabler)
        struct lttng_enabler *base_enabler = lttng_event_enabler_as_enabler(event_enabler);
        struct lttng_event *event;
 
-       if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_SYSCALL &&
-                       base_enabler->event_param.u.syscall.entryexit == LTTNG_KERNEL_SYSCALL_ENTRYEXIT &&
-                       base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_SYSCALL_ABI_ALL &&
-                       base_enabler->event_param.u.syscall.match == LTTNG_KERNEL_SYSCALL_MATCH_NAME &&
+       if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_ABI_SYSCALL &&
+                       base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL &&
+                       base_enabler->event_param.u.syscall.match == LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME &&
                        !strcmp(base_enabler->event_param.name, "*")) {
-               if (base_enabler->enabled)
-                       WRITE_ONCE(chan->syscall_all, 1);
-               else
-                       WRITE_ONCE(chan->syscall_all, 0);
+               int enabled = base_enabler->enabled;
+               enum lttng_kernel_abi_syscall_entryexit entryexit = base_enabler->event_param.u.syscall.entryexit;
+
+               if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
+                       WRITE_ONCE(chan->syscall_all_entry, enabled);
+
+               if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
+                       WRITE_ONCE(chan->syscall_all_exit, enabled);
        }
 
        /* First ensure that probe events are created for this enabler. */
@@ -2048,12 +2246,14 @@ static
 void lttng_create_event_notifier_if_missing(struct lttng_event_notifier_enabler *event_notifier_enabler)
 {
        switch (event_notifier_enabler->base.event_param.instrumentation) {
-       case LTTNG_KERNEL_TRACEPOINT:
+       case LTTNG_KERNEL_ABI_TRACEPOINT:
                lttng_create_tracepoint_event_notifier_if_missing(event_notifier_enabler);
                break;
-       case LTTNG_KERNEL_SYSCALL:
+
+       case LTTNG_KERNEL_ABI_SYSCALL:
                lttng_create_syscall_event_notifier_if_missing(event_notifier_enabler);
                break;
+
        default:
                WARN_ON_ONCE(1);
                break;
@@ -2071,18 +2271,18 @@ int lttng_event_notifier_enabler_ref_event_notifiers(
        struct lttng_enabler *base_enabler = lttng_event_notifier_enabler_as_enabler(event_notifier_enabler);
        struct lttng_event_notifier *event_notifier;
 
-       if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_SYSCALL &&
-                       base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_SYSCALL_ABI_ALL &&
-                       base_enabler->event_param.u.syscall.match == LTTNG_KERNEL_SYSCALL_MATCH_NAME &&
+       if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_ABI_SYSCALL &&
+                       base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL &&
+                       base_enabler->event_param.u.syscall.match == LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME &&
                        !strcmp(base_enabler->event_param.name, "*")) {
 
                int enabled = base_enabler->enabled;
-               enum lttng_kernel_syscall_entryexit entryexit = base_enabler->event_param.u.syscall.entryexit;
+               enum lttng_kernel_abi_syscall_entryexit entryexit = base_enabler->event_param.u.syscall.entryexit;
 
-               if (entryexit == LTTNG_KERNEL_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_SYSCALL_ENTRYEXIT)
+               if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
                        WRITE_ONCE(event_notifier_group->syscall_all_entry, enabled);
 
-               if (entryexit == LTTNG_KERNEL_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_SYSCALL_ENTRYEXIT)
+               if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
                        WRITE_ONCE(event_notifier_group->syscall_all_exit, enabled);
 
        }
@@ -2120,6 +2320,13 @@ int lttng_event_notifier_enabler_ref_event_notifiers(
                lttng_enabler_link_bytecode(event_notifier->desc,
                        lttng_static_ctx, &event_notifier->filter_bytecode_runtime_head,
                        &lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)->filter_bytecode_head);
+
+               /* Link capture bytecodes if not linked yet. */
+               lttng_enabler_link_bytecode(event_notifier->desc,
+                       lttng_static_ctx, &event_notifier->capture_bytecode_runtime_head,
+                       &event_notifier_enabler->capture_bytecode_head);
+
+               event_notifier->num_captures = event_notifier_enabler->num_captures;
        }
        return 0;
 }
@@ -2173,7 +2380,7 @@ int lttng_fix_pending_event_notifiers(void)
 
 struct lttng_event_enabler *lttng_event_enabler_create(
                enum lttng_enabler_format_type format_type,
-               struct lttng_kernel_event *event_param,
+               struct lttng_kernel_abi_event *event_param,
                struct lttng_channel *chan)
 {
        struct lttng_event_enabler *event_enabler;
@@ -2188,7 +2395,6 @@ struct lttng_event_enabler *lttng_event_enabler_create(
        event_enabler->chan = chan;
        /* ctx left NULL */
        event_enabler->base.enabled = 0;
-       event_enabler->base.evtype = LTTNG_TYPE_ENABLER;
        mutex_lock(&sessions_mutex);
        list_add(&event_enabler->node, &event_enabler->chan->session->enablers_head);
        lttng_session_lazy_sync_event_enablers(event_enabler->chan->session);
@@ -2216,7 +2422,7 @@ int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler)
 
 static
 int lttng_enabler_attach_filter_bytecode(struct lttng_enabler *enabler,
-               struct lttng_kernel_filter_bytecode __user *bytecode)
+               struct lttng_kernel_abi_filter_bytecode __user *bytecode)
 {
        struct lttng_bytecode_node *bytecode_node;
        uint32_t bytecode_len;
@@ -2225,7 +2431,7 @@ int lttng_enabler_attach_filter_bytecode(struct lttng_enabler *enabler,
        ret = get_user(bytecode_len, &bytecode->len);
        if (ret)
                return ret;
-       bytecode_node = kzalloc(sizeof(*bytecode_node) + bytecode_len,
+       bytecode_node = lttng_kvzalloc(sizeof(*bytecode_node) + bytecode_len,
                        GFP_KERNEL);
        if (!bytecode_node)
                return -ENOMEM;
@@ -2243,12 +2449,12 @@ int lttng_enabler_attach_filter_bytecode(struct lttng_enabler *enabler,
        return 0;
 
 error_free:
-       kfree(bytecode_node);
+       lttng_kvfree(bytecode_node);
        return ret;
 }
 
 int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler,
-               struct lttng_kernel_filter_bytecode __user *bytecode)
+               struct lttng_kernel_abi_filter_bytecode __user *bytecode)
 {
        int ret;
        ret = lttng_enabler_attach_filter_bytecode(
@@ -2264,23 +2470,17 @@ error:
 }
 
 int lttng_event_add_callsite(struct lttng_event *event,
-               struct lttng_kernel_event_callsite __user *callsite)
+               struct lttng_kernel_abi_event_callsite __user *callsite)
 {
 
        switch (event->instrumentation) {
-       case LTTNG_KERNEL_UPROBE:
+       case LTTNG_KERNEL_ABI_UPROBE:
                return lttng_uprobes_event_add_callsite(event, callsite);
        default:
                return -EINVAL;
        }
 }
 
-int lttng_event_enabler_attach_context(struct lttng_event_enabler *event_enabler,
-               struct lttng_kernel_context *context_param)
-{
-       return -ENOSYS;
-}
-
 static
 void lttng_enabler_destroy(struct lttng_enabler *enabler)
 {
@@ -2289,7 +2489,7 @@ void lttng_enabler_destroy(struct lttng_enabler *enabler)
        /* Destroy filter bytecode */
        list_for_each_entry_safe(filter_node, tmp_filter_node,
                        &enabler->filter_bytecode_head, node) {
-               kfree(filter_node);
+               lttng_kvfree(filter_node);
        }
 }
 
@@ -2299,7 +2499,7 @@ void lttng_event_enabler_destroy(struct lttng_event_enabler *event_enabler)
        lttng_enabler_destroy(lttng_event_enabler_as_enabler(event_enabler));
 
        /* Destroy contexts */
-       lttng_destroy_context(event_enabler->ctx);
+       lttng_kernel_destroy_context(event_enabler->ctx);
 
        list_del(&event_enabler->node);
        kfree(event_enabler);
@@ -2308,7 +2508,7 @@ void lttng_event_enabler_destroy(struct lttng_event_enabler *event_enabler)
 struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
                struct lttng_event_notifier_group *event_notifier_group,
                enum lttng_enabler_format_type format_type,
-               struct lttng_kernel_event_notifier *event_notifier_param)
+               struct lttng_kernel_abi_event_notifier *event_notifier_param)
 {
        struct lttng_event_notifier_enabler *event_notifier_enabler;
 
@@ -2318,10 +2518,13 @@ struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
 
        event_notifier_enabler->base.format_type = format_type;
        INIT_LIST_HEAD(&event_notifier_enabler->base.filter_bytecode_head);
+       INIT_LIST_HEAD(&event_notifier_enabler->capture_bytecode_head);
+
+       event_notifier_enabler->error_counter_index = event_notifier_param->error_counter_index;
+       event_notifier_enabler->num_captures = 0;
 
        memcpy(&event_notifier_enabler->base.event_param, &event_notifier_param->event,
                sizeof(event_notifier_enabler->base.event_param));
-       event_notifier_enabler->base.evtype = LTTNG_TYPE_ENABLER;
 
        event_notifier_enabler->base.enabled = 0;
        event_notifier_enabler->base.user_token = event_notifier_param->event.token;
@@ -2358,7 +2561,7 @@ int lttng_event_notifier_enabler_disable(
 
 int lttng_event_notifier_enabler_attach_filter_bytecode(
                struct lttng_event_notifier_enabler *event_notifier_enabler,
-               struct lttng_kernel_filter_bytecode __user *bytecode)
+               struct lttng_kernel_abi_filter_bytecode __user *bytecode)
 {
        int ret;
 
@@ -2375,12 +2578,54 @@ error:
        return ret;
 }
 
+int lttng_event_notifier_enabler_attach_capture_bytecode(
+               struct lttng_event_notifier_enabler *event_notifier_enabler,
+               struct lttng_kernel_abi_capture_bytecode __user *bytecode)
+{
+       struct lttng_bytecode_node *bytecode_node;
+       struct lttng_enabler *enabler =
+                       lttng_event_notifier_enabler_as_enabler(event_notifier_enabler);
+       uint32_t bytecode_len;
+       int ret;
+
+       ret = get_user(bytecode_len, &bytecode->len);
+       if (ret)
+               return ret;
+
+       bytecode_node = lttng_kvzalloc(sizeof(*bytecode_node) + bytecode_len,
+                       GFP_KERNEL);
+       if (!bytecode_node)
+               return -ENOMEM;
+
+       ret = copy_from_user(&bytecode_node->bc, bytecode,
+               sizeof(*bytecode) + bytecode_len);
+       if (ret)
+               goto error_free;
+
+       bytecode_node->type = LTTNG_BYTECODE_NODE_TYPE_CAPTURE;
+       bytecode_node->enabler = enabler;
+
+       /* Enforce length based on allocated size */
+       bytecode_node->bc.len = bytecode_len;
+       list_add_tail(&bytecode_node->node, &event_notifier_enabler->capture_bytecode_head);
+
+       event_notifier_enabler->num_captures++;
+
+       lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
+       goto end;
+
+error_free:
+       lttng_kvfree(bytecode_node);
+end:
+       return ret;
+}
+
 int lttng_event_notifier_add_callsite(struct lttng_event_notifier *event_notifier,
-               struct lttng_kernel_event_callsite __user *callsite)
+               struct lttng_kernel_abi_event_callsite __user *callsite)
 {
 
        switch (event_notifier->instrumentation) {
-       case LTTNG_KERNEL_UPROBE:
+       case LTTNG_KERNEL_ABI_UPROBE:
                return lttng_uprobes_event_notifier_add_callsite(event_notifier,
                                callsite);
        default:
@@ -2388,13 +2633,6 @@ int lttng_event_notifier_add_callsite(struct lttng_event_notifier *event_notifie
        }
 }
 
-int lttng_event_notifier_enabler_attach_context(
-               struct lttng_event_notifier_enabler *event_notifier_enabler,
-               struct lttng_kernel_context *context_param)
-{
-       return -ENOSYS;
-}
-
 static
 void lttng_event_notifier_enabler_destroy(
                struct lttng_event_notifier_enabler *event_notifier_enabler)
@@ -2433,8 +2671,8 @@ void lttng_session_sync_event_enablers(struct lttng_session *session)
                int enabled = 0, has_enablers_without_bytecode = 0;
 
                switch (event->instrumentation) {
-               case LTTNG_KERNEL_TRACEPOINT:
-               case LTTNG_KERNEL_SYSCALL:
+               case LTTNG_KERNEL_ABI_TRACEPOINT:       /* Fall-through */
+               case LTTNG_KERNEL_ABI_SYSCALL:
                        /* Enable events */
                        list_for_each_entry(enabler_ref,
                                        &event->enablers_ref_head, node) {
@@ -2444,6 +2682,7 @@ void lttng_session_sync_event_enablers(struct lttng_session *session)
                                }
                        }
                        break;
+
                default:
                        /* Not handled with lazy sync. */
                        continue;
@@ -2520,8 +2759,8 @@ void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group
                int enabled = 0, has_enablers_without_bytecode = 0;
 
                switch (event_notifier->instrumentation) {
-               case LTTNG_KERNEL_TRACEPOINT:
-               case LTTNG_KERNEL_SYSCALL:
+               case LTTNG_KERNEL_ABI_TRACEPOINT:       /* Fall-through */
+               case LTTNG_KERNEL_ABI_SYSCALL:
                        /* Enable event_notifiers */
                        list_for_each_entry(enabler_ref,
                                        &event_notifier->enablers_ref_head, node) {
@@ -2531,6 +2770,7 @@ void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group
                                }
                        }
                        break;
+
                default:
                        /* Not handled with sync. */
                        continue;
@@ -2565,6 +2805,13 @@ void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group
                list_for_each_entry(runtime,
                                &event_notifier->filter_bytecode_runtime_head, node)
                        lttng_bytecode_filter_sync_state(runtime);
+
+               /* Enable captures */
+               list_for_each_entry(runtime,
+                               &event_notifier->capture_bytecode_runtime_head, node)
+                       lttng_bytecode_capture_sync_state(runtime);
+
+               WRITE_ONCE(event_notifier->eval_capture, !!event_notifier->num_captures);
        }
 }
 
@@ -2738,7 +2985,7 @@ int print_tabs(struct lttng_session *session, size_t nesting)
 
 static
 int lttng_field_name_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        return lttng_metadata_printf(session, " _%s;\n", field->name);
@@ -2746,30 +2993,30 @@ int lttng_field_name_statedump(struct lttng_session *session,
 
 static
 int _lttng_integer_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_integer *type,
+               enum lttng_kernel_string_encoding parent_encoding,
                size_t nesting)
 {
        int ret;
 
-       WARN_ON_ONCE(type->atype != atype_integer);
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
        ret = lttng_metadata_printf(session,
                "integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s }",
-               type->u.integer.size,
-               type->u.integer.alignment,
-               type->u.integer.signedness,
-               (type->u.integer.encoding == lttng_encode_none)
+               type->size,
+               type->alignment,
+               type->signedness,
+               (parent_encoding == lttng_kernel_string_encoding_none)
                        ? "none"
-                       : (type->u.integer.encoding == lttng_encode_UTF8)
+                       : (parent_encoding == lttng_kernel_string_encoding_UTF8)
                                ? "UTF8"
                                : "ASCII",
-               type->u.integer.base,
+               type->base,
 #if __BYTE_ORDER == __BIG_ENDIAN
-               type->u.integer.reverse_byte_order ? " byte_order = le;" : ""
+               type->reverse_byte_order ? " byte_order = le;" : ""
 #else
-               type->u.integer.reverse_byte_order ? " byte_order = be;" : ""
+               type->reverse_byte_order ? " byte_order = be;" : ""
 #endif
        );
        return ret;
@@ -2780,15 +3027,13 @@ int _lttng_integer_type_statedump(struct lttng_session *session,
  */
 static
 int _lttng_struct_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_struct *type,
                size_t nesting)
 {
        int ret;
        uint32_t i, nr_fields;
        unsigned int alignment;
 
-       WARN_ON_ONCE(type->atype != atype_struct_nestable);
-
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
@@ -2796,11 +3041,11 @@ int _lttng_struct_type_statedump(struct lttng_session *session,
                "struct {\n");
        if (ret)
                return ret;
-       nr_fields = type->u.struct_nestable.nr_fields;
+       nr_fields = type->nr_fields;
        for (i = 0; i < nr_fields; i++) {
-               const struct lttng_event_field *iter_field;
+               const struct lttng_kernel_event_field *iter_field;
 
-               iter_field = &type->u.struct_nestable.fields[i];
+               iter_field = type->fields[i];
                ret = _lttng_field_statedump(session, iter_field, nesting + 1);
                if (ret)
                        return ret;
@@ -2808,7 +3053,7 @@ int _lttng_struct_type_statedump(struct lttng_session *session,
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
-       alignment = type->u.struct_nestable.alignment;
+       alignment = type->alignment;
        if (alignment) {
                ret = lttng_metadata_printf(session,
                        "} align(%u)",
@@ -2825,13 +3070,13 @@ int _lttng_struct_type_statedump(struct lttng_session *session,
  */
 static
 int _lttng_struct_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
 
        ret = _lttng_struct_type_statedump(session,
-                       &field->type, nesting);
+                       lttng_kernel_get_type_struct(field->type), nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -2842,31 +3087,30 @@ int _lttng_struct_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_variant_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_variant *type,
                size_t nesting)
 {
        int ret;
        uint32_t i, nr_choices;
 
-       WARN_ON_ONCE(type->atype != atype_variant_nestable);
        /*
         * CTF 1.8 does not allow expressing nonzero variant alignment in a nestable way.
         */
-       if (type->u.variant_nestable.alignment != 0)
+       if (type->alignment != 0)
                return -EINVAL;
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
        ret = lttng_metadata_printf(session,
                "variant <_%s> {\n",
-               type->u.variant_nestable.tag_name);
+               type->tag_name);
        if (ret)
                return ret;
-       nr_choices = type->u.variant_nestable.nr_choices;
+       nr_choices = type->nr_choices;
        for (i = 0; i < nr_choices; i++) {
-               const struct lttng_event_field *iter_field;
+               const struct lttng_kernel_event_field *iter_field;
 
-               iter_field = &type->u.variant_nestable.choices[i];
+               iter_field = type->choices[i];
                ret = _lttng_field_statedump(session, iter_field, nesting + 1);
                if (ret)
                        return ret;
@@ -2884,13 +3128,13 @@ int _lttng_variant_type_statedump(struct lttng_session *session,
  */
 static
 int _lttng_variant_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
 
        ret = _lttng_variant_type_statedump(session,
-                       &field->type, nesting);
+                       lttng_kernel_get_type_variant(field->type), nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -2901,21 +3145,23 @@ int _lttng_variant_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_array_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
-       const struct lttng_type *elem_type;
+       const struct lttng_kernel_type_array *array_type;
+       const struct lttng_kernel_type_common *elem_type;
 
-       WARN_ON_ONCE(field->type.atype != atype_array_nestable);
+       array_type = lttng_kernel_get_type_array(field->type);
+       WARN_ON_ONCE(!array_type);
 
-       if (field->type.u.array_nestable.alignment) {
+       if (array_type->alignment) {
                ret = print_tabs(session, nesting);
                if (ret)
                        return ret;
                ret = lttng_metadata_printf(session,
                "struct { } align(%u) _%s_padding;\n",
-                               field->type.u.array_nestable.alignment * CHAR_BIT,
+                               array_type->alignment * CHAR_BIT,
                                field->name);
                if (ret)
                        return ret;
@@ -2924,12 +3170,13 @@ int _lttng_array_field_statedump(struct lttng_session *session,
         * Nested compound types: Only array of structures and variants are
         * currently supported.
         */
-       elem_type = field->type.u.array_nestable.elem_type;
-       switch (elem_type->atype) {
-       case atype_integer:
-       case atype_struct_nestable:
-       case atype_variant_nestable:
-               ret = _lttng_type_statedump(session, elem_type, nesting);
+       elem_type = array_type->elem_type;
+       switch (elem_type->type) {
+       case lttng_kernel_type_integer:
+       case lttng_kernel_type_struct:
+       case lttng_kernel_type_variant:
+               ret = _lttng_type_statedump(session, elem_type,
+                               array_type->encoding, nesting);
                if (ret)
                        return ret;
                break;
@@ -2940,7 +3187,7 @@ int _lttng_array_field_statedump(struct lttng_session *session,
        ret = lttng_metadata_printf(session,
                " _%s[%u];\n",
                field->name,
-               field->type.u.array_nestable.length);
+               array_type->length);
        return ret;
 }
 
@@ -2949,24 +3196,26 @@ int _lttng_array_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_sequence_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
        const char *length_name;
-       const struct lttng_type *elem_type;
+       const struct lttng_kernel_type_sequence *sequence_type;
+       const struct lttng_kernel_type_common *elem_type;
 
-       WARN_ON_ONCE(field->type.atype != atype_sequence_nestable);
+       sequence_type = lttng_kernel_get_type_sequence(field->type);
+       WARN_ON_ONCE(!sequence_type);
 
-       length_name = field->type.u.sequence_nestable.length_name;
+       length_name = sequence_type->length_name;
 
-       if (field->type.u.sequence_nestable.alignment) {
+       if (sequence_type->alignment) {
                ret = print_tabs(session, nesting);
                if (ret)
                        return ret;
                ret = lttng_metadata_printf(session,
                "struct { } align(%u) _%s_padding;\n",
-                               field->type.u.sequence_nestable.alignment * CHAR_BIT,
+                               sequence_type->alignment * CHAR_BIT,
                                field->name);
                if (ret)
                        return ret;
@@ -2976,12 +3225,13 @@ int _lttng_sequence_field_statedump(struct lttng_session *session,
         * Nested compound types: Only array of structures and variants are
         * currently supported.
         */
-       elem_type = field->type.u.sequence_nestable.elem_type;
-       switch (elem_type->atype) {
-       case atype_integer:
-       case atype_struct_nestable:
-       case atype_variant_nestable:
-               ret = _lttng_type_statedump(session, elem_type, nesting);
+       elem_type = sequence_type->elem_type;
+       switch (elem_type->type) {
+       case lttng_kernel_type_integer:
+       case lttng_kernel_type_struct:
+       case lttng_kernel_type_variant:
+               ret = _lttng_type_statedump(session, elem_type,
+                               sequence_type->encoding, nesting);
                if (ret)
                        return ret;
                break;
@@ -2992,7 +3242,7 @@ int _lttng_sequence_field_statedump(struct lttng_session *session,
        ret = lttng_metadata_printf(session,
                " _%s[ _%s ];\n",
                field->name,
-               field->type.u.sequence_nestable.length_name);
+               sequence_type->length_name);
        return ret;
 }
 
@@ -3001,20 +3251,20 @@ int _lttng_sequence_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_enum_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_enum *type,
                size_t nesting)
 {
-       const struct lttng_enum_desc *enum_desc;
-       const struct lttng_type *container_type;
+       const struct lttng_kernel_enum_desc *enum_desc;
+       const struct lttng_kernel_type_common *container_type;
        int ret;
        unsigned int i, nr_entries;
 
-       container_type = type->u.enum_nestable.container_type;
-       if (container_type->atype != atype_integer) {
+       container_type = type->container_type;
+       if (container_type->type != lttng_kernel_type_integer) {
                ret = -EINVAL;
                goto end;
        }
-       enum_desc = type->u.enum_nestable.desc;
+       enum_desc = type->desc;
        nr_entries = enum_desc->nr_entries;
 
        ret = print_tabs(session, nesting);
@@ -3023,7 +3273,8 @@ int _lttng_enum_type_statedump(struct lttng_session *session,
        ret = lttng_metadata_printf(session, "enum : ");
        if (ret)
                goto end;
-       ret = _lttng_integer_type_statedump(session, container_type, 0);
+       ret = _lttng_integer_type_statedump(session, lttng_kernel_get_type_integer(container_type),
+                       lttng_kernel_string_encoding_none, 0);
        if (ret)
                goto end;
        ret = lttng_metadata_printf(session, " {\n");
@@ -3031,7 +3282,7 @@ int _lttng_enum_type_statedump(struct lttng_session *session,
                goto end;
        /* Dump all entries */
        for (i = 0; i < nr_entries; i++) {
-               const struct lttng_enum_entry *entry = &enum_desc->entries[i];
+               const struct lttng_kernel_enum_entry *entry = enum_desc->entries[i];
                int j, len;
 
                ret = print_tabs(session, nesting + 1);
@@ -3117,12 +3368,15 @@ end:
  */
 static
 int _lttng_enum_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
+       const struct lttng_kernel_type_enum *enum_type;
 
-       ret = _lttng_enum_type_statedump(session, &field->type, nesting);
+       enum_type = lttng_kernel_get_type_enum(field->type);
+       WARN_ON_ONCE(!enum_type);
+       ret = _lttng_enum_type_statedump(session, enum_type, nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -3130,12 +3384,13 @@ int _lttng_enum_field_statedump(struct lttng_session *session,
 
 static
 int _lttng_integer_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret;
 
-       ret = _lttng_integer_type_statedump(session, &field->type, nesting);
+       ret = _lttng_integer_type_statedump(session, lttng_kernel_get_type_integer(field->type),
+                       lttng_kernel_string_encoding_none, nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -3143,32 +3398,33 @@ int _lttng_integer_field_statedump(struct lttng_session *session,
 
 static
 int _lttng_string_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_string *type,
                size_t nesting)
 {
        int ret;
 
-       WARN_ON_ONCE(type->atype != atype_string);
        /* Default encoding is UTF8 */
        ret = print_tabs(session, nesting);
        if (ret)
                return ret;
        ret = lttng_metadata_printf(session,
                "string%s",
-               type->u.string.encoding == lttng_encode_ASCII ?
+               type->encoding == lttng_kernel_string_encoding_ASCII ?
                        " { encoding = ASCII; }" : "");
        return ret;
 }
 
 static
 int _lttng_string_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
+       const struct lttng_kernel_type_string *string_type;
        int ret;
 
-       WARN_ON_ONCE(field->type.atype != atype_string);
-       ret = _lttng_string_type_statedump(session, &field->type, nesting);
+       string_type = lttng_kernel_get_type_string(field->type);
+       WARN_ON_ONCE(!string_type);
+       ret = _lttng_string_type_statedump(session, string_type, nesting);
        if (ret)
                return ret;
        return lttng_field_name_statedump(session, field, nesting);
@@ -3179,31 +3435,42 @@ int _lttng_string_field_statedump(struct lttng_session *session,
  */
 static
 int _lttng_type_statedump(struct lttng_session *session,
-               const struct lttng_type *type,
+               const struct lttng_kernel_type_common *type,
+               enum lttng_kernel_string_encoding parent_encoding,
                size_t nesting)
 {
        int ret = 0;
 
-       switch (type->atype) {
-       case atype_integer:
-               ret = _lttng_integer_type_statedump(session, type, nesting);
+       switch (type->type) {
+       case lttng_kernel_type_integer:
+               ret = _lttng_integer_type_statedump(session,
+                               lttng_kernel_get_type_integer(type),
+                               parent_encoding, nesting);
                break;
-       case atype_enum_nestable:
-               ret = _lttng_enum_type_statedump(session, type, nesting);
+       case lttng_kernel_type_enum:
+               ret = _lttng_enum_type_statedump(session,
+                               lttng_kernel_get_type_enum(type),
+                               nesting);
                break;
-       case atype_string:
-               ret = _lttng_string_type_statedump(session, type, nesting);
+       case lttng_kernel_type_string:
+               ret = _lttng_string_type_statedump(session,
+                               lttng_kernel_get_type_string(type),
+                               nesting);
                break;
-       case atype_struct_nestable:
-               ret = _lttng_struct_type_statedump(session, type, nesting);
+       case lttng_kernel_type_struct:
+               ret = _lttng_struct_type_statedump(session,
+                               lttng_kernel_get_type_struct(type),
+                               nesting);
                break;
-       case atype_variant_nestable:
-               ret = _lttng_variant_type_statedump(session, type, nesting);
+       case lttng_kernel_type_variant:
+               ret = _lttng_variant_type_statedump(session,
+                               lttng_kernel_get_type_variant(type),
+                               nesting);
                break;
 
        /* Nested arrays and sequences are not supported yet. */
-       case atype_array_nestable:
-       case atype_sequence_nestable:
+       case lttng_kernel_type_array:
+       case lttng_kernel_type_sequence:
        default:
                WARN_ON_ONCE(1);
                return -EINVAL;
@@ -3216,31 +3483,31 @@ int _lttng_type_statedump(struct lttng_session *session,
  */
 static
 int _lttng_field_statedump(struct lttng_session *session,
-               const struct lttng_event_field *field,
+               const struct lttng_kernel_event_field *field,
                size_t nesting)
 {
        int ret = 0;
 
-       switch (field->type.atype) {
-       case atype_integer:
+       switch (field->type->type) {
+       case lttng_kernel_type_integer:
                ret = _lttng_integer_field_statedump(session, field, nesting);
                break;
-       case atype_enum_nestable:
+       case lttng_kernel_type_enum:
                ret = _lttng_enum_field_statedump(session, field, nesting);
                break;
-       case atype_string:
+       case lttng_kernel_type_string:
                ret = _lttng_string_field_statedump(session, field, nesting);
                break;
-       case atype_struct_nestable:
+       case lttng_kernel_type_struct:
                ret = _lttng_struct_field_statedump(session, field, nesting);
                break;
-       case atype_array_nestable:
+       case lttng_kernel_type_array:
                ret = _lttng_array_field_statedump(session, field, nesting);
                break;
-       case atype_sequence_nestable:
+       case lttng_kernel_type_sequence:
                ret = _lttng_sequence_field_statedump(session, field, nesting);
                break;
-       case atype_variant_nestable:
+       case lttng_kernel_type_variant:
                ret = _lttng_variant_field_statedump(session, field, nesting);
                break;
 
@@ -3253,7 +3520,7 @@ int _lttng_field_statedump(struct lttng_session *session,
 
 static
 int _lttng_context_metadata_statedump(struct lttng_session *session,
-                                   struct lttng_ctx *ctx)
+                                   struct lttng_kernel_ctx *ctx)
 {
        int ret = 0;
        int i;
@@ -3261,9 +3528,9 @@ int _lttng_context_metadata_statedump(struct lttng_session *session,
        if (!ctx)
                return 0;
        for (i = 0; i < ctx->nr_fields; i++) {
-               const struct lttng_ctx_field *field = &ctx->fields[i];
+               const struct lttng_kernel_ctx_field *field = &ctx->fields[i];
 
-               ret = _lttng_field_statedump(session, &field->event_field, 2);
+               ret = _lttng_field_statedump(session, field->event_field, 2);
                if (ret)
                        return ret;
        }
@@ -3274,12 +3541,12 @@ static
 int _lttng_fields_metadata_statedump(struct lttng_session *session,
                                   struct lttng_event *event)
 {
-       const struct lttng_event_desc *desc = event->desc;
+       const struct lttng_kernel_event_desc *desc = event->desc;
        int ret = 0;
        int i;
 
        for (i = 0; i < desc->nr_fields; i++) {
-               const struct lttng_event_field *field = &desc->fields[i];
+               const struct lttng_kernel_event_field *field = desc->fields[i];
 
                ret = _lttng_field_statedump(session, field, 2);
                if (ret)
@@ -3312,7 +3579,7 @@ int _lttng_event_metadata_statedump(struct lttng_session *session,
                "       name = \"%s\";\n"
                "       id = %u;\n"
                "       stream_id = %u;\n",
-               event->desc->name,
+               event->desc->event_name,
                event->id,
                event->chan->id);
        if (ret)
@@ -3819,7 +4086,30 @@ void lttng_transport_unregister(struct lttng_transport *transport)
 }
 EXPORT_SYMBOL_GPL(lttng_transport_unregister);
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
+void lttng_counter_transport_register(struct lttng_counter_transport *transport)
+{
+       /*
+        * Make sure no page fault can be triggered by the module about to be
+        * registered. We deal with this here so we don't have to call
+        * vmalloc_sync_mappings() in each module's init.
+        */
+       wrapper_vmalloc_sync_mappings();
+
+       mutex_lock(&sessions_mutex);
+       list_add_tail(&transport->node, &lttng_counter_transport_list);
+       mutex_unlock(&sessions_mutex);
+}
+EXPORT_SYMBOL_GPL(lttng_counter_transport_register);
+
+void lttng_counter_transport_unregister(struct lttng_counter_transport *transport)
+{
+       mutex_lock(&sessions_mutex);
+       list_del(&transport->node);
+       mutex_unlock(&sessions_mutex);
+}
+EXPORT_SYMBOL_GPL(lttng_counter_transport_unregister);
+
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0))
 
 enum cpuhp_state lttng_hp_prepare;
 enum cpuhp_state lttng_hp_online;
@@ -3935,7 +4225,7 @@ static void __exit lttng_exit_cpu_hotplug(void)
        cpuhp_remove_multi_state(lttng_hp_prepare);
 }
 
-#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) */
+#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
 static int lttng_init_cpu_hotplug(void)
 {
        return 0;
@@ -3943,7 +4233,7 @@ static int lttng_init_cpu_hotplug(void)
 static void lttng_exit_cpu_hotplug(void)
 {
 }
-#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) */
+#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) */
 
 
 static int __init lttng_events_init(void)
This page took 0.055791 seconds and 4 git commands to generate.