struct itimerval;
struct itimerspec;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0))
typedef __kernel_old_time_t time_t;
#endif
DECLARE_BITMAP(sc_compat_exit, NR_compat_syscalls);
};
-static void syscall_entry_event_unknown(struct lttng_event *event,
+static void syscall_entry_event_unknown(struct hlist_head *unknown_action_list_head,
struct pt_regs *regs, long id)
{
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
+ struct lttng_event *event;
lttng_syscall_get_arguments(current, regs, args);
- if (unlikely(in_compat_syscall()))
- __event_probe__compat_syscall_entry_unknown(event, id, args);
- else
- __event_probe__syscall_entry_unknown(event, id, args);
+ lttng_hlist_for_each_entry_rcu(event, unknown_action_list_head, u.syscall.node) {
+ if (unlikely(in_compat_syscall()))
+ __event_probe__compat_syscall_entry_unknown(event, id, args);
+ else
+ __event_probe__syscall_entry_unknown(event, id, args);
+ }
}
static void syscall_entry_event_notifier_unknown(
}
static __always_inline
-void syscall_entry_call_func(void *func, unsigned int nrargs, void *data,
+void syscall_entry_call_func(struct hlist_head *action_list,
+ void *func, unsigned int nrargs,
struct pt_regs *regs)
{
+ struct lttng_event *event;
+
switch (nrargs) {
case 0:
{
void (*fptr)(void *__data) = func;
- fptr(data);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event);
break;
}
case 1:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- fptr(data, args[0]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, args[0]);
break;
}
case 2:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- fptr(data, args[0], args[1]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, args[0], args[1]);
break;
}
case 3:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- fptr(data, args[0], args[1], args[2]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, args[0], args[1], args[2]);
break;
}
case 4:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- fptr(data, args[0], args[1], args[2], args[3]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, args[0], args[1], args[2], args[3]);
break;
}
case 5:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- fptr(data, args[0], args[1], args[2], args[3], args[4]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, args[0], args[1], args[2], args[3], args[4]);
break;
}
case 6:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- fptr(data, args[0], args[1], args[2],
- args[3], args[4], args[5]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, args[0], args[1], args[2],
+ args[3], args[4], args[5]);
break;
}
default:
void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id)
{
- struct lttng_channel *chan = __data;
- struct lttng_event *event, *unknown_event;
+ struct lttng_event_container *container = __data;
+ struct hlist_head *action_list, *unknown_action_list;
const struct trace_syscall_entry *table, *entry;
size_t table_len;
if (unlikely(in_compat_syscall())) {
- struct lttng_syscall_filter *filter = chan->sc_filter;
+ struct lttng_syscall_filter *filter = container->sc_filter;
if (id < 0 || id >= NR_compat_syscalls
- || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_compat_entry))) {
+ || (!READ_ONCE(container->syscall_all_entry) && !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;
+ unknown_action_list = &container->sc_compat_unknown;
} else {
- struct lttng_syscall_filter *filter = chan->sc_filter;
+ struct lttng_syscall_filter *filter = container->sc_filter;
if (id < 0 || id >= NR_syscalls
- || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_entry))) {
+ || (!READ_ONCE(container->syscall_all_entry) && !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;
+ unknown_action_list = &container->sc_unknown;
}
if (unlikely(id < 0 || id >= table_len)) {
- syscall_entry_event_unknown(unknown_event, regs, id);
+ syscall_entry_event_unknown(unknown_action_list, 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);
+
+ entry = &table[id];
+ if (!entry->event_func) {
+ syscall_entry_event_unknown(unknown_action_list, regs, id);
return;
}
- entry = &table[id];
- WARN_ON_ONCE(!entry->event_func);
- syscall_entry_call_func(entry->event_func, entry->nrargs, event, regs);
+
+ if (unlikely(in_compat_syscall())) {
+ action_list = &container->compat_sc_table[id];
+ } else {
+ action_list = &container->sc_table[id];
+ }
+ if (unlikely(hlist_empty(action_list)))
+ return;
+
+ syscall_entry_call_func(action_list, entry->event_func, entry->nrargs, regs);
}
void syscall_entry_event_notifier_probe(void *__data, struct pt_regs *regs,
entry->event_notifier_func, entry->nrargs, regs);
}
-static void syscall_exit_event_unknown(struct lttng_event *event,
+static void syscall_exit_event_unknown(struct hlist_head *unknown_action_list_head,
struct pt_regs *regs, long id, long ret)
{
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
+ struct lttng_event *event;
lttng_syscall_get_arguments(current, regs, args);
- if (unlikely(in_compat_syscall()))
- __event_probe__compat_syscall_exit_unknown(event, id, ret,
- args);
- else
- __event_probe__syscall_exit_unknown(event, id, ret, args);
+ lttng_hlist_for_each_entry_rcu(event, unknown_action_list_head, u.syscall.node) {
+ if (unlikely(in_compat_syscall()))
+ __event_probe__compat_syscall_exit_unknown(event, id, ret,
+ args);
+ else
+ __event_probe__syscall_exit_unknown(event, id, ret, args);
+ }
}
-void syscall_exit_event_probe(void *__data, struct pt_regs *regs, long ret)
+static __always_inline
+void syscall_exit_call_func(struct hlist_head *action_list,
+ void *func, unsigned int nrargs,
+ struct pt_regs *regs, long ret)
{
- struct lttng_channel *chan = __data;
- struct lttng_event *event, *unknown_event;
- const struct trace_syscall_entry *table, *entry;
- size_t table_len;
- long id;
-
- id = syscall_get_nr(current, regs);
- 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_exit))) {
- /* System call filtered out. */
- return;
- }
- table = compat_sc_exit_table;
- table_len = ARRAY_SIZE(compat_sc_exit_table);
- unknown_event = chan->compat_sc_exit_unknown;
- } else {
- struct lttng_syscall_filter *filter = chan->sc_filter;
+ struct lttng_event *event;
- if (id < 0 || id >= NR_syscalls
- || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_exit))) {
- /* System call filtered out. */
- return;
- }
- table = sc_exit_table;
- table_len = ARRAY_SIZE(sc_exit_table);
- unknown_event = chan->sc_exit_unknown;
- }
- if (unlikely(id < 0 || id >= table_len)) {
- syscall_exit_event_unknown(unknown_event, regs, id, ret);
- return;
- }
- if (unlikely(in_compat_syscall()))
- event = chan->compat_sc_exit_table[id];
- else
- event = chan->sc_exit_table[id];
- if (unlikely(!event)) {
- syscall_exit_event_unknown(unknown_event, regs, id, ret);
- return;
- }
- entry = &table[id];
- WARN_ON_ONCE(!entry->event_func);
-
- switch (entry->nrargs) {
+ switch (nrargs) {
case 0:
{
- void (*fptr)(void *__data, long ret) = entry->event_func;
+ void (*fptr)(void *__data, long ret) = func;
- fptr(event, ret);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, ret);
break;
}
case 1:
{
void (*fptr)(void *__data,
long ret,
- unsigned long arg0) = entry->event_func;
+ unsigned long arg0) = func;
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- fptr(event, ret, args[0]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, ret, args[0]);
break;
}
case 2:
void (*fptr)(void *__data,
long ret,
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, ret, args[0], args[1]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, ret, args[0], args[1]);
break;
}
case 3:
long ret,
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, ret, args[0], args[1], args[2]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, ret, args[0], args[1], args[2]);
break;
}
case 4:
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, ret, args[0], args[1], args[2], args[3]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, ret, args[0], args[1], args[2], args[3]);
break;
}
case 5:
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, ret, args[0], args[1], args[2], args[3], args[4]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, ret, args[0], args[1], args[2], args[3], args[4]);
break;
}
case 6:
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, ret, args[0], args[1], args[2],
- args[3], args[4], args[5]);
+ lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
+ fptr(event, ret, args[0], args[1], args[2],
+ args[3], args[4], args[5]);
break;
}
default:
}
}
+void syscall_exit_event_probe(void *__data, struct pt_regs *regs, long ret)
+{
+ struct lttng_event_container *container = __data;
+ struct hlist_head *action_list, *unknown_action_list;
+ const struct trace_syscall_entry *table, *entry;
+ size_t table_len;
+ long id;
+
+ id = syscall_get_nr(current, regs);
+
+ if (unlikely(in_compat_syscall())) {
+ struct lttng_syscall_filter *filter = container->sc_filter;
+
+ if (id < 0 || id >= NR_compat_syscalls
+ || (!READ_ONCE(container->syscall_all_exit) && !test_bit(id, filter->sc_compat_exit))) {
+ /* System call filtered out. */
+ return;
+ }
+ table = compat_sc_exit_table;
+ table_len = ARRAY_SIZE(compat_sc_exit_table);
+ unknown_action_list = &container->compat_sc_exit_unknown;
+ } else {
+ struct lttng_syscall_filter *filter = container->sc_filter;
+
+ if (id < 0 || id >= NR_syscalls
+ || (!READ_ONCE(container->syscall_all_exit) && !test_bit(id, filter->sc_exit))) {
+ /* System call filtered out. */
+ return;
+ }
+ table = sc_exit_table;
+ table_len = ARRAY_SIZE(sc_exit_table);
+ unknown_action_list = &container->sc_exit_unknown;
+ }
+ if (unlikely(id < 0 || id >= table_len)) {
+ syscall_exit_event_unknown(unknown_action_list, regs, id, ret);
+ return;
+ }
+
+ entry = &table[id];
+ if (!entry->event_func) {
+ syscall_exit_event_unknown(unknown_action_list, regs, id, ret);
+ return;
+ }
+
+ if (unlikely(in_compat_syscall())) {
+ action_list = &container->compat_sc_exit_table[id];
+ } else {
+ action_list = &container->sc_exit_table[id];
+ }
+ if (unlikely(hlist_empty(action_list)))
+ return;
+
+ syscall_exit_call_func(action_list, entry->event_func, entry->nrargs,
+ regs, ret);
+}
+
static __always_inline
void syscall_exit_event_notifier_call_func(struct hlist_head *dispatch_list,
void *func, unsigned int nrargs, struct pt_regs *regs, long ret)
* Should be called with sessions lock held.
*/
static
-int fill_event_table(const struct trace_syscall_entry *table, size_t table_len,
- struct lttng_event **chan_table, struct lttng_channel *chan,
+int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *table, size_t table_len,
+ struct hlist_head *container_table, struct lttng_event_enabler *event_enabler,
void *filter, enum sc_type type)
{
- const struct lttng_event_desc *desc;
+ struct lttng_event_container *container = event_enabler->container;
unsigned int i;
- /* Allocate events for each syscall, insert into table */
+ /* Allocate events for each syscall matching enabler, insert into table */
for (i = 0; i < table_len; i++) {
+ const struct lttng_event_desc *desc = table[i].desc;
struct lttng_kernel_event ev;
- desc = table[i].desc;
+ struct lttng_event *event;
if (!desc) {
/* Unknown syscall */
continue;
}
- /*
- * Skip those already populated by previous failed
- * register for this channel.
- */
- if (chan_table[i])
+ if (lttng_desc_match_enabler(desc,
+ lttng_event_enabler_as_enabler(event_enabler)) <= 0)
continue;
+
+ /* We need to create an event for this syscall/enabler. */
memset(&ev, 0, sizeof(ev));
switch (type) {
case SC_TYPE_ENTRY:
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN - 1);
ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
ev.instrumentation = LTTNG_KERNEL_SYSCALL;
- chan_table[i] = _lttng_event_create(chan, &ev, filter,
- desc, ev.instrumentation);
- WARN_ON_ONCE(!chan_table[i]);
- if (IS_ERR(chan_table[i])) {
+ event = _lttng_event_create(container, &ev, &event_enabler->key, filter,
+ desc, ev.instrumentation,
+ event_enabler->base.user_token);
+ /* Skip if event is already found. */
+ if (IS_ERR(event) && PTR_ERR(event) == -EEXIST)
+ continue;
+ if (IS_ERR(event)) {
/*
* If something goes wrong in event registration
* after the first one, we have no choice but to
* leave the previous events in there, until
* deleted by session teardown.
*/
- return PTR_ERR(chan_table[i]);
+ return PTR_ERR(event);
}
+ hlist_add_head(&event->u.syscall.node, &container_table[i]);
}
return 0;
}
/*
* Should be called with sessions lock held.
*/
-int lttng_syscalls_register_event(struct lttng_channel *chan, void *filter)
+int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler, void *filter)
{
+ struct lttng_event_container *container = event_enabler->container;
struct lttng_kernel_event ev;
int ret;
wrapper_vmalloc_sync_mappings();
- if (!chan->sc_table) {
+ if (!container->sc_table) {
/* create syscall table mapping syscall to events */
- chan->sc_table = kzalloc(sizeof(struct lttng_event *)
+ container->sc_table = kzalloc(sizeof(struct hlist_head)
* ARRAY_SIZE(sc_table), GFP_KERNEL);
- if (!chan->sc_table)
+ if (!container->sc_table)
return -ENOMEM;
}
- if (!chan->sc_exit_table) {
+ if (!container->sc_exit_table) {
/* create syscall table mapping syscall to events */
- chan->sc_exit_table = kzalloc(sizeof(struct lttng_event *)
+ container->sc_exit_table = kzalloc(sizeof(struct hlist_head)
* ARRAY_SIZE(sc_exit_table), GFP_KERNEL);
- if (!chan->sc_exit_table)
+ if (!container->sc_exit_table)
return -ENOMEM;
}
-
#ifdef CONFIG_COMPAT
- if (!chan->compat_sc_table) {
+ if (!container->compat_sc_table) {
/* create syscall table mapping compat syscall to events */
- chan->compat_sc_table = kzalloc(sizeof(struct lttng_event *)
+ container->compat_sc_table = kzalloc(sizeof(struct hlist_head)
* ARRAY_SIZE(compat_sc_table), GFP_KERNEL);
- if (!chan->compat_sc_table)
+ if (!container->compat_sc_table)
return -ENOMEM;
}
- if (!chan->compat_sc_exit_table) {
+ if (!container->compat_sc_exit_table) {
/* create syscall table mapping compat syscall to events */
- chan->compat_sc_exit_table = kzalloc(sizeof(struct lttng_event *)
+ container->compat_sc_exit_table = kzalloc(sizeof(struct hlist_head)
* ARRAY_SIZE(compat_sc_exit_table), GFP_KERNEL);
- if (!chan->compat_sc_exit_table)
+ if (!container->compat_sc_exit_table)
return -ENOMEM;
}
#endif
- if (!chan->sc_unknown) {
+
+ {
const struct lttng_event_desc *desc =
&__event_desc___syscall_entry_unknown;
+ struct lttng_event *event;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
ev.instrumentation = LTTNG_KERNEL_SYSCALL;
ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
- chan->sc_unknown = _lttng_event_create(chan, &ev, filter,
- desc,
- ev.instrumentation);
- WARN_ON_ONCE(!chan->sc_unknown);
- if (IS_ERR(chan->sc_unknown)) {
- return PTR_ERR(chan->sc_unknown);
+ event = _lttng_event_create(container, &ev, &event_enabler->key, filter,
+ desc, ev.instrumentation,
+ event_enabler->base.user_token);
+ if (IS_ERR(event)) {
+ if (PTR_ERR(event) != -EEXIST)
+ return PTR_ERR(event);
+ /* Skip if event is already found. */
+ } else {
+ hlist_add_head(&event->u.syscall.node, &container->sc_unknown);
}
}
- if (!chan->sc_compat_unknown) {
+ {
const struct lttng_event_desc *desc =
&__event_desc___compat_syscall_entry_unknown;
+ struct lttng_event *event;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
ev.instrumentation = LTTNG_KERNEL_SYSCALL;
ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
- chan->sc_compat_unknown = _lttng_event_create(chan, &ev, filter,
- desc,
- ev.instrumentation);
- WARN_ON_ONCE(!chan->sc_unknown);
- if (IS_ERR(chan->sc_compat_unknown)) {
- return PTR_ERR(chan->sc_compat_unknown);
+ event = _lttng_event_create(container, &ev, &event_enabler->key, filter,
+ desc, ev.instrumentation,
+ event_enabler->base.user_token);
+ if (IS_ERR(event)) {
+ if (PTR_ERR(event) != -EEXIST)
+ return PTR_ERR(event);
+ /* Skip if event is already found. */
+ } else {
+ hlist_add_head(&event->u.syscall.node, &container->sc_compat_unknown);
}
}
- if (!chan->compat_sc_exit_unknown) {
+ {
const struct lttng_event_desc *desc =
&__event_desc___compat_syscall_exit_unknown;
+ struct lttng_event *event;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
ev.instrumentation = LTTNG_KERNEL_SYSCALL;
ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
- chan->compat_sc_exit_unknown = _lttng_event_create(chan, &ev,
- filter, desc,
- ev.instrumentation);
- WARN_ON_ONCE(!chan->compat_sc_exit_unknown);
- if (IS_ERR(chan->compat_sc_exit_unknown)) {
- return PTR_ERR(chan->compat_sc_exit_unknown);
+ event = _lttng_event_create(container, &ev, &event_enabler->key,
+ filter, desc, ev.instrumentation,
+ event_enabler->base.user_token);
+ if (IS_ERR(event)) {
+ if (PTR_ERR(event) != -EEXIST)
+ return PTR_ERR(event);
+ /* Skip if event is already found. */
+ } else {
+ hlist_add_head(&event->u.syscall.node, &container->compat_sc_exit_unknown);
}
}
- if (!chan->sc_exit_unknown) {
+ {
const struct lttng_event_desc *desc =
&__event_desc___syscall_exit_unknown;
+ struct lttng_event *event;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
ev.instrumentation = LTTNG_KERNEL_SYSCALL;
ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
- chan->sc_exit_unknown = _lttng_event_create(chan, &ev, filter,
- desc, ev.instrumentation);
- WARN_ON_ONCE(!chan->sc_exit_unknown);
- if (IS_ERR(chan->sc_exit_unknown)) {
- return PTR_ERR(chan->sc_exit_unknown);
+ event = _lttng_event_create(container, &ev, &event_enabler->key, filter,
+ desc, ev.instrumentation,
+ event_enabler->base.user_token);
+ if (IS_ERR(event)) {
+ if (PTR_ERR(event) != -EEXIST)
+ return PTR_ERR(event);
+ /* Skip if event is already found. */
+ } else {
+ hlist_add_head(&event->u.syscall.node, &container->sc_exit_unknown);
}
}
- ret = fill_event_table(sc_table, ARRAY_SIZE(sc_table),
- chan->sc_table, chan, filter, SC_TYPE_ENTRY);
+ ret = lttng_create_syscall_event_if_missing(sc_table, ARRAY_SIZE(sc_table),
+ container->sc_table, event_enabler, filter, SC_TYPE_ENTRY);
if (ret)
return ret;
- ret = fill_event_table(sc_exit_table, ARRAY_SIZE(sc_exit_table),
- chan->sc_exit_table, chan, filter, SC_TYPE_EXIT);
+ ret = lttng_create_syscall_event_if_missing(sc_exit_table, ARRAY_SIZE(sc_exit_table),
+ container->sc_exit_table, event_enabler, filter, SC_TYPE_EXIT);
if (ret)
return ret;
#ifdef CONFIG_COMPAT
- ret = fill_event_table(compat_sc_table, ARRAY_SIZE(compat_sc_table),
- chan->compat_sc_table, chan, filter,
+ ret = lttng_create_syscall_event_if_missing(compat_sc_table, ARRAY_SIZE(compat_sc_table),
+ container->compat_sc_table, event_enabler, filter,
SC_TYPE_COMPAT_ENTRY);
if (ret)
return ret;
- ret = fill_event_table(compat_sc_exit_table, ARRAY_SIZE(compat_sc_exit_table),
- chan->compat_sc_exit_table, chan, filter,
+ ret = lttng_create_syscall_event_if_missing(compat_sc_exit_table, ARRAY_SIZE(compat_sc_exit_table),
+ container->compat_sc_exit_table, event_enabler, filter,
SC_TYPE_COMPAT_EXIT);
if (ret)
return ret;
#endif
- if (!chan->sc_filter) {
- chan->sc_filter = kzalloc(sizeof(struct lttng_syscall_filter),
+ if (!container->sc_filter) {
+ container->sc_filter = kzalloc(sizeof(struct lttng_syscall_filter),
GFP_KERNEL);
- if (!chan->sc_filter)
+ if (!container->sc_filter)
return -ENOMEM;
}
- if (!chan->sys_enter_registered) {
+ if (!container->sys_enter_registered) {
ret = lttng_wrapper_tracepoint_probe_register("sys_enter",
- (void *) syscall_entry_event_probe, chan);
+ (void *) syscall_entry_event_probe, container);
if (ret)
return ret;
- chan->sys_enter_registered = 1;
+ container->sys_enter_registered = 1;
}
/*
* We change the name of sys_exit tracepoint due to namespace
* conflict with sys_exit syscall entry.
*/
- if (!chan->sys_exit_registered) {
+ if (!container->sys_exit_registered) {
ret = lttng_wrapper_tracepoint_probe_register("sys_exit",
- (void *) syscall_exit_event_probe, chan);
+ (void *) syscall_exit_event_probe, container);
if (ret) {
WARN_ON_ONCE(lttng_wrapper_tracepoint_probe_unregister("sys_enter",
- (void *) syscall_entry_event_probe, chan));
+ (void *) syscall_entry_event_probe, container));
return ret;
}
- chan->sys_exit_registered = 1;
+ container->sys_exit_registered = 1;
}
return ret;
}
continue;
}
- if (!lttng_desc_match_enabler(desc,
- lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)))
+ if (lttng_desc_match_enabler(desc,
+ lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)) <= 0)
continue;
/*
end:
return ret;
-
}
int lttng_syscals_create_matching_event_notifiers(
/*
* Unregister the syscall event_notifier probes from the callsites.
*/
-int lttng_syscalls_unregister_event_notifier(
+int lttng_syscalls_unregister_event_notifier_group(
struct lttng_event_notifier_group *event_notifier_group)
{
int ret;
return 0;
}
-int lttng_syscalls_unregister_event(struct lttng_channel *chan)
+int lttng_syscalls_unregister_event_container(struct lttng_event_container *container)
{
int ret;
- if (!chan->sc_table)
+ if (!container->sc_table)
return 0;
- if (chan->sys_enter_registered) {
+ if (container->sys_enter_registered) {
ret = lttng_wrapper_tracepoint_probe_unregister("sys_enter",
- (void *) syscall_entry_event_probe, chan);
+ (void *) syscall_entry_event_probe, container);
if (ret)
return ret;
- chan->sys_enter_registered = 0;
+ container->sys_enter_registered = 0;
}
- if (chan->sys_exit_registered) {
+ if (container->sys_exit_registered) {
ret = lttng_wrapper_tracepoint_probe_unregister("sys_exit",
- (void *) syscall_exit_event_probe, chan);
+ (void *) syscall_exit_event_probe, container);
if (ret)
return ret;
- chan->sys_exit_registered = 0;
+ container->sys_exit_registered = 0;
}
return 0;
}
-int lttng_syscalls_destroy_event(struct lttng_channel *chan)
+int lttng_syscalls_destroy_event_container(struct lttng_event_container *container)
{
- kfree(chan->sc_table);
- kfree(chan->sc_exit_table);
+ kfree(container->sc_table);
+ kfree(container->sc_exit_table);
#ifdef CONFIG_COMPAT
- kfree(chan->compat_sc_table);
- kfree(chan->compat_sc_exit_table);
+ kfree(container->compat_sc_table);
+ kfree(container->compat_sc_exit_table);
#endif
- kfree(chan->sc_filter);
+ kfree(container->sc_filter);
return 0;
}
case LTTNG_SYSCALL_ABI_COMPAT:
dispatch_list = &group->event_notifier_compat_syscall_dispatch[syscall_id];
break;
+ default:
+ ret = -EINVAL;
+ goto end;
}
break;
case LTTNG_SYSCALL_EXIT:
case LTTNG_SYSCALL_ABI_COMPAT:
dispatch_list = &group->event_notifier_exit_compat_syscall_dispatch[syscall_id];
break;
+ default:
+ ret = -EINVAL;
+ goto end;
}
break;
+ default:
+ ret = -EINVAL;
+ goto end;
}
hlist_add_head_rcu(¬ifier->u.syscall.node, dispatch_list);
}
int lttng_syscall_filter_enable_event(
- struct lttng_channel *channel,
+ struct lttng_event_container *container,
struct lttng_event *event)
{
WARN_ON_ONCE(event->instrumentation != LTTNG_KERNEL_SYSCALL);
- return lttng_syscall_filter_enable(channel->sc_filter,
+ return lttng_syscall_filter_enable(container->sc_filter,
event->desc->name, event->u.syscall.abi,
event->u.syscall.entryexit);
}
}
int lttng_syscall_filter_disable_event(
- struct lttng_channel *channel,
+ struct lttng_event_container *container,
struct lttng_event *event)
{
- return lttng_syscall_filter_disable(channel->sc_filter,
+ return lttng_syscall_filter_disable(container->sc_filter,
event->desc->name, event->u.syscall.abi,
event->u.syscall.entryexit);
}
/*
* A syscall is enabled if it is traced for either entry or exit.
*/
-long lttng_channel_syscall_mask(struct lttng_channel *channel,
+long lttng_event_container_syscall_mask(struct lttng_event_container *container,
struct lttng_kernel_syscall_mask __user *usyscall_mask)
{
uint32_t len, sc_tables_len, bitmask_len;
tmp_mask = kzalloc(bitmask_len, GFP_KERNEL);
if (!tmp_mask)
return -ENOMEM;
- filter = channel->sc_filter;
+ filter = container->sc_filter;
for (bit = 0; bit < ARRAY_SIZE(sc_table); bit++) {
char state;
- if (channel->sc_table) {
- if (!READ_ONCE(channel->syscall_all) && filter)
+ if (container->sc_table) {
+ if (!(READ_ONCE(container->syscall_all_entry)
+ || READ_ONCE(container->syscall_all_exit)) && filter)
state = test_bit(bit, filter->sc_entry)
|| test_bit(bit, filter->sc_exit);
else
for (; bit < sc_tables_len; bit++) {
char state;
- if (channel->compat_sc_table) {
- if (!READ_ONCE(channel->syscall_all) && filter)
+ if (container->compat_sc_table) {
+ if (!(READ_ONCE(container->syscall_all_entry)
+ || READ_ONCE(container->syscall_all_exit)) && filter)
state = test_bit(bit - ARRAY_SIZE(sc_table),
filter->sc_compat_entry)
|| test_bit(bit - ARRAY_SIZE(sc_table),