From: Francis Deslauriers Date: Thu, 23 Jan 2020 23:31:06 +0000 (-0500) Subject: lttng-syscalls.c: extract function calling actual probe X-Git-Tag: v2.13.0-rc1~128 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=63aa91609c6b8140e5382ecc0f94dc555b62af7b;p=lttng-modules.git lttng-syscalls.c: extract function calling actual probe This function will be reused by the event notifier infrastructure. Signed-off-by: Francis Deslauriers Signed-off-by: Mathieu Desnoyers Change-Id: Iad25a44202d74eac8f75af108eb8297d82303d63 --- diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 3d9f3736..3139a556 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -387,77 +387,36 @@ static void syscall_entry_event_unknown(struct lttng_event *event, __event_probe__syscall_entry_unknown(event, id, args); } -void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id) +static __always_inline +void syscall_entry_call_func(void *func, unsigned int nrargs, void *data, + struct pt_regs *regs) { - struct lttng_channel *chan = __data; - struct lttng_event *event, *unknown_event; - const struct trace_syscall_entry *table, *entry; - size_t table_len; - - if (unlikely(in_compat_syscall())) { - struct lttng_syscall_filter *filter = chan->sc_filter; - - if (id < 0 || id >= NR_compat_syscalls - || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_compat_entry))) { - /* System call filtered out. */ - return; - } - table = compat_sc_table; - table_len = ARRAY_SIZE(compat_sc_table); - unknown_event = chan->sc_compat_unknown; - } else { - struct lttng_syscall_filter *filter = chan->sc_filter; - - if (id < 0 || id >= NR_syscalls - || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_entry))) { - /* System call filtered out. */ - return; - } - table = sc_table; - table_len = ARRAY_SIZE(sc_table); - unknown_event = chan->sc_unknown; - } - if (unlikely(id < 0 || id >= table_len)) { - syscall_entry_event_unknown(unknown_event, regs, id); - return; - } - if (unlikely(in_compat_syscall())) - event = chan->compat_sc_table[id]; - else - event = chan->sc_table[id]; - if (unlikely(!event)) { - syscall_entry_event_unknown(unknown_event, regs, id); - return; - } - entry = &table[id]; - WARN_ON_ONCE(!entry); - - switch (entry->nrargs) { + switch (nrargs) { case 0: { - void (*fptr)(void *__data) = entry->event_func; + void (*fptr)(void *__data) = func; - fptr(event); + fptr(data); break; } case 1: { - void (*fptr)(void *__data, unsigned long arg0) = entry->event_func; + void (*fptr)(void *__data, unsigned long arg0) = func; unsigned long args[LTTNG_SYSCALL_NR_ARGS]; lttng_syscall_get_arguments(current, regs, args); - fptr(event, args[0]); + fptr(data, args[0]); break; } case 2: { void (*fptr)(void *__data, unsigned long arg0, - unsigned long arg1) = entry->event_func; + unsigned long arg1) = func; unsigned long args[LTTNG_SYSCALL_NR_ARGS]; lttng_syscall_get_arguments(current, regs, args); - fptr(event, args[0], args[1]); + fptr(data, args[0], args[1]); break; } case 3: @@ -465,11 +424,11 @@ void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id) void (*fptr)(void *__data, unsigned long arg0, unsigned long arg1, - unsigned long arg2) = entry->event_func; + unsigned long arg2) = func; unsigned long args[LTTNG_SYSCALL_NR_ARGS]; lttng_syscall_get_arguments(current, regs, args); - fptr(event, args[0], args[1], args[2]); + fptr(data, args[0], args[1], args[2]); break; } case 4: @@ -478,11 +437,11 @@ void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id) unsigned long arg0, unsigned long arg1, unsigned long arg2, - unsigned long arg3) = entry->event_func; + unsigned long arg3) = func; unsigned long args[LTTNG_SYSCALL_NR_ARGS]; lttng_syscall_get_arguments(current, regs, args); - fptr(event, args[0], args[1], args[2], args[3]); + fptr(data, args[0], args[1], args[2], args[3]); break; } case 5: @@ -492,11 +451,11 @@ void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id) unsigned long arg1, unsigned long arg2, unsigned long arg3, - unsigned long arg4) = entry->event_func; + unsigned long arg4) = func; unsigned long args[LTTNG_SYSCALL_NR_ARGS]; lttng_syscall_get_arguments(current, regs, args); - fptr(event, args[0], args[1], args[2], args[3], args[4]); + fptr(data, args[0], args[1], args[2], args[3], args[4]); break; } case 6: @@ -507,11 +466,11 @@ void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id) unsigned long arg2, unsigned long arg3, unsigned long arg4, - unsigned long arg5) = entry->event_func; + unsigned long arg5) = func; unsigned long args[LTTNG_SYSCALL_NR_ARGS]; lttng_syscall_get_arguments(current, regs, args); - fptr(event, args[0], args[1], args[2], + fptr(data, args[0], args[1], args[2], args[3], args[4], args[5]); break; } @@ -520,6 +479,53 @@ void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id) } } +void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id) +{ + struct lttng_channel *chan = __data; + struct lttng_event *event, *unknown_event; + const struct trace_syscall_entry *table, *entry; + size_t table_len; + + if (unlikely(in_compat_syscall())) { + struct lttng_syscall_filter *filter = chan->sc_filter; + + if (id < 0 || id >= NR_compat_syscalls + || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_compat_entry))) { + /* System call filtered out. */ + return; + } + table = compat_sc_table; + table_len = ARRAY_SIZE(compat_sc_table); + unknown_event = chan->sc_compat_unknown; + } else { + struct lttng_syscall_filter *filter = chan->sc_filter; + + if (id < 0 || id >= NR_syscalls + || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_entry))) { + /* System call filtered out. */ + return; + } + table = sc_table; + table_len = ARRAY_SIZE(sc_table); + unknown_event = chan->sc_unknown; + } + if (unlikely(id < 0 || id >= table_len)) { + syscall_entry_event_unknown(unknown_event, regs, id); + return; + } + if (unlikely(in_compat_syscall())) + event = chan->compat_sc_table[id]; + else + event = chan->sc_table[id]; + if (unlikely(!event)) { + syscall_entry_event_unknown(unknown_event, regs, id); + return; + } + entry = &table[id]; + WARN_ON_ONCE(!entry); + syscall_entry_call_func(entry->event_func, entry->nrargs, event, regs); +} + static void syscall_exit_event_unknown(struct lttng_event *event, struct pt_regs *regs, int id, long ret) {