X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fcommon%2Fevents.h;h=a145024969b0dd41758446cd0113c5638010a915;hb=HEAD;hp=b3e11bb383d946d97fe5620fe48b26f369408e39;hpb=36c52fffa1beb46c7c15bb6ac4a4179cae373b98;p=lttng-ust.git diff --git a/src/common/events.h b/src/common/events.h index b3e11bb3..d53a587b 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -18,6 +18,13 @@ #include "common/macros.h" #include "common/ust-context-provider.h" +/* + * The context procname length is part of the LTTng-UST ABI. + * TODO: At the next breaking protocol bump, all users of this macro + * should instead use LTTNG_UST_ABI_PROCNAME_LEN. + */ +#define LTTNG_UST_CONTEXT_PROCNAME_LEN 17 + struct lttng_ust_abi_obj; struct lttng_event_notifier_group; @@ -40,11 +47,18 @@ union lttng_ust_abi_args { int event_notifier_notif_fd; } event_notifier_handle; struct { - void *counter_data; + uint32_t len; + } event_notifier; + struct { + uint32_t len; } counter; struct { + uint32_t len; int shm_fd; } counter_shm; + struct { + uint32_t len; + } counter_event; }; struct lttng_ust_abi_objd_ops { @@ -58,11 +72,65 @@ enum lttng_enabler_format_type { LTTNG_ENABLER_FORMAT_EVENT, }; +enum lttng_key_token_type { + LTTNG_KEY_TOKEN_STRING = 0, + LTTNG_KEY_TOKEN_EVENT_NAME = 1, + LTTNG_KEY_TOKEN_PROVIDER_NAME = 2, +}; + +#define LTTNG_KEY_TOKEN_STRING_LEN_MAX 4096 +struct lttng_key_token { + enum lttng_key_token_type type; + union { + char string[LTTNG_KEY_TOKEN_STRING_LEN_MAX]; + } arg; +}; + +enum lttng_key_type { + LTTNG_KEY_TYPE_TOKENS = 0, + LTTNG_KEY_TYPE_INTEGER = 1, +}; + +#define LTTNG_NR_KEY_TOKEN 8 +struct lttng_counter_key_dimension { + enum lttng_key_type key_type; + + union { + struct { + size_t nr_key_tokens; + struct lttng_key_token key_tokens[LTTNG_NR_KEY_TOKEN]; + } tokens; + } u; +}; + +#define LTTNG_COUNTER_DIMENSION_MAX 4 +struct lttng_counter_key { + size_t nr_dimensions; + struct lttng_counter_key_dimension key_dimensions[LTTNG_COUNTER_DIMENSION_MAX]; +}; + +struct lttng_counter_dimension { + uint64_t size; + uint64_t underflow_index; + uint64_t overflow_index; + enum lttng_key_type key_type; + uint8_t has_underflow; + uint8_t has_overflow; +}; + +enum lttng_event_enabler_type { + LTTNG_EVENT_ENABLER_TYPE_RECORDER, + LTTNG_EVENT_ENABLER_TYPE_NOTIFIER, + LTTNG_EVENT_ENABLER_TYPE_COUNTER, +}; + /* * Enabler field, within whatever object is enabling an event. Target of * backward reference. */ -struct lttng_enabler { +struct lttng_event_enabler_common { + enum lttng_event_enabler_type enabler_type; + enum lttng_enabler_format_type format_type; /* head list of struct lttng_ust_filter_bytecode_node */ @@ -72,26 +140,38 @@ struct lttng_enabler { struct lttng_ust_abi_event event_param; unsigned int enabled:1; + + struct cds_list_head node; /* list of enablers */ + uint64_t user_token; /* User-provided token */ +}; + +struct lttng_event_enabler_session_common { + struct lttng_event_enabler_common parent; + struct lttng_ust_channel_common *chan; }; -struct lttng_event_enabler { - struct lttng_enabler base; - struct cds_list_head node; /* per-session list of enablers */ +struct lttng_event_recorder_enabler { + struct lttng_event_enabler_session_common parent; struct lttng_ust_channel_buffer *chan; - /* - * Unused, but kept around to make it explicit that the tracer can do - * it. - */ - struct lttng_ust_ctx *ctx; +}; + +enum lttng_event_counter_action { + LTTNG_EVENT_COUNTER_ACTION_INCREMENT = 0, +}; + +struct lttng_event_counter_enabler { + struct lttng_event_enabler_session_common parent; + struct lttng_ust_channel_counter *chan; + struct lttng_counter_key key; + + enum lttng_event_counter_action action; }; struct lttng_event_notifier_enabler { - struct lttng_enabler base; + struct lttng_event_enabler_common parent; uint64_t error_counter_index; - struct cds_list_head node; /* per-app list of event_notifier enablers */ struct cds_list_head capture_bytecode_head; struct lttng_event_notifier_group *group; /* weak ref */ - uint64_t user_token; /* User-provided token */ uint64_t num_captures; }; @@ -103,7 +183,7 @@ enum lttng_ust_bytecode_type { struct lttng_ust_bytecode_node { enum lttng_ust_bytecode_type type; struct cds_list_head node; - struct lttng_enabler *enabler; + struct lttng_event_enabler_common *enabler; struct { uint32_t len; uint32_t reloc_offset; @@ -134,7 +214,7 @@ struct lttng_ust_bytecode_filter_ctx { struct lttng_ust_excluder_node { struct cds_list_head node; - struct lttng_enabler *enabler; + struct lttng_event_enabler_common *enabler; /* * struct lttng_ust_event_exclusion had variable sized array, * must be last field. @@ -175,44 +255,7 @@ struct lttng_ust_field_list { */ struct lttng_enabler_ref { struct cds_list_head node; /* enabler ref list */ - struct lttng_enabler *ref; /* backward ref */ -}; - -#define LTTNG_COUNTER_DIMENSION_MAX 8 -struct lttng_counter_dimension { - uint64_t size; - uint64_t underflow_index; - uint64_t overflow_index; - uint8_t has_underflow; - uint8_t has_overflow; -}; - -struct lttng_counter_ops { - struct lib_counter *(*counter_create)(size_t nr_dimensions, - const struct lttng_counter_dimension *dimensions, - int64_t global_sum_step, - int global_counter_fd, - int nr_counter_cpu_fds, - const int *counter_cpu_fds, - bool is_daemon); - void (*counter_destroy)(struct lib_counter *counter); - int (*counter_add)(struct lib_counter *counter, - const size_t *dimension_indexes, int64_t v); - int (*counter_read)(struct lib_counter *counter, - const size_t *dimension_indexes, int cpu, - int64_t *value, bool *overflow, bool *underflow); - int (*counter_aggregate)(struct lib_counter *counter, - const size_t *dimension_indexes, int64_t *value, - bool *overflow, bool *underflow); - int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes); -}; - -struct lttng_counter { - int objd; - struct lttng_event_notifier_group *event_notifier_group; /* owner */ - struct lttng_counter_transport *transport; - struct lib_counter *counter; - struct lttng_counter_ops *ops; + struct lttng_event_enabler_common *ref; /* backward ref */ }; #define LTTNG_UST_EVENT_HT_BITS 12 @@ -222,12 +265,6 @@ struct lttng_ust_event_ht { struct cds_hlist_head table[LTTNG_UST_EVENT_HT_SIZE]; }; -#define LTTNG_UST_EVENT_NOTIFIER_HT_BITS 12 -#define LTTNG_UST_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_UST_EVENT_NOTIFIER_HT_BITS) -struct lttng_ust_event_notifier_ht { - struct cds_hlist_head table[LTTNG_UST_EVENT_NOTIFIER_HT_SIZE]; -}; - #define LTTNG_UST_ENUM_HT_BITS 12 #define LTTNG_UST_ENUM_HT_SIZE (1U << LTTNG_UST_ENUM_HT_BITS) @@ -240,12 +277,17 @@ struct lttng_event_notifier_group { void *owner; int notification_fd; struct cds_list_head node; /* Event notifier group handle list */ - struct cds_list_head enablers_head; + + /* List of non-synchronized enablers */ + struct cds_list_head unsync_enablers_head; + /* List of synchronized enablers */ + struct cds_list_head sync_enablers_head; + struct cds_list_head event_notifiers_head; /* list of event_notifiers */ - struct lttng_ust_event_notifier_ht event_notifiers_ht; /* hashtable of event_notifiers */ + struct lttng_ust_event_ht event_notifiers_ht; /* hashtable of event notifiers */ struct lttng_ust_ctx *ctx; /* contexts for filters. */ - struct lttng_counter *error_counter; + struct lttng_ust_channel_counter *error_counter; size_t error_counter_len; }; @@ -253,13 +295,13 @@ struct lttng_transport { const char *name; struct cds_list_head node; struct lttng_ust_channel_buffer_ops ops; - const struct lttng_ust_lib_ring_buffer_config *client_config; + const struct lttng_ust_ring_buffer_config *client_config; }; struct lttng_counter_transport { const char *name; struct cds_list_head node; - struct lttng_counter_ops ops; + struct lttng_ust_channel_counter_ops ops; const struct lib_counter_config *client_config; }; @@ -275,16 +317,31 @@ struct lttng_ust_event_common_private { int has_enablers_without_filter_bytecode; /* list of struct lttng_ust_bytecode_runtime, sorted by seqnum */ struct cds_list_head filter_bytecode_runtime_head; + + struct cds_hlist_node name_hlist_node; /* node in events-by-name hash table */ + struct cds_list_head node; /* node in event list */ }; -struct lttng_ust_event_recorder_private { +struct lttng_ust_event_session_common_private { struct lttng_ust_event_common_private parent; + struct lttng_ust_channel_common *chan; + + uint64_t id; /* Event id */ +}; + +struct lttng_ust_event_recorder_private { + struct lttng_ust_event_session_common_private parent; + struct lttng_ust_event_recorder *pub; /* Public event interface */ - struct cds_list_head node; /* Event recorder list */ - struct cds_hlist_node hlist; /* Hash table of event recorders */ - struct lttng_ust_ctx *ctx; - unsigned int id; +}; + +struct lttng_ust_event_counter_private { + struct lttng_ust_event_session_common_private parent; + + struct lttng_ust_event_counter *pub; /* Public event interface */ + enum lttng_event_counter_action action; + char key[LTTNG_KEY_TOKEN_STRING_LEN_MAX]; }; struct lttng_ust_event_notifier_private { @@ -294,8 +351,6 @@ struct lttng_ust_event_notifier_private { struct lttng_event_notifier_group *group; /* weak ref */ size_t num_captures; /* Needed to allocate the msgpack array. */ uint64_t error_counter_index; - struct cds_list_head node; /* Event notifier list */ - struct cds_hlist_node hlist; /* Hash table of event notifiers */ struct cds_list_head capture_bytecode_runtime_head; }; @@ -305,6 +360,7 @@ struct lttng_ust_bytecode_runtime { int link_failed; int (*interpreter_func)(struct lttng_ust_bytecode_runtime *bytecode_runtime, const char *interpreter_stack_data, + struct lttng_ust_probe_ctx *probe_ctx, void *ctx); struct cds_list_head node; /* list of bytecode runtime in event */ /* @@ -320,21 +376,24 @@ struct lttng_ust_session_private { int been_active; /* Been active ? */ int objd; /* Object associated */ struct cds_list_head chan_head; /* Channel list head */ + struct cds_list_head counters_head; /* Counter list head */ struct cds_list_head events_head; /* list of events */ struct cds_list_head node; /* Session list */ - /* List of enablers */ - struct cds_list_head enablers_head; - struct lttng_ust_event_ht events_ht; /* ht of events */ - void *owner; /* object owner */ - int tstate:1; /* Transient enable state */ + /* List of non-synchronized enablers */ + struct cds_list_head unsync_enablers_head; + /* List of synchronized enablers */ + struct cds_list_head sync_enablers_head; - int statedump_pending:1; + struct cds_list_head enums_head; + struct lttng_ust_event_ht events_name_ht; /* ht of events, indexed by name */ struct lttng_ust_enum_ht enums_ht; /* ht of enumerations */ - struct cds_list_head enums_head; - struct lttng_ust_ctx *ctx; /* contexts for filters. */ + void *owner; /* object owner */ + unsigned int tstate:1; /* Transient enable state */ + unsigned int statedump_pending:1; + struct lttng_ust_ctx *ctx; /* contexts for filters. */ unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ bool uuid_set; /* Is uuid set ? */ }; @@ -377,7 +436,8 @@ struct lttng_ust_channel_common_private { struct lttng_ust_channel_common *pub; /* Public channel interface */ int objd; /* Object associated with channel. */ - int tstate:1; /* Transient enable state */ + unsigned int tstate:1; /* Transient enable state */ + bool coalesce_hits; }; struct lttng_ust_channel_buffer_private { @@ -389,10 +449,50 @@ struct lttng_ust_channel_buffer_private { unsigned int id; /* Channel ID */ enum lttng_ust_abi_chan_type type; struct lttng_ust_ctx *ctx; - struct lttng_ust_lib_ring_buffer_channel *rb_chan; /* Ring buffer channel */ + struct lttng_ust_ring_buffer_channel *rb_chan; /* Ring buffer channel */ unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ }; +struct lttng_ust_channel_counter_ops_private { + struct lttng_ust_channel_counter_ops *pub; /* Public channel counter ops interface */ + + struct lttng_ust_channel_counter *(*counter_create)(size_t nr_dimensions, + const struct lttng_counter_dimension *dimensions, + int64_t global_sum_step, + int global_counter_fd, + int nr_counter_cpu_fds, + const int *counter_cpu_fds, + bool is_daemon); + void (*counter_destroy)(struct lttng_ust_channel_counter *counter); + int (*counter_add)(struct lttng_ust_channel_counter *counter, + const size_t *dimension_indexes, int64_t v); + int (*counter_read)(struct lttng_ust_channel_counter *counter, + const size_t *dimension_indexes, int cpu, + int64_t *value, bool *overflow, bool *underflow); + int (*counter_aggregate)(struct lttng_ust_channel_counter *counter, + const size_t *dimension_indexes, int64_t *value, + bool *overflow, bool *underflow); + int (*counter_clear)(struct lttng_ust_channel_counter *counter, + const size_t *dimension_indexes); +}; + +struct lttng_ust_channel_counter_private { + struct lttng_ust_channel_common_private parent; + + struct lttng_ust_channel_counter *pub; /* Public channel counter interface */ + struct lib_counter *counter; + struct lttng_ust_channel_counter_ops *ops; + + /* Event notifier group owner. */ + struct lttng_event_notifier_group *event_notifier_group; + + /* Session owner. */ + struct lttng_session *session; + struct cds_list_head node; /* Counter list (in session) */ + size_t free_index; /* Next index to allocate */ + enum lttng_key_type dimension_key_types[LTTNG_COUNTER_DIMENSION_MAX]; +}; + /* * IMPORTANT: this structure is part of the ABI between the consumer * daemon and the UST library within traced applications. Changing it @@ -407,10 +507,13 @@ struct lttng_ust_abi_channel_config { void *unused3; void *unused4; int unused5; + unsigned int _deprecated1; + unsigned int _deprecated2; struct cds_list_head unused6; void *unused7; int unused8; void *unused9; + unsigned int _deprecated3:1; /* Channel ID */ unsigned int id; @@ -441,10 +544,13 @@ struct lttng_ust_registered_probe { struct lttng_ust_ctx_field { const struct lttng_ust_event_field *event_field; - size_t (*get_size)(void *priv, size_t offset); - void (*record)(void *priv, struct lttng_ust_lib_ring_buffer_ctx *ctx, - struct lttng_ust_channel_buffer *chan); - void (*get_value)(void *priv, struct lttng_ust_ctx_value *value); + size_t (*get_size)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + size_t offset); + void (*record)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ring_buffer_ctx *ctx, + struct lttng_ust_channel_buffer *chan); + void (*get_value)(void *priv, struct lttng_ust_probe_ctx *probe_ctx, + struct lttng_ust_ctx_value *value); void (*destroy)(void *priv); void *priv; }; @@ -506,7 +612,7 @@ const struct lttng_ust_type_struct *lttng_ust_get_type_struct(const struct lttng } #define lttng_ust_static_type_integer(_size, _alignment, _signedness, _byte_order, _base) \ - ((const struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_type_integer, { \ + ((const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_integer, { \ .parent = { \ .type = lttng_ust_type_integer, \ }, \ @@ -514,12 +620,12 @@ const struct lttng_ust_type_struct *lttng_ust_get_type_struct(const struct lttng .size = (_size), \ .alignment = (_alignment), \ .signedness = (_signedness), \ - .reverse_byte_order = (_byte_order) != BYTE_ORDER, \ + .reverse_byte_order = (_byte_order) != LTTNG_UST_BYTE_ORDER, \ .base = (_base), \ })) #define lttng_ust_static_type_array_text(_length) \ - ((const struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_type_array, { \ + ((const struct lttng_ust_type_common *) LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_type_array, { \ .parent = { \ .type = lttng_ust_type_array, \ }, \ @@ -529,11 +635,11 @@ const struct lttng_ust_type_struct *lttng_ust_get_type_struct(const struct lttng .encoding = lttng_ust_string_encoding_UTF8, \ .elem_type = lttng_ust_static_type_integer(sizeof(char) * CHAR_BIT, \ lttng_ust_rb_alignof(char) * CHAR_BIT, lttng_ust_is_signed_type(char), \ - BYTE_ORDER, 10), \ + LTTNG_UST_BYTE_ORDER, 10), \ })) #define lttng_ust_static_event_field(_name, _type, _nowrite, _nofilter) \ - __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ + LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_event_field, { \ .struct_size = sizeof(struct lttng_ust_event_field), \ .name = (_name), \ .type = (_type), \ @@ -542,7 +648,7 @@ const struct lttng_ust_type_struct *lttng_ust_get_type_struct(const struct lttng }) #define lttng_ust_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \ - __LTTNG_COMPOUND_LITERAL(const struct lttng_ust_ctx_field, { \ + LTTNG_UST_COMPOUND_LITERAL(const struct lttng_ust_ctx_field, { \ .event_field = (_event_field), \ .get_size = (_get_size), \ .record = (_record), \ @@ -552,23 +658,55 @@ const struct lttng_ust_type_struct *lttng_ust_get_type_struct(const struct lttng }) static inline -struct lttng_enabler *lttng_event_enabler_as_enabler( - struct lttng_event_enabler *event_enabler) +struct lttng_event_enabler_common *lttng_event_notifier_enabler_as_enabler( + struct lttng_event_notifier_enabler *event_notifier_enabler) { - return &event_enabler->base; + return &event_notifier_enabler->parent; } static inline -struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( - struct lttng_event_notifier_enabler *event_notifier_enabler) +struct lttng_ust_event_ht *lttng_get_event_ht_from_enabler(struct lttng_event_enabler_common *event_enabler) { - return &event_notifier_enabler->base; + switch (event_enabler->enabler_type) { + case LTTNG_EVENT_ENABLER_TYPE_RECORDER: /* Fall-through */ + case LTTNG_EVENT_ENABLER_TYPE_COUNTER: + { + struct lttng_event_enabler_session_common *event_enabler_session = + caa_container_of(event_enabler, struct lttng_event_enabler_session_common, parent); + return &event_enabler_session->chan->session->priv->events_name_ht; + } + case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER: + { + struct lttng_event_notifier_enabler *event_notifier_enabler = + caa_container_of(event_enabler, struct lttng_event_notifier_enabler, parent); + return &event_notifier_enabler->group->event_notifiers_ht; + } + default: + return NULL; + } } - - -/* This is ABI between liblttng-ust and liblttng-ust-ctl */ -struct lttng_transport *lttng_ust_transport_find(const char *name); +static inline +struct cds_list_head *lttng_get_event_list_head_from_enabler(struct lttng_event_enabler_common *event_enabler) +{ + switch (event_enabler->enabler_type) { + case LTTNG_EVENT_ENABLER_TYPE_RECORDER: /* Fall-through */ + case LTTNG_EVENT_ENABLER_TYPE_COUNTER: + { + struct lttng_event_enabler_session_common *event_enabler_session = + caa_container_of(event_enabler, struct lttng_event_enabler_session_common, parent); + return &event_enabler_session->chan->session->priv->events_head; + } + case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER: + { + struct lttng_event_notifier_enabler *event_notifier_enabler = + caa_container_of(event_enabler, struct lttng_event_notifier_enabler, parent); + return &event_notifier_enabler->group->event_notifiers_head; + } + default: + return NULL; + } +} /* This is ABI between liblttng-ust and liblttng-ust-dl */ void lttng_ust_dl_update(void *ip);