struct lttng_event_desc {
const char *name; /* lttng-modules name */
const char *kname; /* Linux kernel name (tracepoints) */
- void *probe_callback;
+ void *probe_callback; /* store-event and count-event probe */
const struct lttng_event_ctx *ctx; /* context */
const struct lttng_event_field *fields; /* event payload */
unsigned int nr_fields;
struct lttng_kprobe {
struct kprobe kp;
char *symbol_name;
+ uint64_t user_token;
};
struct lttng_uprobe {
struct inode *inode;
struct list_head head;
+ uint64_t user_token;
};
enum lttng_syscall_entryexit {
LTTNG_SYSCALL_ABI_COMPAT,
};
+struct lttng_syscall {
+ struct list_head node; /* chain registered syscall trigger */
+ unsigned int syscall_id;
+ bool is_compat;
+};
+
+enum lttng_key_token_type {
+ LTTNG_KEY_TOKEN_STRING = 0,
+ LTTNG_KEY_TOKEN_EVENT_NAME = 1,
+};
+
+#define LTTNG_KEY_TOKEN_STRING_LEN_MAX LTTNG_KERNEL_KEY_TOKEN_STRING_LEN_MAX
+struct lttng_key_token {
+ enum lttng_key_token_type type;
+ union {
+ char string[LTTNG_KEY_TOKEN_STRING_LEN_MAX];
+ } arg;
+};
+
+#define LTTNG_NR_KEY_TOKEN LTTNG_KERNEL_NR_KEY_TOKEN
+struct lttng_counter_key_dimension {
+ size_t nr_key_tokens;
+ struct lttng_key_token key_tokens[LTTNG_KERNEL_NR_KEY_TOKEN];
+};
+
+#define LTTNG_COUNTER_DIMENSION_MAX LTTNG_KERNEL_COUNTER_DIMENSION_MAX
+struct lttng_counter_key {
+ size_t nr_dimensions;
+ struct lttng_counter_key_dimension key_dimensions[LTTNG_COUNTER_DIMENSION_MAX];
+};
+
+#define LTTNG_KEY_TOKEN_STRING_LEN_MAX LTTNG_KERNEL_KEY_TOKEN_STRING_LEN_MAX
+
/*
* lttng_event structure is referred to by the tracing fast path. It must be
* kept small.
*/
struct lttng_event {
enum lttng_event_type evtype; /* First field. */
- unsigned int id;
- struct lttng_channel *chan;
+ struct lttng_event_container *container;
+ size_t id;
int enabled;
const struct lttng_event_desc *desc;
void *filter;
struct {
struct lttng_krp *lttng_krp;
char *symbol_name;
+ uint64_t user_token;
} kretprobe;
struct lttng_uprobe uprobe;
struct {
/* Backward references: list of lttng_enabler_ref (ref to enablers) */
struct list_head enablers_ref_head;
- struct hlist_node hlist; /* session ht of events */
+ struct hlist_node name_hlist; /* session ht of events, per event name */
+ struct hlist_node key_hlist; /* session ht of events, per key */
int registered; /* has reg'd tracepoint probe */
/* list of struct lttng_bytecode_runtime, sorted by seqnum */
struct list_head filter_bytecode_runtime_head;
int has_enablers_without_bytecode;
+
+ /* List node of actions to perform (for syscall events). */
+ struct hlist_node action_list;
+
+ char key[LTTNG_KEY_TOKEN_STRING_LEN_MAX];
+
+ /*
+ * For non-coalesce-hit event containers, each event is
+ * associated with a single event enabler user_token.
+ */
+ uint64_t user_token;
+};
+
+struct lttng_kernel_notifier_ctx {
+ int eval_capture;
};
// FIXME: Really similar to lttng_event above. Could those be merged ?
size_t num_captures;
struct list_head capture_bytecode_runtime_head;
int has_enablers_without_bytecode;
+ int eval_capture; /* Should evaluate capture */
void (*send_notification)(struct lttng_event_notifier *event_notifier,
struct lttng_probe_ctx *lttng_probe_ctx,
- const char *interpreter_stack_data);
+ const char *interpreter_stack_data,
+ struct lttng_kernel_notifier_ctx *notif_ctx);
struct lttng_event_notifier_group *group; /* Weak ref */
};
struct lttng_event_enabler {
struct lttng_enabler base;
struct list_head node; /* per-session list of enablers */
- struct lttng_channel *chan;
+ struct lttng_event_container *container;
+ struct lttng_counter_key key;
/*
* Unused, but kept around to make it explicit that the tracer can do
* it.
struct hlist_head table[LTTNG_EVENT_NOTIFIER_HT_SIZE];
};
-struct lttng_channel {
- unsigned int id;
- struct channel *chan; /* Channel buffers */
+enum lttng_event_container_type {
+ LTTNG_EVENT_CONTAINER_CHANNEL,
+ LTTNG_EVENT_CONTAINER_COUNTER,
+};
+
+/*
+ * An event can be contained within either a channel or a counter.
+ */
+struct lttng_event_container {
+ enum lttng_event_container_type type;
+
+ struct file *file; /* File associated to event container */
+ struct lttng_session *session; /* Session containing the container */
int enabled;
- struct lttng_ctx *ctx;
- /* Event ID management */
- struct lttng_session *session;
- struct file *file; /* File associated to channel */
- unsigned int free_event_id; /* Next event ID to allocate */
- struct list_head list; /* Channel list */
- struct lttng_channel_ops *ops;
- struct lttng_transport *transport;
- struct hlist_head *sc_table; /* for syscall tracing */
+ struct hlist_head *sc_table; /* for syscall tracing */
struct hlist_head *compat_sc_table;
struct hlist_head *sc_exit_table; /* for syscall exit tracing */
struct hlist_head *compat_sc_exit_table;
- struct hlist_head sc_unknown; /* for unknown syscalls */
+
+ /*
+ * Combining all unknown syscall events works as long as they
+ * are only matched by "all" syscalls enablers, but will require
+ * a design change when we allow matching by syscall number, for
+ * instance by allocating sc_tables accomodating NR_syscalls
+ * entries.
+ */
+ struct hlist_head sc_unknown; /* for unknown syscalls */
struct hlist_head sc_compat_unknown;
struct hlist_head sc_exit_unknown;
struct hlist_head compat_sc_exit_unknown;
+
struct lttng_syscall_filter *sc_filter;
- int header_type; /* 0: unset, 1: compact, 2: large */
- enum channel_type channel_type;
int syscall_all_entry;
int syscall_all_exit;
- unsigned int metadata_dumped:1,
- sys_enter_registered:1,
+ unsigned int sys_enter_registered:1,
sys_exit_registered:1,
- tstate:1; /* Transient enable state */
+ tstate:1; /* Transient enable state */
+ bool coalesce_hits;
+};
+
+struct lttng_channel {
+ unsigned int id;
+ struct channel *chan; /* Channel buffers */
+ struct lttng_ctx *ctx;
+ /* Event ID management */
+ unsigned int free_event_id; /* Next event ID to allocate */
+ struct list_head list; /* Channel list */
+ struct lttng_channel_ops *ops;
+ struct lttng_transport *transport;
+ int header_type; /* 0: unset, 1: compact, 2: large */
+ enum channel_type channel_type;
+ unsigned int metadata_dumped:1;
+
+ struct lttng_event_container parent;
};
struct lttng_metadata_stream {
struct file *file; /* File associated to session */
struct list_head chan; /* Channel list head */
struct list_head events; /* Event list head */
+ struct list_head counters; /* Counters list head */
struct list_head list; /* Session list */
unsigned int free_chan_id; /* Next chan ID to allocate */
uuid_le uuid; /* Trace session unique ID */
tstate:1; /* Transient enable state */
/* List of event enablers */
struct list_head enablers_head;
- /* Hash table of events */
- struct lttng_event_ht events_ht;
+ /* Hash table of events indexed by event name */
+ struct lttng_event_ht events_name_ht;
+ /* Hash table of events indexed by key */
+ struct lttng_event_ht events_key_ht;
char name[LTTNG_KERNEL_SESSION_NAME_LEN];
char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
};
+struct lttng_counter_map_descriptor {
+ uint64_t user_token;
+ size_t array_index;
+ char key[LTTNG_KERNEL_COUNTER_KEY_LEN];
+};
+
+struct lttng_counter_map {
+ struct lttng_counter_map_descriptor *descriptors;
+ size_t nr_descriptors;
+ size_t alloc_len;
+ struct mutex lock; /* counter map lock */
+};
+
struct lttng_counter {
- struct file *file; /* File associated to counter. */
struct file *owner;
struct lttng_counter_transport *transport;
struct lib_counter *counter;
struct lttng_counter_ops *ops;
+ struct list_head node; /* Counter list (in session) */
+
+ size_t free_index; /* Next index to allocate */
+ struct lttng_counter_map map;
+
+ struct lttng_event_container parent;
};
struct lttng_event_notifier_group {
uint64_t version; /* Current version of the metadata */
};
+static inline
+struct lttng_event_container *lttng_channel_get_event_container(struct lttng_channel *channel)
+{
+ return &channel->parent;
+}
+
+static inline
+struct lttng_event_container *lttng_counter_get_event_container(struct lttng_counter *counter)
+{
+ return &counter->parent;
+}
+
+static inline
+struct lttng_channel *lttng_event_container_get_channel(struct lttng_event_container *container)
+{
+ if (container->type != LTTNG_EVENT_CONTAINER_CHANNEL)
+ return NULL;
+ return container_of(container, struct lttng_channel, parent);
+}
+
+static inline
+struct lttng_counter *lttng_event_container_get_counter(struct lttng_event_container *container)
+{
+ if (container->type != LTTNG_EVENT_CONTAINER_COUNTER)
+ return NULL;
+ return container_of(container, struct lttng_counter, parent);
+}
+
void lttng_lock_sessions(void);
void lttng_unlock_sessions(void);
struct lttng_event_enabler *lttng_event_enabler_create(
enum lttng_enabler_format_type format_type,
struct lttng_kernel_event *event_param,
- struct lttng_channel *chan);
+ const struct lttng_counter_key *key,
+ struct lttng_event_container *container);
int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler);
int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler);
int lttng_session_statedump(struct lttng_session *session);
void metadata_cache_destroy(struct kref *kref);
-struct lttng_counter *lttng_kernel_counter_create(
- const char *counter_transport_name, size_t number_dimensions,
- const size_t *dimensions_sizes);
int lttng_kernel_counter_read(struct lttng_counter *counter,
const size_t *dimension_indexes, int32_t cpu,
int64_t *val, bool *overflow, bool *underflow);
int lttng_event_notifier_group_create_error_counter(
struct file *event_notifier_group_file,
const struct lttng_kernel_counter_conf *error_counter_conf);
+
void lttng_event_notifier_group_destroy(
struct lttng_event_notifier_group *event_notifier_group);
+int lttng_event_notifier_group_set_error_counter(
+ struct lttng_event_notifier_group *event_notifier_group,
+ const char *counter_transport_name,
+ size_t counter_len);
struct lttng_channel *lttng_channel_create(struct lttng_session *session,
const char *transport_name,
unsigned int switch_timer_interval,
unsigned int read_timer_interval,
enum channel_type channel_type);
-struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
- int overwrite, void *buf_addr,
- size_t subbuf_size, size_t num_subbuf,
- unsigned int switch_timer_interval,
- unsigned int read_timer_interval);
void lttng_metadata_channel_destroy(struct lttng_channel *chan);
-struct lttng_event *lttng_event_create(struct lttng_channel *chan,
+struct lttng_event *lttng_event_create(struct lttng_event_container *container,
struct lttng_kernel_event *event_param,
+ const struct lttng_counter_key *key,
void *filter,
const struct lttng_event_desc *event_desc,
- enum lttng_kernel_instrumentation itype);
-struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
+ enum lttng_kernel_instrumentation itype,
+ uint64_t user_token);
+struct lttng_event *_lttng_event_create(struct lttng_event_container *container,
struct lttng_kernel_event *event_param,
+ const struct lttng_counter_key *key,
void *filter,
const struct lttng_event_desc *event_desc,
- enum lttng_kernel_instrumentation itype);
-struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
- struct lttng_kernel_old_event *old_event_param,
- void *filter,
- const struct lttng_event_desc *internal_desc);
+ enum lttng_kernel_instrumentation itype,
+ uint64_t user_token);
+struct lttng_counter *lttng_session_create_counter(
+ struct lttng_session *session,
+ const char *counter_transport_name,
+ size_t number_dimensions, const size_t *dimensions_sizes,
+ bool coalesce_hits);
struct lttng_event_notifier *lttng_event_notifier_create(
const struct lttng_event_desc *event_notifier_desc,
void *filter,
enum lttng_kernel_instrumentation itype);
-int lttng_channel_enable(struct lttng_channel *channel);
-int lttng_channel_disable(struct lttng_channel *channel);
+int lttng_event_container_enable(struct lttng_event_container *container);
+int lttng_event_container_disable(struct lttng_event_container *container);
int lttng_event_enable(struct lttng_event *event);
int lttng_event_disable(struct lttng_event *event);
#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler, void *filter);
-int lttng_syscalls_unregister_channel(struct lttng_channel *chan);
-int lttng_syscalls_destroy_event(struct lttng_channel *chan);
-int lttng_syscall_filter_enable_event(
- struct lttng_channel *chan,
+int lttng_syscalls_unregister_event_container(struct lttng_event_container *event_container);
+int lttng_syscalls_destroy_event_container(struct lttng_event_container *container);
+int lttng_syscall_filter_enable_event(struct lttng_event_container *container,
struct lttng_event *event);
-int lttng_syscall_filter_disable_event(
- struct lttng_channel *chan,
+int lttng_syscall_filter_disable_event(struct lttng_event_container *container,
struct lttng_event *event);
-
-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);
int lttng_syscalls_register_event_notifier(
return -ENOSYS;
}
-static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan)
+static inline int lttng_syscalls_unregister_event_container(struct lttng_event_container *event_container)
{
return 0;
}
-static inline int lttng_syscalls_destroy(struct lttng_channel *chan)
+static inline int lttng_syscalls_destroy_event_container(struct lttng_event_container *event_container)
{
return 0;
}
-static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan,
+static inline int lttng_syscall_filter_enable_event(struct lttng_event_container *event_container,
struct lttng_event *event);
{
return -ENOSYS;
}
-static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan,
+static inline int lttng_syscall_filter_disable_event(struct lttng_event_container *event_container,
struct lttng_event *event);
{
return -ENOSYS;
}
-static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
+static inline long lttng_channel_syscall_mask(struct lttng_event_container *event_container,
struct lttng_kernel_syscall_mask __user *usyscall_mask)
{
return -ENOSYS;
struct lttng_ctx *ctx,
struct list_head *instance_bytecode_runtime_head,
struct list_head *enabler_bytecode_runtime_head);
+void lttng_free_event_filter_runtime(struct lttng_event *event);
+void lttng_free_event_notifier_filter_runtime(struct lttng_event_notifier *event_notifier);
int lttng_probes_init(void);