Rename struct lib_ring_buffer* to struct lttng_kernel_ring_buffer*
[lttng-modules.git] / include / lttng / events-internal.h
index 177198870da16fd2a45c948861e57ddf7abcf67e..3923232bf76623a8481d8894583d9b34ff503ac0 100644 (file)
 
 #include <lttng/events.h>
 
+struct lttng_syscall_filter;
+struct lttng_metadata_cache;
+struct perf_event;
+struct perf_event_attr;
+struct lttng_kernel_ring_buffer_config;
+
 enum lttng_enabler_format_type {
        LTTNG_ENABLER_FORMAT_STAR_GLOB,
        LTTNG_ENABLER_FORMAT_NAME,
 };
 
+enum channel_type {
+       PER_CPU_CHANNEL,
+       METADATA_CHANNEL,
+};
+
 /*
  * Objects in a linked-list of enablers, owned by an event.
  */
@@ -106,6 +117,44 @@ struct lttng_kernel_event_notifier_private {
 
 };
 
+struct lttng_kernel_channel_common_private {
+       struct lttng_kernel_channel_common *pub;
+
+       struct file *file;                      /* File associated to channel */
+       unsigned int sys_enter_registered:1,
+               sys_exit_registered:1,
+               tstate:1;                       /* Transient enable state */
+
+       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 */
+       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 syscall_all_entry;
+       int syscall_all_exit;
+};
+
+struct lttng_kernel_channel_buffer_private {
+       struct lttng_kernel_channel_common_private parent;
+
+       struct lttng_kernel_channel_buffer *pub;
+
+       unsigned int id;                        /* Channel ID */
+       unsigned int free_event_id;             /* Next event ID to allocate */
+       int header_type;                        /* 0: unset, 1: compact, 2: large */
+
+       enum channel_type channel_type;
+       struct lttng_kernel_ctx *ctx;
+       struct lttng_kernel_ring_buffer_channel *rb_chan;               /* Ring buffer channel */
+       unsigned int metadata_dumped:1;
+       struct list_head node;                  /* Channel list in session */
+       struct lttng_transport *transport;
+};
+
 enum lttng_kernel_bytecode_interpreter_ret {
        LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR = -1,
        LTTNG_KERNEL_BYTECODE_INTERPRETER_OK = 0,
@@ -171,7 +220,7 @@ struct lttng_enabler {
 struct lttng_event_enabler {
        struct lttng_enabler base;
        struct list_head node;  /* per-session list of enablers */
-       struct lttng_channel *chan;
+       struct lttng_kernel_channel_buffer *chan;
 };
 
 struct lttng_event_notifier_enabler {
@@ -217,7 +266,7 @@ struct lttng_kernel_ctx_field {
                        size_t offset);
        void (*record)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
                        struct lttng_kernel_ring_buffer_ctx *ctx,
-                       struct lttng_channel *chan);
+                       struct lttng_kernel_channel_buffer *chan);
        void (*get_value)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
                        struct lttng_ctx_value *value);
        void (*destroy)(void *priv);
@@ -259,52 +308,52 @@ struct lttng_metadata_stream {
 struct lttng_kernel_channel_buffer_ops_private {
        struct lttng_kernel_channel_buffer_ops *pub;    /* Public channel buffer ops interface */
 
-       struct channel *(*channel_create)(const char *name,
+       struct lttng_kernel_ring_buffer_channel *(*channel_create)(const char *name,
                                void *priv,
                                void *buf_addr,
                                size_t subbuf_size, size_t num_subbuf,
                                unsigned int switch_timer_interval,
                                unsigned int read_timer_interval);
-       void (*channel_destroy)(struct channel *chan);
-       struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
-       int (*buffer_has_read_closed_stream)(struct channel *chan);
-       void (*buffer_read_close)(struct lib_ring_buffer *buf);
+       void (*channel_destroy)(struct lttng_kernel_ring_buffer_channel *chan);
+       struct lttng_kernel_ring_buffer *(*buffer_read_open)(struct lttng_kernel_ring_buffer_channel *chan);
+       int (*buffer_has_read_closed_stream)(struct lttng_kernel_ring_buffer_channel *chan);
+       void (*buffer_read_close)(struct lttng_kernel_ring_buffer *buf);
        /*
         * packet_avail_size returns the available size in the current
         * packet. Note that the size returned is only a hint, since it
         * may change due to concurrent writes.
         */
-       size_t (*packet_avail_size)(struct channel *chan);
-       wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
-       wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
-       int (*is_finalized)(struct channel *chan);
-       int (*is_disabled)(struct channel *chan);
-       int (*timestamp_begin) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       size_t (*packet_avail_size)(struct lttng_kernel_ring_buffer_channel *chan);
+       wait_queue_head_t *(*get_writer_buf_wait_queue)(struct lttng_kernel_ring_buffer_channel *chan, int cpu);
+       wait_queue_head_t *(*get_hp_wait_queue)(struct lttng_kernel_ring_buffer_channel *chan);
+       int (*is_finalized)(struct lttng_kernel_ring_buffer_channel *chan);
+       int (*is_disabled)(struct lttng_kernel_ring_buffer_channel *chan);
+       int (*timestamp_begin) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *timestamp_begin);
-       int (*timestamp_end) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       int (*timestamp_end) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *timestamp_end);
-       int (*events_discarded) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       int (*events_discarded) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *events_discarded);
-       int (*content_size) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       int (*content_size) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *content_size);
-       int (*packet_size) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       int (*packet_size) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *packet_size);
-       int (*stream_id) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       int (*stream_id) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *stream_id);
-       int (*current_timestamp) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       int (*current_timestamp) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *ts);
-       int (*sequence_number) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       int (*sequence_number) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *seq);
-       int (*instance_id) (const struct lib_ring_buffer_config *config,
-                       struct lib_ring_buffer *bufb,
+       int (*instance_id) (const struct lttng_kernel_ring_buffer_config *config,
+                       struct lttng_kernel_ring_buffer *bufb,
                        uint64_t *id);
 };
 
