From: Mathieu Desnoyers Date: Tue, 2 Nov 2021 15:21:47 +0000 (-0400) Subject: Refactoring: syscall: combine syscall filter enable/disable recorder/notifier X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9b2f1c54afa6deced96dd6ca5bfa8506f64a6d0b;p=lttng-modules.git Refactoring: syscall: combine syscall filter enable/disable recorder/notifier Signed-off-by: Mathieu Desnoyers Change-Id: If0e10ade6586073255817f5a8a96f73b5aa92f99 --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index 8ac1869b..aceabbe4 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -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 diff --git a/src/lttng-events.c b/src/lttng-events.c index 6907b5a0..270ee573 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -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: diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 46cf8dfc..f72afbe2 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -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) {