From: Francis Deslauriers Date: Thu, 19 Nov 2020 22:00:19 +0000 (-0500) Subject: syscalls: extract `lttng_syscall_filter_enable()` for reuse X-Git-Tag: v2.13.0-rc1~111 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ade8a729bae2186c2bd0d262cbe3b822adce8659;p=lttng-modules.git syscalls: extract `lttng_syscall_filter_enable()` for reuse The syscall event notifiers will reuse the concept of syscall filtering to avoid needlessly preparing arguments for disabled syscalls. Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers Change-Id: I64395a031e526e8485e10b4b72f653058c8d0a38 --- diff --git a/include/lttng/events.h b/include/lttng/events.h index 7226a27b..05b0f7cf 100644 --- a/include/lttng/events.h +++ b/include/lttng/events.h @@ -773,10 +773,13 @@ void lttng_clock_unref(void); int lttng_syscalls_register_event(struct lttng_channel *chan, void *filter); int lttng_syscalls_unregister_event(struct lttng_channel *chan); int lttng_syscalls_destroy_event(struct lttng_channel *chan); -int lttng_syscall_filter_enable_event(struct lttng_channel *chan, +int lttng_syscall_filter_enable_event( + struct lttng_channel *chan, struct lttng_event *event); -int lttng_syscall_filter_disable_event(struct lttng_channel *chan, +int lttng_syscall_filter_disable_event( + struct lttng_channel *chan, struct lttng_event *event); + long lttng_channel_syscall_mask(struct lttng_channel *channel, struct lttng_kernel_syscall_mask __user *usyscall_mask); diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 3139a556..3e9f791a 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -1008,15 +1008,16 @@ uint32_t get_sc_tables_len(void) } static -const char *get_syscall_name(struct lttng_event *event) +const char *get_syscall_name(const char *desc_name, + enum lttng_syscall_abi abi, + enum lttng_syscall_entryexit entryexit) { size_t prefix_len = 0; - WARN_ON_ONCE(event->instrumentation != LTTNG_KERNEL_SYSCALL); - switch (event->u.syscall.entryexit) { + switch (entryexit) { case LTTNG_SYSCALL_ENTRY: - switch (event->u.syscall.abi) { + switch (abi) { case LTTNG_SYSCALL_ABI_NATIVE: prefix_len = strlen(SYSCALL_ENTRY_STR); break; @@ -1026,7 +1027,7 @@ const char *get_syscall_name(struct lttng_event *event) } break; case LTTNG_SYSCALL_EXIT: - switch (event->u.syscall.abi) { + switch (abi) { case LTTNG_SYSCALL_ABI_NATIVE: prefix_len = strlen(SYSCALL_EXIT_STR); break; @@ -1037,22 +1038,22 @@ const char *get_syscall_name(struct lttng_event *event) break; } WARN_ON_ONCE(prefix_len == 0); - return event->desc->name + prefix_len; + return desc_name + prefix_len; } -int lttng_syscall_filter_enable_event(struct lttng_channel *chan, - struct lttng_event *event) +static +int lttng_syscall_filter_enable( + struct lttng_syscall_filter *filter, + const char *desc_name, enum lttng_syscall_abi abi, + enum lttng_syscall_entryexit entryexit) { - struct lttng_syscall_filter *filter = chan->sc_filter; const char *syscall_name; unsigned long *bitmap; int syscall_nr; - WARN_ON_ONCE(!chan->sc_table); - - syscall_name = get_syscall_name(event); + syscall_name = get_syscall_name(desc_name, abi, entryexit); - switch (event->u.syscall.abi) { + switch (abi) { case LTTNG_SYSCALL_ABI_NATIVE: syscall_nr = get_syscall_nr(syscall_name); break; @@ -1065,9 +1066,9 @@ int lttng_syscall_filter_enable_event(struct lttng_channel *chan, if (syscall_nr < 0) return -ENOENT; - switch (event->u.syscall.entryexit) { + switch (entryexit) { case LTTNG_SYSCALL_ENTRY: - switch (event->u.syscall.abi) { + switch (abi) { case LTTNG_SYSCALL_ABI_NATIVE: bitmap = filter->sc_entry; break; @@ -1079,7 +1080,7 @@ int lttng_syscall_filter_enable_event(struct lttng_channel *chan, } break; case LTTNG_SYSCALL_EXIT: - switch (event->u.syscall.abi) { + switch (abi) { case LTTNG_SYSCALL_ABI_NATIVE: bitmap = filter->sc_exit; break; @@ -1099,19 +1100,30 @@ int lttng_syscall_filter_enable_event(struct lttng_channel *chan, return 0; } -int lttng_syscall_filter_disable_event(struct lttng_channel *chan, +int lttng_syscall_filter_enable_event( + struct lttng_channel *channel, struct lttng_event *event) { - struct lttng_syscall_filter *filter = chan->sc_filter; + WARN_ON_ONCE(event->instrumentation != LTTNG_KERNEL_SYSCALL); + + return lttng_syscall_filter_enable(channel->sc_filter, + event->desc->name, event->u.syscall.abi, + event->u.syscall.entryexit); +} + +static +int lttng_syscall_filter_disable( + struct lttng_syscall_filter *filter, + const char *desc_name, enum lttng_syscall_abi abi, + enum lttng_syscall_entryexit entryexit) +{ const char *syscall_name; unsigned long *bitmap; int syscall_nr; - WARN_ON_ONCE(!chan->sc_table); + syscall_name = get_syscall_name(desc_name, abi, entryexit); - syscall_name = get_syscall_name(event); - - switch (event->u.syscall.abi) { + switch (abi) { case LTTNG_SYSCALL_ABI_NATIVE: syscall_nr = get_syscall_nr(syscall_name); break; @@ -1124,9 +1136,9 @@ int lttng_syscall_filter_disable_event(struct lttng_channel *chan, if (syscall_nr < 0) return -ENOENT; - switch (event->u.syscall.entryexit) { + switch (entryexit) { case LTTNG_SYSCALL_ENTRY: - switch (event->u.syscall.abi) { + switch (abi) { case LTTNG_SYSCALL_ABI_NATIVE: bitmap = filter->sc_entry; break; @@ -1138,7 +1150,7 @@ int lttng_syscall_filter_disable_event(struct lttng_channel *chan, } break; case LTTNG_SYSCALL_EXIT: - switch (event->u.syscall.abi) { + switch (abi) { case LTTNG_SYSCALL_ABI_NATIVE: bitmap = filter->sc_exit; break; @@ -1159,6 +1171,15 @@ int lttng_syscall_filter_disable_event(struct lttng_channel *chan, return 0; } +int lttng_syscall_filter_disable_event( + struct lttng_channel *channel, + struct lttng_event *event) +{ + return lttng_syscall_filter_disable(channel->sc_filter, + event->desc->name, event->u.syscall.abi, + event->u.syscall.entryexit); +} + static const struct trace_syscall_entry *syscall_list_get_entry(loff_t *pos) {