@@ -338,6 +387,13 @@ struct lttng_counter {
        struct lttng_counter_ops *ops;
 };
 
+#define LTTNG_EVENT_NOTIFIER_HT_BITS           12
+#define LTTNG_EVENT_NOTIFIER_HT_SIZE           (1U << LTTNG_EVENT_NOTIFIER_HT_BITS)
+
+struct lttng_event_notifier_ht {
+       struct hlist_head table[LTTNG_EVENT_NOTIFIER_HT_SIZE];
+};
+
 struct lttng_event_notifier_group {
        struct file *file;              /* File associated to event notifier group */
        struct file *notif_file;        /* File used to expose notifications to userspace. */
@@ -347,8 +403,8 @@ struct lttng_event_notifier_group {
        struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */
        struct lttng_kernel_channel_buffer_ops *ops;
        struct lttng_transport *transport;
-       struct channel *chan;           /* Ring buffer channel for event notifier group. */
-       struct lib_ring_buffer *buf;    /* Ring buffer for event notifier group. */
+       struct lttng_kernel_ring_buffer_channel *chan;          /* Ring buffer channel for event notifier group. */
+       struct lttng_kernel_ring_buffer *buf;   /* Ring buffer for event notifier group. */
        wait_queue_head_t read_wait;
        struct irq_work wakeup_pending; /* Pending wakeup irq work. */
        struct lttng_kernel_event_notifier *sc_unknown; /* for unknown syscalls */
@@ -389,6 +445,13 @@ struct lttng_counter_transport {
        struct lttng_counter_ops ops;
 };
 
+#define LTTNG_EVENT_HT_BITS            12
+#define LTTNG_EVENT_HT_SIZE            (1U << LTTNG_EVENT_HT_BITS)
+
+struct lttng_event_ht {
+       struct hlist_head table[LTTNG_EVENT_HT_SIZE];
+};
+
 struct lttng_kernel_session_private {
        struct lttng_kernel_session *pub;       /* Public session interface */
 
@@ -415,6 +478,24 @@ struct lttng_id_hash_node {
        int id;
 };
 
+enum tracker_type {
+       TRACKER_PID,
+       TRACKER_VPID,
+       TRACKER_UID,
+       TRACKER_VUID,
+       TRACKER_GID,
+       TRACKER_VGID,
+
+       TRACKER_UNKNOWN,
+};
+
+struct lttng_kernel_id_tracker_private {
+       struct lttng_kernel_id_tracker *pub;    /* Public interface */
+
+       struct lttng_kernel_session *session;
+       enum tracker_type tracker_type;
+};
+
 extern struct lttng_kernel_ctx *lttng_static_ctx;
 
 static inline
@@ -691,7 +772,7 @@ int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
 struct lttng_event_enabler *lttng_event_enabler_create(
                enum lttng_enabler_format_type format_type,
                struct lttng_kernel_abi_event *event_param,
-               struct lttng_channel *chan);
+               struct lttng_kernel_channel_buffer *chan);
 
 int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler);
 int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler);
@@ -724,16 +805,16 @@ void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_des
 
 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
 int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler);
