struct lttng_event_enabler_common parent;
uint64_t error_counter_index;
struct list_head node; /* List of event_notifier enablers */
+ bool published; /* published in group list. */
struct lttng_event_notifier_group *group;
/* head list of struct lttng_kernel_bytecode_node */
struct lttng_event_recorder_enabler *event_enabler);
struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
- struct lttng_event_notifier_group *event_notifier_group,
enum lttng_enabler_format_type format_type,
- struct lttng_kernel_abi_event_notifier *event_notifier_param);
+ struct lttng_kernel_abi_event_notifier *event_notifier_param,
+ struct lttng_event_notifier_group *event_notifier_group);
+void lttng_event_notifier_enabler_group_add(struct lttng_event_notifier_group *event_notifier_group,
+ struct lttng_event_notifier_enabler *event_notifier_enabler);
int lttng_event_notifier_enabler_attach_capture_bytecode(
struct lttng_event_notifier_enabler *event_notifier_enabler,
struct lttng_kernel_abi_capture_bytecode __user *bytecode);
struct lttng_kernel_abi_old_event *old_event_param,
const struct lttng_kernel_event_desc *internal_desc);
-struct lttng_kernel_event_notifier *lttng_event_notifier_create(
- const struct lttng_kernel_event_desc *event_notifier_desc,
- uint64_t id,
- uint64_t error_counter_idx,
- struct lttng_event_notifier_group *event_notifier_group,
- struct lttng_kernel_abi_event_notifier *event_notifier_param,
- enum lttng_kernel_abi_instrumentation itype);
-struct lttng_kernel_event_notifier *_lttng_event_notifier_create(
- const struct lttng_kernel_event_desc *event_notifier_desc,
- uint64_t id,
- uint64_t error_counter_idx,
- struct lttng_event_notifier_group *event_notifier_group,
- struct lttng_kernel_abi_event_notifier *event_notifier_param,
- enum lttng_kernel_abi_instrumentation itype);
+struct lttng_kernel_event_notifier *lttng_event_notifier_create(struct lttng_event_notifier_enabler *event_enabler,
+ const struct lttng_kernel_event_desc *event_notifier_desc);
+struct lttng_kernel_event_notifier *_lttng_event_notifier_create(struct lttng_event_notifier_enabler *event_enabler,
+ const struct lttng_kernel_event_desc *event_notifier_desc);
int lttng_channel_enable(struct lttng_kernel_channel_common *channel);
int lttng_channel_disable(struct lttng_kernel_channel_common *channel);
* we create the special star globbing enabler.
*/
enabler = lttng_event_notifier_enabler_create(
- event_notifier_group,
LTTNG_ENABLER_FORMAT_STAR_GLOB,
- event_notifier_param);
+ event_notifier_param,
+ event_notifier_group);
} else {
enabler = lttng_event_notifier_enabler_create(
- event_notifier_group,
LTTNG_ENABLER_FORMAT_NAME,
- event_notifier_param);
+ event_notifier_param,
+ event_notifier_group);
}
+ if (enabler)
+ lttng_event_notifier_enabler_group_add(event_notifier_group, enabler);
priv = enabler;
break;
}
case LTTNG_KERNEL_ABI_UPROBE:
{
struct lttng_kernel_event_notifier *event_notifier;
+ struct lttng_event_notifier_enabler *event_notifier_enabler;
- /*
- * We tolerate no failure path after event notifier creation.
- * It will stay invariant for the rest of the session.
- */
- event_notifier = lttng_event_notifier_create(NULL,
- event_notifier_param->event.token,
- event_notifier_param->error_counter_index,
- event_notifier_group,
- event_notifier_param,
- event_notifier_param->event.instrumentation);
+ event_notifier_enabler = lttng_event_notifier_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ event_notifier_param, event_notifier_group);
+ if (!event_notifier_enabler) {
+ ret = -ENOMEM;
+ goto event_notifier_error;
+ }
+ event_notifier = lttng_event_notifier_create(event_notifier_enabler, NULL);
WARN_ON_ONCE(!event_notifier);
+ lttng_event_enabler_destroy(&event_notifier_enabler->parent);
if (IS_ERR(event_notifier)) {
ret = PTR_ERR(event_notifier);
goto event_notifier_error;
return ERR_PTR(ret);
}
-struct lttng_kernel_event_notifier *_lttng_event_notifier_create(
- const struct lttng_kernel_event_desc *event_desc,
- uint64_t token, uint64_t error_counter_index,
- struct lttng_event_notifier_group *event_notifier_group,
- struct lttng_kernel_abi_event_notifier *event_notifier_param,
- enum lttng_kernel_abi_instrumentation itype)
+struct lttng_kernel_event_notifier *_lttng_event_notifier_create(struct lttng_event_notifier_enabler *event_enabler,
+ const struct lttng_kernel_event_desc *event_desc)
{
+ struct lttng_event_notifier_group *event_notifier_group = event_enabler->group;
+ struct lttng_kernel_abi_event *event_param = &event_enabler->parent.event_param;
+ uint64_t token = event_enabler->parent.user_token;
+ enum lttng_kernel_abi_instrumentation itype = event_param->instrumentation;
struct lttng_kernel_event_notifier *event_notifier;
struct lttng_kernel_event_notifier_private *event_notifier_priv;
struct lttng_counter *error_counter;
case LTTNG_KERNEL_ABI_UPROBE:
lttng_fallthrough;
case LTTNG_KERNEL_ABI_SYSCALL:
- event_name = event_notifier_param->event.name;
+ event_name = event_param->name;
break;
case LTTNG_KERNEL_ABI_KRETPROBE:
event_notifier->parent.type = LTTNG_KERNEL_EVENT_TYPE_NOTIFIER;
event_notifier->priv->group = event_notifier_group;
- event_notifier->priv->parent.user_token = token;
- event_notifier->priv->error_counter_index = error_counter_index;
+ event_notifier->priv->parent.user_token = event_enabler->parent.user_token;
+ event_notifier->priv->error_counter_index = event_enabler->error_counter_index;
event_notifier->priv->num_captures = 0;
event_notifier->priv->parent.instrumentation = itype;
event_notifier->notification_send = lttng_event_notifier_notification_send;
* registration.
*/
smp_wmb();
- ret = lttng_kprobes_register_event(event_notifier_param->event.u.kprobe.symbol_name,
- event_notifier_param->event.u.kprobe.symbol_name,
- event_notifier_param->event.u.kprobe.offset,
- event_notifier_param->event.u.kprobe.addr,
+ ret = lttng_kprobes_register_event(event_param->u.kprobe.symbol_name,
+ event_param->u.kprobe.symbol_name,
+ event_param->u.kprobe.offset,
+ event_param->u.kprobe.addr,
&event_notifier->parent);
if (ret) {
ret = -EINVAL;
event_notifier->parent.enabled = 0;
event_notifier->priv->parent.registered = 0;
event_notifier->priv->parent.desc = event_desc;
- switch (event_notifier_param->event.u.syscall.entryexit) {
+ switch (event_param->u.syscall.entryexit) {
case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
ret = -EINVAL;
goto register_error;
event_notifier->priv->parent.u.syscall.entryexit = LTTNG_SYSCALL_EXIT;
break;
}
- switch (event_notifier_param->event.u.syscall.abi) {
+ switch (event_param->u.syscall.abi) {
case LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL:
ret = -EINVAL;
goto register_error;
*/
smp_wmb();
- ret = lttng_uprobes_register_event(event_notifier_param->event.name,
- event_notifier_param->event.u.uprobe.fd,
+ ret = lttng_uprobes_register_event(event_param->name,
+ event_param->u.uprobe.fd,
&event_notifier->parent);
if (ret)
goto register_error;
return event;
}
-struct lttng_kernel_event_notifier *lttng_event_notifier_create(
- const struct lttng_kernel_event_desc *event_desc,
- uint64_t id, uint64_t error_counter_index,
- struct lttng_event_notifier_group *event_notifier_group,
- struct lttng_kernel_abi_event_notifier *event_notifier_param,
- enum lttng_kernel_abi_instrumentation itype)
+struct lttng_kernel_event_notifier *lttng_event_notifier_create(struct lttng_event_notifier_enabler *event_enabler,
+ const struct lttng_kernel_event_desc *event_desc)
{
struct lttng_kernel_event_notifier *event_notifier;
mutex_lock(&sessions_mutex);
- event_notifier = _lttng_event_notifier_create(event_desc, id,
- error_counter_index, event_notifier_group,
- event_notifier_param, itype);
+ event_notifier = _lttng_event_notifier_create(event_enabler, event_desc);
mutex_unlock(&sessions_mutex);
return event_notifier;
}
/*
* We need to create a event_notifier for this event probe.
*/
- event_notifier = _lttng_event_notifier_create(desc,
- event_notifier_enabler->parent.user_token,
- event_notifier_enabler->error_counter_index,
- event_notifier_group, NULL,
- LTTNG_KERNEL_ABI_TRACEPOINT);
+ event_notifier = _lttng_event_notifier_create(event_notifier_enabler, desc);
if (IS_ERR(event_notifier)) {
printk(KERN_INFO "Unable to create event_notifier %s\n",
probe_desc->event_desc[i]->event_name);
struct lttng_event_notifier_enabler *event_notifier_enabler =
container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
- list_del(&event_notifier_enabler->node);
lttng_enabler_destroy(event_enabler);
+ if (event_notifier_enabler->published)
+ list_del(&event_notifier_enabler->node);
kfree(event_notifier_enabler);
break;
}
}
struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
- struct lttng_event_notifier_group *event_notifier_group,
enum lttng_enabler_format_type format_type,
- struct lttng_kernel_abi_event_notifier *event_notifier_param)
+ struct lttng_kernel_abi_event_notifier *event_notifier_param,
+ struct lttng_event_notifier_group *event_notifier_group)
{
struct lttng_event_notifier_enabler *event_notifier_enabler;
event_notifier_enabler->parent.enabled = 0;
event_notifier_enabler->parent.user_token = event_notifier_param->event.token;
event_notifier_enabler->group = event_notifier_group;
+ return event_notifier_enabler;
+}
+void lttng_event_notifier_enabler_group_add(struct lttng_event_notifier_group *event_notifier_group,
+ struct lttng_event_notifier_enabler *event_notifier_enabler)
+{
mutex_lock(&sessions_mutex);
list_add(&event_notifier_enabler->node, &event_notifier_enabler->group->enablers_head);
+ event_notifier_enabler->published = true;
lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group);
-
mutex_unlock(&sessions_mutex);
-
- return event_notifier_enabler;
}
int lttng_event_notifier_enabler_enable(
event_notifier_param.event.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
event_notifier_param.event.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
+ event_notifier_param.event.token = user_token;
event_notifier_param.event.u.syscall.abi = abi;
event_notifier_param.event.u.syscall.entryexit = entryexit;
+ event_notifier_param.error_counter_index = error_counter_index;
- event_notifier = _lttng_event_notifier_create(desc, user_token,
- error_counter_index, group, &event_notifier_param,
- event_notifier_param.event.instrumentation);
+ event_notifier_enabler = lttng_event_notifier_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ &event_notifier_param, group);
+ WARN_ON_ONCE(!event_notifier_enabler);
+ event_notifier = _lttng_event_notifier_create(event_notifier_enabler, desc);
+ lttng_event_enabler_destroy(&event_notifier_enabler->parent);
if (IS_ERR(event_notifier)) {
printk(KERN_INFO "Unable to create unknown notifier %s\n",
desc->event_name);
}
static int create_matching_event_notifiers(
- struct lttng_event_notifier_enabler *event_notifier_enabler,
+ struct lttng_event_notifier_enabler *syscall_event_notifier_enabler,
const struct trace_syscall_entry *table,
size_t table_len, enum sc_type type)
{
- struct lttng_event_notifier_group *group = event_notifier_enabler->group;
+ struct lttng_event_notifier_group *group = syscall_event_notifier_enabler->group;
const struct lttng_kernel_event_desc *desc;
- uint64_t user_token = event_notifier_enabler->parent.user_token;
- uint64_t error_counter_index = event_notifier_enabler->error_counter_index;
+ uint64_t user_token = syscall_event_notifier_enabler->parent.user_token;
+ uint64_t error_counter_index = syscall_event_notifier_enabler->error_counter_index;
unsigned int i;
int ret = 0;
/* iterate over all syscall and create event_notifier that match */
for (i = 0; i < table_len; i++) {
+ struct lttng_event_notifier_enabler *event_notifier_enabler;
struct lttng_kernel_event_notifier_private *event_notifier_priv;
struct lttng_kernel_event_notifier *event_notifier;
struct lttng_kernel_abi_event_notifier event_notifier_param;
}
if (!lttng_desc_match_enabler(desc,
- lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)))
+ lttng_event_notifier_enabler_as_enabler(syscall_event_notifier_enabler)))
continue;
/*
LTTNG_EVENT_HT_SIZE, desc->event_name);
lttng_hlist_for_each_entry(event_notifier_priv, head, hlist) {
if (event_notifier_priv->parent.desc == desc
- && event_notifier_priv->parent.user_token == event_notifier_enabler->parent.user_token)
+ && event_notifier_priv->parent.user_token == syscall_event_notifier_enabler->parent.user_token)
found = 1;
}
if (found)
LTTNG_KERNEL_ABI_SYM_NAME_LEN - strlen(event_notifier_param.event.name) - 1);
event_notifier_param.event.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
event_notifier_param.event.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
-
- event_notifier = _lttng_event_notifier_create(desc, user_token,
- error_counter_index, group, &event_notifier_param,
- event_notifier_param.event.instrumentation);
+ event_notifier_param.event.token = user_token;
+ event_notifier_param.error_counter_index = error_counter_index;
+
+ event_notifier_enabler = lttng_event_notifier_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ &event_notifier_param, group);
+ WARN_ON_ONCE(!event_notifier_enabler);
+ event_notifier = _lttng_event_notifier_create(event_notifier_enabler, desc);
+ lttng_event_enabler_destroy(&event_notifier_enabler->parent);
if (IS_ERR(event_notifier)) {
printk(KERN_INFO "Unable to create event_notifier %s\n",
desc->event_name);