Refactoring: syscall: combine syscall filter enable/disable recorder/notifier
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 2 Nov 2021 15:21:47 +0000 (11:21 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 2 Nov 2021 16:18:35 +0000 (12:18 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If0e10ade6586073255817f5a8a96f73b5aa92f99

include/lttng/events-internal.h
src/lttng-events.c
src/lttng-syscalls.c

index 8ac1869bf064b2d44fa1a0650e08c6bde881da6a..aceabbe4324bc6b397dc983d66a49f2347212440 100644 (file)
@@ -810,8 +810,8 @@ void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_des
 
 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
 int lttng_syscalls_register_event_recorder(struct lttng_event_recorder_enabler *event_enabler);
-int lttng_syscall_filter_enable_event_recorder(struct lttng_kernel_event_recorder *event_recorder);
-int lttng_syscall_filter_disable_event_recorder(struct lttng_kernel_event_recorder *event_recorder);
+int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common *event);
+int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common *event);
 
 int lttng_syscalls_unregister_syscall_table(struct lttng_kernel_syscall_table *syscall_table);
 int lttng_syscalls_destroy_syscall_table(struct lttng_kernel_syscall_table *syscall_table);
@@ -823,20 +823,18 @@ int lttng_syscalls_register_event_notifier(
                struct lttng_event_notifier_enabler *event_notifier_enabler);
 int lttng_syscalls_create_matching_event_notifiers(
                struct lttng_event_notifier_enabler *event_notifier_enabler);
-int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
-int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier);
 #else
 static inline int lttng_syscalls_register_event_recorder(struct lttng_event_recorder_enabler *event_enabler)
 {
        return -ENOSYS;
 }
 
-static inline int lttng_syscall_filter_enable_event_recorder(struct lttng_kernel_event_recorder *event_recorder)
+static inline int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common *event)
 {
        return -ENOSYS;
 }
 
-static inline int lttng_syscall_filter_disable_event_recorder(struct lttng_kernel_event_recorder *event_recorder)
+static inline int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common *event)
 {
        return -ENOSYS;
 }
@@ -868,16 +866,6 @@ static inline int lttng_syscalls_create_matching_event_notifiers(struct lttng_ev
        return -ENOSYS;
 }
 
-static inline int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
-{
-       return -ENOSYS;
-}
-
-static inline int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
-{
-       return -ENOSYS;
-}
-
 #endif
 
 #ifdef CONFIG_KPROBES
index 6907b5a0f347d069ee8f5472b661b51eae0512f4..270ee57309fb6fa1ead3a9ab7f8701514eb78902 100644 (file)
@@ -1456,7 +1456,7 @@ void register_event_recorder(struct lttng_kernel_event_recorder *event_recorder)
                break;
 
        case LTTNG_KERNEL_ABI_SYSCALL:
-               ret = lttng_syscall_filter_enable_event_recorder(event_recorder);
+               ret = lttng_syscall_filter_enable_event(&event_recorder->parent);
                break;
 
        case LTTNG_KERNEL_ABI_KPROBE:
