X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Flttng-syscalls.c;h=1194b95d24ab71b2b88ce940ad393febec032341;hb=d26015f62c573e6d544f05caa25f0b0f645ef20c;hp=f72afbe2c6eeffdab3b513316dd8006f677808f4;hpb=9b2f1c54afa6deced96dd6ca5bfa8506f64a6d0b;p=lttng-modules.git diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index f72afbe2..1194b95d 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -613,46 +613,20 @@ int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *tabl return 0; } -/* - * Should be called with sessions lock held. - */ -int lttng_syscalls_register_event_recorder(struct lttng_event_recorder_enabler *syscall_event_enabler) +static +int lttng_syscalls_populate_events(struct lttng_event_enabler_common *syscall_event_enabler) { - struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(&syscall_event_enabler->parent); + struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(syscall_event_enabler); + struct lttng_event_recorder_enabler *event_recorder_enabler; + struct lttng_kernel_channel_buffer *chan; struct lttng_kernel_abi_event ev; int ret; - wrapper_vmalloc_sync_mappings(); - - if (!syscall_table->syscall_dispatch) { - /* create syscall table mapping syscall to events */ - syscall_table->syscall_dispatch = kzalloc(sizeof(struct hlist_head) * sc_table.len, GFP_KERNEL); - if (!syscall_table->syscall_dispatch) - return -ENOMEM; - } - if (!syscall_table->syscall_exit_dispatch) { - /* create syscall table mapping syscall to events */ - syscall_table->syscall_exit_dispatch = kzalloc(sizeof(struct hlist_head) * sc_exit_table.len, GFP_KERNEL); - if (!syscall_table->syscall_exit_dispatch) - return -ENOMEM; - } - - -#ifdef CONFIG_COMPAT - if (!syscall_table->compat_syscall_dispatch) { - /* create syscall table mapping compat syscall to events */ - syscall_table->compat_syscall_dispatch = kzalloc(sizeof(struct hlist_head) * compat_sc_table.len, GFP_KERNEL); - if (!syscall_table->compat_syscall_dispatch) - return -ENOMEM; - } + if (syscall_event_enabler->enabler_type != LTTNG_EVENT_ENABLER_TYPE_RECORDER) + return 0; + event_recorder_enabler = container_of(syscall_event_enabler, struct lttng_event_recorder_enabler, parent); + chan = event_recorder_enabler->chan; - if (!syscall_table->compat_syscall_exit_dispatch) { - /* create syscall table mapping compat syscall to events */ - syscall_table->compat_syscall_exit_dispatch = kzalloc(sizeof(struct hlist_head) * compat_sc_exit_table.len, GFP_KERNEL); - if (!syscall_table->compat_syscall_exit_dispatch) - return -ENOMEM; - } -#endif if (hlist_empty(&syscall_table->unknown_syscall_dispatch)) { const struct lttng_kernel_event_desc *desc = &__event_desc___syscall_entry_unknown; @@ -665,7 +639,7 @@ int lttng_syscalls_register_event_recorder(struct lttng_event_recorder_enabler * ev.instrumentation = LTTNG_KERNEL_ABI_SYSCALL; ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY; ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE; - event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, syscall_event_enabler->chan); + event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan); if (!event_enabler) { return -ENOMEM; } @@ -690,7 +664,7 @@ int lttng_syscalls_register_event_recorder(struct lttng_event_recorder_enabler * ev.instrumentation = LTTNG_KERNEL_ABI_SYSCALL; ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY; ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT; - event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, syscall_event_enabler->chan); + event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan); if (!event_enabler) { return -ENOMEM; } @@ -715,7 +689,7 @@ int lttng_syscalls_register_event_recorder(struct lttng_event_recorder_enabler * ev.instrumentation = LTTNG_KERNEL_ABI_SYSCALL; ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_EXIT; ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT; - event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, syscall_event_enabler->chan); + event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan); if (!event_enabler) { return -ENOMEM; } @@ -740,7 +714,7 @@ int lttng_syscalls_register_event_recorder(struct lttng_event_recorder_enabler * ev.instrumentation = LTTNG_KERNEL_ABI_SYSCALL; ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_EXIT; ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE; - event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, syscall_event_enabler->chan); + event_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan); if (!event_enabler) { return -ENOMEM; } @@ -754,96 +728,64 @@ int lttng_syscalls_register_event_recorder(struct lttng_event_recorder_enabler * } ret = lttng_create_syscall_event_if_missing(sc_table.table, sc_table.len, - syscall_table->syscall_dispatch, syscall_event_enabler, SC_TYPE_ENTRY); + syscall_table->syscall_dispatch, event_recorder_enabler, SC_TYPE_ENTRY); if (ret) return ret; ret = lttng_create_syscall_event_if_missing(sc_exit_table.table, sc_exit_table.len, - syscall_table->syscall_exit_dispatch, syscall_event_enabler, SC_TYPE_EXIT); + syscall_table->syscall_exit_dispatch, event_recorder_enabler, SC_TYPE_EXIT); if (ret) return ret; #ifdef CONFIG_COMPAT ret = lttng_create_syscall_event_if_missing(compat_sc_table.table, compat_sc_table.len, - syscall_table->compat_syscall_dispatch, syscall_event_enabler, SC_TYPE_COMPAT_ENTRY); + syscall_table->compat_syscall_dispatch, event_recorder_enabler, SC_TYPE_COMPAT_ENTRY); if (ret) return ret; ret = lttng_create_syscall_event_if_missing(compat_sc_exit_table.table, compat_sc_exit_table.len, - syscall_table->compat_syscall_exit_dispatch, syscall_event_enabler, SC_TYPE_COMPAT_EXIT); + syscall_table->compat_syscall_exit_dispatch, event_recorder_enabler, SC_TYPE_COMPAT_EXIT); if (ret) return ret; #endif - - if (!syscall_table->sc_filter) { - syscall_table->sc_filter = kzalloc(sizeof(struct lttng_syscall_filter), - GFP_KERNEL); - if (!syscall_table->sc_filter) - return -ENOMEM; - } - - if (!syscall_table->sys_enter_registered) { - ret = lttng_wrapper_tracepoint_probe_register("sys_enter", - (void *) syscall_entry_event_probe, syscall_table); - if (ret) - return ret; - syscall_table->sys_enter_registered = 1; - } - /* - * We change the name of sys_exit tracepoint due to namespace - * conflict with sys_exit syscall entry. - */ - if (!syscall_table->sys_exit_registered) { - ret = lttng_wrapper_tracepoint_probe_register("sys_exit", - (void *) syscall_exit_event_probe, syscall_table); - if (ret) { - WARN_ON_ONCE(lttng_wrapper_tracepoint_probe_unregister("sys_enter", - (void *) syscall_entry_event_probe, syscall_table)); - return ret; - } - syscall_table->sys_exit_registered = 1; - } return ret; } /* * Should be called with sessions lock held. */ -int lttng_syscalls_register_event_notifier( - struct lttng_event_notifier_enabler *event_notifier_enabler) +int lttng_syscalls_register_event(struct lttng_event_enabler_common *syscall_event_enabler) { - struct lttng_event_notifier_group *group = event_notifier_enabler->group; - struct lttng_kernel_syscall_table *syscall_table = &group->syscall_table; - int ret = 0; - - wrapper_vmalloc_sync_mappings(); + struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(syscall_event_enabler); + int ret; if (!syscall_table->syscall_dispatch) { + /* create syscall table mapping syscall to events */ syscall_table->syscall_dispatch = kzalloc(sizeof(struct hlist_head) * sc_table.len, GFP_KERNEL); if (!syscall_table->syscall_dispatch) return -ENOMEM; } - if (!syscall_table->syscall_exit_dispatch) { - syscall_table->syscall_exit_dispatch = kzalloc(sizeof(struct hlist_head) * sc_table.len, GFP_KERNEL); + /* create syscall table mapping syscall to events */ + syscall_table->syscall_exit_dispatch = kzalloc(sizeof(struct hlist_head) * sc_exit_table.len, GFP_KERNEL); if (!syscall_table->syscall_exit_dispatch) return -ENOMEM; } + #ifdef CONFIG_COMPAT if (!syscall_table->compat_syscall_dispatch) { + /* create syscall table mapping compat syscall to events */ syscall_table->compat_syscall_dispatch = kzalloc(sizeof(struct hlist_head) * compat_sc_table.len, GFP_KERNEL); if (!syscall_table->compat_syscall_dispatch) return -ENOMEM; } if (!syscall_table->compat_syscall_exit_dispatch) { - syscall_table->compat_syscall_exit_dispatch = - kzalloc(sizeof(struct hlist_head) * compat_sc_exit_table.len, - GFP_KERNEL); + /* create syscall table mapping compat syscall to events */ + syscall_table->compat_syscall_exit_dispatch = kzalloc(sizeof(struct hlist_head) * compat_sc_exit_table.len, GFP_KERNEL); if (!syscall_table->compat_syscall_exit_dispatch) return -ENOMEM; } #endif - if (!syscall_table->sc_filter) { syscall_table->sc_filter = kzalloc(sizeof(struct lttng_syscall_filter), GFP_KERNEL); @@ -851,6 +793,12 @@ int lttng_syscalls_register_event_notifier( return -ENOMEM; } + ret = lttng_syscalls_populate_events(syscall_event_enabler); + if (ret) + return ret; + + wrapper_vmalloc_sync_mappings(); + if (!syscall_table->sys_enter_registered) { ret = lttng_wrapper_tracepoint_probe_register("sys_enter", (void *) syscall_entry_event_probe, syscall_table); @@ -858,7 +806,6 @@ int lttng_syscalls_register_event_notifier( return ret; syscall_table->sys_enter_registered = 1; } - if (!syscall_table->sys_exit_registered) { ret = lttng_wrapper_tracepoint_probe_register("sys_exit", (void *) syscall_exit_event_probe, syscall_table); @@ -869,7 +816,6 @@ int lttng_syscalls_register_event_notifier( } syscall_table->sys_exit_registered = 1; } - return ret; }