From: Mathieu Desnoyers Date: Wed, 3 Nov 2021 19:09:53 +0000 (-0400) Subject: Refactoring: combine common code into lttng_syscall_table_set_wildcard_all X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9cb5be7ee29abb8446e4ec971b897d979f24c8b5;p=lttng-modules.git Refactoring: combine common code into lttng_syscall_table_set_wildcard_all Signed-off-by: Mathieu Desnoyers Change-Id: I84bda6aa93f5ca67e57dec95710c51f9464a11f4 --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index 21d887f0..57a7325e 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -860,6 +860,8 @@ int lttng_syscalls_destroy_syscall_table(struct lttng_kernel_syscall_table *sysc long lttng_syscall_table_get_active_mask(struct lttng_kernel_syscall_table *syscall_table, struct lttng_kernel_abi_syscall_mask __user *usyscall_mask); + +void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler); #else static inline int lttng_syscalls_register_event(struct lttng_event_enabler_common *event_enabler) { @@ -897,6 +899,9 @@ static inline int lttng_syscalls_create_matching_event_notifiers(struct lttng_ev return -ENOSYS; } +static inline void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler) +{ +} #endif #ifdef CONFIG_KPROBES diff --git a/src/lttng-events.c b/src/lttng-events.c index fa151acf..12ef85e3 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -2230,24 +2230,11 @@ void lttng_create_event_if_missing(struct lttng_event_enabler_common *event_enab static int lttng_event_enabler_ref_events(struct lttng_event_recorder_enabler *event_enabler) { - struct lttng_kernel_channel_buffer *chan = event_enabler->chan; struct lttng_event_enabler_common *base_enabler = lttng_event_recorder_enabler_as_enabler(event_enabler); struct lttng_kernel_event_recorder_private *event_recorder_priv; struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(&event_enabler->parent); - 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_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->priv->parent.syscall_table.syscall_all_entry, enabled); - - if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) - WRITE_ONCE(chan->priv->parent.syscall_table.syscall_all_exit, enabled); - } + lttng_syscall_table_set_wildcard_all(base_enabler); /* First ensure that probe events are created for this enabler. */ lttng_create_event_if_missing(&event_enabler->parent); @@ -2292,26 +2279,10 @@ static int lttng_event_notifier_enabler_ref_event_notifiers( struct lttng_event_notifier_enabler *event_notifier_enabler) { - struct lttng_event_notifier_group *event_notifier_group = event_notifier_enabler->group; - struct lttng_event_enabler_common *base_enabler = lttng_event_notifier_enabler_as_enabler(event_notifier_enabler); struct lttng_kernel_event_notifier_private *event_notifier_priv; struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(&event_notifier_enabler->parent); - 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_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(event_notifier_group->syscall_table.syscall_all_entry, enabled); - - if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) - WRITE_ONCE(event_notifier_group->syscall_table.syscall_all_exit, enabled); - - } + lttng_syscall_table_set_wildcard_all(&event_notifier_enabler->parent); /* First ensure that probe event_notifiers are created for this enabler. */ lttng_create_event_if_missing(&event_notifier_enabler->parent); diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index b5bd5bd3..d26dd83f 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -1397,6 +1397,29 @@ int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common *event) return 0; } +void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler) +{ + struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(event_enabler); + enum lttng_kernel_abi_syscall_entryexit entryexit; + int enabled = event_enabler->enabled; + + if (event_enabler->event_param.instrumentation != LTTNG_KERNEL_ABI_SYSCALL) + return; + if (event_enabler->event_param.u.syscall.abi != LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL) + return; + if (event_enabler->event_param.u.syscall.match != LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME) + return; + if (strcmp(event_enabler->event_param.name, "*")) + return; + + entryexit = event_enabler->event_param.u.syscall.entryexit; + if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) + WRITE_ONCE(syscall_table->syscall_all_entry, enabled); + + if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) + WRITE_ONCE(syscall_table->syscall_all_exit, enabled); +} + static const struct trace_syscall_entry *syscall_list_get_entry(loff_t *pos) {