@@ -1509,7 +1509,7 @@ int _lttng_event_recorder_unregister(struct lttng_kernel_event_recorder *event_r
                break;
 
        case LTTNG_KERNEL_ABI_SYSCALL:
-               ret = lttng_syscall_filter_disable_event_recorder(event_recorder);
+               ret = lttng_syscall_filter_disable_event(&event_recorder->parent);
                break;
 
        case LTTNG_KERNEL_ABI_NOOP:
@@ -1550,7 +1550,7 @@ void register_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
                break;
 
        case LTTNG_KERNEL_ABI_SYSCALL:
-               ret = lttng_syscall_filter_enable_event_notifier(event_notifier);
+               ret = lttng_syscall_filter_enable_event(&event_notifier->parent);
                break;
 
        case LTTNG_KERNEL_ABI_KPROBE:
@@ -1601,7 +1601,7 @@ int _lttng_event_notifier_unregister(
                break;
 
        case LTTNG_KERNEL_ABI_SYSCALL:
-               ret = lttng_syscall_filter_disable_event_notifier(event_notifier);
+               ret = lttng_syscall_filter_disable_event(&event_notifier->parent);
                break;
 
        case LTTNG_KERNEL_ABI_KRETPROBE:
index 46cf8dfc90631163c7246c199bd4e174526591eb..f72afbe2c6eeffdab3b513316dd8006f677808f4 100644 (file)
@@ -1288,73 +1288,68 @@ int lttng_syscall_filter_enable(
        return 0;
 }
 
-int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
+int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common *event)
 {
-       struct lttng_event_notifier_group *group = event_notifier->priv->group;
-       struct lttng_kernel_syscall_table *syscall_table = &group->syscall_table;
-       unsigned int syscall_id = event_notifier->priv->parent.u.syscall.syscall_id;
-       struct hlist_head *dispatch_list;
-       int ret = 0;
+       struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_event(event);
+       int ret;
 
-       WARN_ON_ONCE(event_notifier->priv->parent.instrumentation != LTTNG_KERNEL_ABI_SYSCALL);
+       WARN_ON_ONCE(event->priv->instrumentation != LTTNG_KERNEL_ABI_SYSCALL);
 
        ret = lttng_syscall_filter_enable(syscall_table->sc_filter,
-               event_notifier->priv->parent.desc->event_name,
-               event_notifier->priv->parent.u.syscall.abi,
-               event_notifier->priv->parent.u.syscall.entryexit);
-       if (ret) {
-               goto end;
-       }
+               event->priv->desc->event_name, event->priv->u.syscall.abi,
+               event->priv->u.syscall.entryexit);
+       if (ret)
+               return ret;
 
-       switch (event_notifier->priv->parent.u.syscall.entryexit) {
-       case LTTNG_SYSCALL_ENTRY:
-               switch (event_notifier->priv->parent.u.syscall.abi) {
-               case LTTNG_SYSCALL_ABI_NATIVE:
-                       dispatch_list = &syscall_table->syscall_dispatch[syscall_id];
-                       break;
-               case LTTNG_SYSCALL_ABI_COMPAT:
-                       dispatch_list = &syscall_table->compat_syscall_dispatch[syscall_id];
-                       break;
-               default:
-                       ret = -EINVAL;
-                       goto end;
-               }
+       switch (event->type) {
+       case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
                break;
-       case LTTNG_SYSCALL_EXIT:
-               switch (event_notifier->priv->parent.u.syscall.abi) {
-               case LTTNG_SYSCALL_ABI_NATIVE:
-                       dispatch_list = &syscall_table->syscall_exit_dispatch[syscall_id];
+       case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+       {
+               unsigned int syscall_id = event->priv->u.syscall.syscall_id;
+               struct hlist_head *dispatch_list;
+
+               switch (event->priv->u.syscall.entryexit) {
+               case LTTNG_SYSCALL_ENTRY:
+                       switch (event->priv->u.syscall.abi) {
+                       case LTTNG_SYSCALL_ABI_NATIVE:
+                               dispatch_list = &syscall_table->syscall_dispatch[syscall_id];
+                               break;
+                       case LTTNG_SYSCALL_ABI_COMPAT:
+                               dispatch_list = &syscall_table->compat_syscall_dispatch[syscall_id];
+                               break;
+                       default:
+                               ret = -EINVAL;
+                               goto end;
+                       }
                        break;
-               case LTTNG_SYSCALL_ABI_COMPAT:
-                       dispatch_list = &syscall_table->compat_syscall_exit_dispatch[syscall_id];
+               case LTTNG_SYSCALL_EXIT:
+                       switch (event->priv->u.syscall.abi) {
+                       case LTTNG_SYSCALL_ABI_NATIVE:
+                               dispatch_list = &syscall_table->syscall_exit_dispatch[syscall_id];
+                               break;
+                       case LTTNG_SYSCALL_ABI_COMPAT:
+                               dispatch_list = &syscall_table->compat_syscall_exit_dispatch[syscall_id];
+                               break;
+                       default:
+                               ret = -EINVAL;
+                               goto end;
+                       }
                        break;
                default:
                        ret = -EINVAL;
                        goto end;
                }
+
+               hlist_add_head_rcu(&event->priv->u.syscall.node, dispatch_list);
                break;
+       }
        default:
-               ret = -EINVAL;
-               goto end;
+               WARN_ON_ONCE(1);
+               return -ENOSYS;
        }
-
-       hlist_add_head_rcu(&event_notifier->priv->parent.u.syscall.node, dispatch_list);
-
 end:
-       return ret ;
-}
-
-int lttng_syscall_filter_enable_event_recorder(struct lttng_kernel_event_recorder *event_recorder)
-{
-       struct lttng_kernel_channel_buffer *channel = event_recorder->chan;
-       struct lttng_kernel_syscall_table *syscall_table = &channel->priv->parent.syscall_table;
-
-       WARN_ON_ONCE(event_recorder->priv->parent.instrumentation != LTTNG_KERNEL_ABI_SYSCALL);
-
-       return lttng_syscall_filter_enable(syscall_table->sc_filter,
-               event_recorder->priv->parent.desc->event_name,
-               event_recorder->priv->parent.u.syscall.abi,
-               event_recorder->priv->parent.u.syscall.entryexit);
+       return ret;
 }
 
 static
@@ -1416,35 +1411,32 @@ int lttng_syscall_filter_disable(struct lttng_syscall_filter *filter,
        return 0;
 }
 
-int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
+int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common *event)
 {
-       struct lttng_event_notifier_group *group = event_notifier->priv->group;
-       struct lttng_kernel_syscall_table *syscall_table = &group->syscall_table;
+       struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_event(event);
        int ret;
 
-       WARN_ON_ONCE(event_notifier->priv->parent.instrumentation != LTTNG_KERNEL_ABI_SYSCALL);
-
        ret = lttng_syscall_filter_disable(syscall_table->sc_filter,
-               event_notifier->priv->parent.desc->event_name,
-               event_notifier->priv->parent.u.syscall.abi,
-               event_notifier->priv->parent.u.syscall.entryexit);
-       WARN_ON_ONCE(ret != 0);
+               event->priv->desc->event_name, event->priv->u.syscall.abi,
+               event->priv->u.syscall.entryexit);
+       if (ret)
+               return ret;
 
-       hlist_del_rcu(&event_notifier->priv->parent.u.syscall.node);
+       switch (event->type) {
+       case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+               break;
+       case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+       {
+               hlist_del_rcu(&event->priv->u.syscall.node);
+               break;
+       }
+       default:
+               WARN_ON_ONCE(1);
+               return -ENOSYS;
+       }
        return 0;
 }
 
-int lttng_syscall_filter_disable_event_recorder(struct lttng_kernel_event_recorder *event_recorder)
-{
-       struct lttng_kernel_channel_buffer *channel = event_recorder->chan;
-       struct lttng_kernel_syscall_table *syscall_table = &channel->priv->parent.syscall_table;
-
-       return lttng_syscall_filter_disable(syscall_table->sc_filter,
-               event_recorder->priv->parent.desc->event_name,
-               event_recorder->priv->parent.u.syscall.abi,
-               event_recorder->priv->parent.u.syscall.entryexit);
-}
-
 static
 const struct trace_syscall_entry *syscall_list_get_entry(loff_t *pos)
 {
This page took 0.032052 seconds and 4 git commands to generate.