struct lttng_event_enabler {
struct lttng_enabler base;
- struct list_head node; /* per-session list of enablers */
+ struct list_head node; /* per-session list of enablers */
+ bool published; /* published in per-session list. */
struct lttng_kernel_channel_buffer *chan;
};
enum lttng_enabler_format_type format_type,
struct lttng_kernel_abi_event *event_param,
struct lttng_kernel_channel_buffer *chan);
+void lttng_event_enabler_session_add(struct lttng_kernel_session *session,
+ struct lttng_event_enabler *event_enabler);
+void lttng_event_enabler_destroy(struct lttng_event_enabler *event_enabler);
int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler);
int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler);
unsigned int read_timer_interval);
void lttng_metadata_channel_destroy(struct lttng_kernel_channel_buffer *chan);
-struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_kernel_channel_buffer *chan,
- struct lttng_kernel_abi_event *event_param,
- const struct lttng_kernel_event_desc *event_desc,
- enum lttng_kernel_abi_instrumentation itype);
-struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_kernel_channel_buffer *chan,
- struct lttng_kernel_abi_event *event_param,
- const struct lttng_kernel_event_desc *event_desc,
- enum lttng_kernel_abi_instrumentation itype);
+struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_event_enabler *event_enabler,
+ const struct lttng_kernel_event_desc *event_desc);
+struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_event_enabler *event_enabler,
+ const struct lttng_kernel_event_desc *event_desc);
struct lttng_kernel_event_recorder *lttng_event_compat_old_create(struct lttng_kernel_channel_buffer *chan,
struct lttng_kernel_abi_old_event *old_event_param,
const struct lttng_kernel_event_desc *internal_desc);
static void lttng_session_lazy_sync_event_enablers(struct lttng_kernel_session *session);
static void lttng_session_sync_event_enablers(struct lttng_kernel_session *session);
-static void lttng_event_enabler_destroy(struct lttng_event_enabler *event_enabler);
static void lttng_event_notifier_enabler_destroy(struct lttng_event_notifier_enabler *event_notifier_enabler);
static void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group *event_notifier_group);
* Supports event creation while tracing session is active.
* Needs to be called with sessions mutex held.
*/
-struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_kernel_channel_buffer *chan,
- struct lttng_kernel_abi_event *event_param,
- const struct lttng_kernel_event_desc *event_desc,
- enum lttng_kernel_abi_instrumentation itype)
+struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_event_enabler *event_enabler,
+ const struct lttng_kernel_event_desc *event_desc)
{
+ struct lttng_kernel_channel_buffer *chan = event_enabler->chan;
+ struct lttng_kernel_abi_event *event_param = &event_enabler->base.event_param;
+ enum lttng_kernel_abi_instrumentation itype = event_param->instrumentation;
struct lttng_kernel_session *session = chan->parent.session;
struct lttng_kernel_event_recorder *event_recorder;
struct lttng_kernel_event_recorder_private *event_recorder_priv;
return counter->ops->counter_clear(counter->counter, dim_indexes);
}
-struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_kernel_channel_buffer *chan,
- struct lttng_kernel_abi_event *event_param,
- const struct lttng_kernel_event_desc *event_desc,
- enum lttng_kernel_abi_instrumentation itype)
+struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_event_enabler *event_enabler,
+ const struct lttng_kernel_event_desc *event_desc)
{
struct lttng_kernel_event_recorder *event;
mutex_lock(&sessions_mutex);
- event = _lttng_kernel_event_recorder_create(chan, event_param, event_desc, itype);
+ event = _lttng_kernel_event_recorder_create(event_enabler, event_desc);
mutex_unlock(&sessions_mutex);
return event;
}
* We need to create an event for this
* event probe.
*/
- event_recorder = _lttng_kernel_event_recorder_create(event_enabler->chan,
- NULL, desc, LTTNG_KERNEL_ABI_TRACEPOINT);
+ event_recorder = _lttng_kernel_event_recorder_create(event_enabler, desc);
if (!event_recorder) {
printk(KERN_INFO "LTTng: Unable to create event %s\n",
probe_desc->event_desc[i]->event_name);
event_enabler->chan = chan;
/* ctx left NULL */
event_enabler->base.enabled = 0;
+ return event_enabler;
+}
+
+void lttng_event_enabler_session_add(struct lttng_kernel_session *session,
+ struct lttng_event_enabler *event_enabler)
+{
mutex_lock(&sessions_mutex);
- list_add(&event_enabler->node, &event_enabler->chan->parent.session->priv->enablers_head);
- lttng_session_lazy_sync_event_enablers(event_enabler->chan->parent.session);
+ list_add(&event_enabler->node, &session->priv->enablers_head);
+ event_enabler->published = true;
+ lttng_session_lazy_sync_event_enablers(session);
mutex_unlock(&sessions_mutex);
- return event_enabler;
}
int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler)
}
}
-static
void lttng_event_enabler_destroy(struct lttng_event_enabler *event_enabler)
{
lttng_enabler_destroy(lttng_event_enabler_as_enabler(event_enabler));
- list_del(&event_enabler->node);
+ if (event_enabler->published)
+ list_del(&event_enabler->node);
kfree(event_enabler);
}
*/
static
int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *table, size_t table_len,
- struct hlist_head *chan_table, struct lttng_event_enabler *event_enabler,
+ struct hlist_head *chan_table, struct lttng_event_enabler *syscall_event_enabler,
enum sc_type type)
{
- struct lttng_kernel_channel_buffer *chan = event_enabler->chan;
+ struct lttng_kernel_channel_buffer *chan = syscall_event_enabler->chan;
struct lttng_kernel_session *session = chan->parent.session;
unsigned int i;
/* Allocate events for each syscall matching enabler, insert into table */
for (i = 0; i < table_len; i++) {
const struct lttng_kernel_event_desc *desc = table[i].desc;
+ struct lttng_event_enabler *event_enabler;
struct lttng_kernel_abi_event ev;
struct lttng_kernel_event_recorder_private *event_recorder_priv;
struct lttng_kernel_event_recorder *event_recorder;
continue;
}
if (lttng_desc_match_enabler(desc,
- lttng_event_enabler_as_enabler(event_enabler)) <= 0)
+ lttng_event_enabler_as_enabler(syscall_event_enabler)) <= 0)
continue;
/*
* Check if already created.
desc->event_name);
lttng_hlist_for_each_entry(event_recorder_priv, head, hlist) {
if (event_recorder_priv->parent.desc == desc
- && event_recorder_priv->pub->chan == event_enabler->chan)
+ && event_recorder_priv->pub->chan == chan)
found = true;
}
if (found)
strncpy(ev.name, desc->event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1);
ev.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
ev.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
- event_recorder = _lttng_kernel_event_recorder_create(chan, &ev, desc, ev.instrumentation);
+ event_enabler = lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan);
+ if (!event_enabler) {
+ return -ENOMEM;
+ }
+ event_recorder = _lttng_kernel_event_recorder_create(event_enabler, desc);
WARN_ON_ONCE(!event_recorder);
+ lttng_event_enabler_destroy(event_enabler);
if (IS_ERR(event_recorder)) {
/*
* If something goes wrong in event registration
/*
* Should be called with sessions lock held.
*/
-int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler)
+int lttng_syscalls_register_event(struct lttng_event_enabler *syscall_event_enabler)
{
- struct lttng_kernel_channel_buffer *chan = event_enabler->chan;
+ struct lttng_kernel_channel_buffer *chan = syscall_event_enabler->chan;
struct lttng_kernel_abi_event ev;
int ret;
const struct lttng_kernel_event_desc *desc =
&__event_desc___syscall_entry_unknown;
struct lttng_kernel_event_recorder *event_recorder;
+ struct lttng_event_enabler *event_enabler;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN);
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_recorder = _lttng_kernel_event_recorder_create(chan, &ev, desc,
- ev.instrumentation);
+ event_enabler = lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan);
+ if (!event_enabler) {
+ return -ENOMEM;
+ }
+ event_recorder = _lttng_kernel_event_recorder_create(event_enabler, desc);
+ lttng_event_enabler_destroy(event_enabler);
WARN_ON_ONCE(!event_recorder);
if (IS_ERR(event_recorder)) {
return PTR_ERR(event_recorder);
const struct lttng_kernel_event_desc *desc =
&__event_desc___compat_syscall_entry_unknown;
struct lttng_kernel_event_recorder *event_recorder;
+ struct lttng_event_enabler *event_enabler;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN);
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_recorder = _lttng_kernel_event_recorder_create(chan, &ev, desc,
- ev.instrumentation);
+ event_enabler = lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan);
+ if (!event_enabler) {
+ return -ENOMEM;
+ }
+ event_recorder = _lttng_kernel_event_recorder_create(event_enabler, desc);
WARN_ON_ONCE(!event_recorder);
+ lttng_event_enabler_destroy(event_enabler);
if (IS_ERR(event_recorder)) {
return PTR_ERR(event_recorder);
}
const struct lttng_kernel_event_desc *desc =
&__event_desc___compat_syscall_exit_unknown;
struct lttng_kernel_event_recorder *event_recorder;
+ struct lttng_event_enabler *event_enabler;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN);
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_recorder = _lttng_kernel_event_recorder_create(chan, &ev, desc,
- ev.instrumentation);
+ event_enabler = lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan);
+ if (!event_enabler) {
+ return -ENOMEM;
+ }
+ event_recorder = _lttng_kernel_event_recorder_create(event_enabler, desc);
WARN_ON_ONCE(!event_recorder);
+ lttng_event_enabler_destroy(event_enabler);
if (IS_ERR(event_recorder)) {
return PTR_ERR(event_recorder);
}
const struct lttng_kernel_event_desc *desc =
&__event_desc___syscall_exit_unknown;
struct lttng_kernel_event_recorder *event_recorder;
+ struct lttng_event_enabler *event_enabler;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN);
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_recorder = _lttng_kernel_event_recorder_create(chan, &ev, desc,
- ev.instrumentation);
+ event_enabler = lttng_event_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev, chan);
+ if (!event_enabler) {
+ return -ENOMEM;
+ }
+ event_recorder = _lttng_kernel_event_recorder_create(event_enabler, desc);
WARN_ON_ONCE(!event_recorder);
+ lttng_event_enabler_destroy(event_enabler);
if (IS_ERR(event_recorder)) {
return PTR_ERR(event_recorder);
}
}
ret = lttng_create_syscall_event_if_missing(sc_table.table, sc_table.len,
- chan->priv->parent.sc_table, event_enabler, SC_TYPE_ENTRY);
+ chan->priv->parent.sc_table, syscall_event_enabler, SC_TYPE_ENTRY);
if (ret)
return ret;
ret = lttng_create_syscall_event_if_missing(sc_exit_table.table, sc_exit_table.len,
- chan->priv->parent.sc_exit_table, event_enabler, SC_TYPE_EXIT);
+ chan->priv->parent.sc_exit_table, syscall_event_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,
- chan->priv->parent.compat_sc_table, event_enabler, SC_TYPE_COMPAT_ENTRY);
+ chan->priv->parent.compat_sc_table, syscall_event_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,
- chan->priv->parent.compat_sc_exit_table, event_enabler, SC_TYPE_COMPAT_EXIT);
+ chan->priv->parent.compat_sc_exit_table, syscall_event_enabler, SC_TYPE_COMPAT_EXIT);
if (ret)
return ret;
#endif