-int lttng_syscalls_unregister_channel(struct lttng_channel *chan);
-int lttng_syscalls_destroy_event(struct lttng_channel *chan);
+int lttng_syscalls_unregister_channel(struct lttng_kernel_channel_buffer *chan);
+int lttng_syscalls_destroy_event(struct lttng_kernel_channel_buffer *chan);
 int lttng_syscall_filter_enable_event(
-               struct lttng_channel *chan,
+               struct lttng_kernel_channel_buffer *chan,
                struct lttng_kernel_event_recorder *event);
 int lttng_syscall_filter_disable_event(
-               struct lttng_channel *chan,
+               struct lttng_kernel_channel_buffer *chan,
                struct lttng_kernel_event_recorder *event);
 
-long lttng_channel_syscall_mask(struct lttng_channel *channel,
+long lttng_channel_syscall_mask(struct lttng_kernel_channel_buffer *channel,
                struct lttng_kernel_abi_syscall_mask __user *usyscall_mask);
 
 int lttng_syscalls_register_event_notifier(
@@ -750,29 +831,29 @@ static inline int lttng_syscalls_register_event(
        return -ENOSYS;
 }
 
-static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan)
+static inline int lttng_syscalls_unregister_channel(struct lttng_kernel_channel_buffer *chan)
 {
        return 0;
 }
 
-static inline int lttng_syscalls_destroy(struct lttng_channel *chan)
+static inline int lttng_syscalls_destroy(struct lttng_kernel_channel_buffer *chan)
 {
        return 0;
 }
 
-static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan,
+static inline int lttng_syscall_filter_enable_event(struct lttng_kernel_channel_buffer *chan,
                struct lttng_kernel_event_recorder *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_kernel_channel_buffer *chan,
                struct lttng_kernel_event_recorder *event);
 {
        return -ENOSYS;
 }
 
-static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
+static inline long lttng_channel_syscall_mask(struct lttng_kernel_channel_buffer *channel,
                struct lttng_kernel_syscall_mask __user *usyscall_mask)
 {
        return -ENOSYS;
@@ -995,29 +1076,29 @@ int lttng_event_notifier_group_create_error_counter(
 void lttng_event_notifier_group_destroy(
                struct lttng_event_notifier_group *event_notifier_group);
 
-struct lttng_channel *lttng_channel_create(struct lttng_kernel_session *session,
+struct lttng_kernel_channel_buffer *lttng_channel_create(struct lttng_kernel_session *session,
                                       const char *transport_name,
                                       void *buf_addr,
                                       size_t subbuf_size, size_t num_subbuf,
                                       unsigned int switch_timer_interval,
                                       unsigned int read_timer_interval,
                                       enum channel_type channel_type);
-struct lttng_channel *lttng_global_channel_create(struct lttng_kernel_session *session,
+struct lttng_kernel_channel_buffer *lttng_global_channel_create(struct lttng_kernel_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_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_channel *chan,
+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_channel *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_event_compat_old_create(struct lttng_channel *chan,
+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);
 
@@ -1036,8 +1117,8 @@ struct lttng_kernel_event_notifier *_lttng_event_notifier_create(
                                struct lttng_kernel_abi_event_notifier *event_notifier_param,
                                enum lttng_kernel_abi_instrumentation itype);
 
-int lttng_channel_enable(struct lttng_channel *channel);
-int lttng_channel_disable(struct lttng_channel *channel);
+int lttng_channel_enable(struct lttng_kernel_channel_buffer *channel);
+int lttng_channel_disable(struct lttng_kernel_channel_buffer *channel);
 int lttng_event_enable(struct lttng_kernel_event_common *event);
 int lttng_event_disable(struct lttng_kernel_event_common *event);
 
@@ -1059,13 +1140,17 @@ int lttng_probes_init(void);
 void lttng_probes_exit(void);
 
 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
-               struct channel *chan, bool *coherent);
+               struct lttng_kernel_ring_buffer_channel *chan, bool *coherent);
 
 int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node);
-int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf);
-void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu);
-int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id);
-int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id);
+int lttng_id_tracker_empty_set(struct lttng_kernel_id_tracker *lf);
+int lttng_id_tracker_init(struct lttng_kernel_id_tracker *lf,
+               struct lttng_kernel_session *session,
+               enum tracker_type type);
+void lttng_id_tracker_fini(struct lttng_kernel_id_tracker *lf);
+void lttng_id_tracker_destroy(struct lttng_kernel_id_tracker *lf, bool rcu);
+int lttng_id_tracker_add(struct lttng_kernel_id_tracker *lf, int id);
+int lttng_id_tracker_del(struct lttng_kernel_id_tracker *lf, int id);
 
 int lttng_session_track_id(struct lttng_kernel_session *session,
                enum tracker_type tracker_type, int id);
This page took 0.028958 seconds and 4 git commands to generate.