Move alignment into event write callback
[lttng-modules.git] / include / lttng / events.h
index b7267cd587a730d4b7e72b717a6eb97544414414..9d07d7ed08f0c96cbe8546859f62aa231278cf92 100644 (file)
@@ -25,7 +25,7 @@
 
 #define lttng_is_signed_type(type)     (((type) -1) < (type) 1)
 
-struct lttng_channel;
+struct lttng_kernel_channel_buffer;
 struct lttng_kernel_session;
 struct lttng_kernel_ring_buffer_ctx;
 
@@ -49,11 +49,6 @@ enum lttng_kernel_string_encoding {
        NR_LTTNG_KERNEL_STRING_ENCODING,
 };
 
-enum channel_type {
-       PER_CPU_CHANNEL,
-       METADATA_CHANNEL,
-};
-
 struct lttng_kernel_enum_value {
        unsigned long long value;
        unsigned int signedness:1;
@@ -114,22 +109,23 @@ struct lttng_kernel_type_sequence {
 struct lttng_kernel_type_struct {
        struct lttng_kernel_type_common parent;
        unsigned int nr_fields;
-       const struct lttng_kernel_event_field **fields; /* Array of pointers to fields. */
+       const struct lttng_kernel_event_field * const *fields;  /* Array of pointers to fields. */
        unsigned int alignment;
 };
 
 struct lttng_kernel_type_variant {
        struct lttng_kernel_type_common parent;
        const char *tag_name;           /* Tag field name. If NULL, use previous field. */
-       const struct lttng_kernel_event_field **choices; /* Array of pointers to fields. */
+       const struct lttng_kernel_event_field * const *choices; /* Array of pointers to fields. */
        unsigned int nr_choices;
        unsigned int alignment;
 };
 
 struct lttng_kernel_enum_desc {
        const char *name;
-       const struct lttng_kernel_enum_entry **entries;
+       const struct lttng_kernel_enum_entry * const *entries;
        unsigned int nr_entries;
+       const struct lttng_kernel_probe_desc *probe_desc;
 };
 
 /* Event field description */
@@ -142,6 +138,10 @@ struct lttng_kernel_event_field {
                        nofilter:1;     /* do not consider for filter */
 };
 
+#ifndef PARAMS
+#define PARAMS(args...)        args
+#endif
+
 #define lttng_kernel_static_type_integer(_size, _alignment, _signedness, _byte_order, _base)           \
        ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_integer, { \
                .parent = {                                                                             \
@@ -207,15 +207,20 @@ struct lttng_kernel_event_field {
                .encoding = lttng_kernel_string_encoding_##_encoding,                                   \
        }))
 
-#define lttng_kernel_static_type_struct(_nr_fields, _fields, _alignment)                               \
-       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_struct, { \
+#define lttng_kernel_static_type_struct_init(_nr_fields, _fields, _alignment)                          \
+       {                                                                                               \
                .parent = {                                                                             \
                        .type = lttng_kernel_type_struct,                                               \
                },                                                                                      \
                .nr_fields = (_nr_fields),                                                              \
                .fields = _fields,                                                                      \
                .alignment = (_alignment),                                                              \
-       }))
+       }
+
+#define lttng_kernel_static_type_struct(_nr_fields, _fields, _alignment)                               \
+       ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_struct, \
+               lttng_kernel_static_type_struct_init(_nr_fields, PARAMS(_fields), _alignment)                   \
+       ))
 
 #define lttng_kernel_static_type_variant(_nr_choices, _choices, _tag_name, _alignment)                 \
        ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_variant, { \
@@ -293,19 +298,24 @@ struct lttng_kernel_probe_ctx {
        uint8_t interruptible;
 };
 
+struct lttng_kernel_tracepoint_class {
+       void (*probe_callback)(void);
+       const struct lttng_kernel_event_field * const *fields;  /* event payload */
+       unsigned int nr_fields;
+       const struct lttng_kernel_probe_desc *probe_desc;
+};
+
 struct lttng_kernel_event_desc {
        const char *event_name;         /* lttng-modules name */
        const char *event_kname;        /* Linux kernel name (tracepoints) */
        const struct lttng_kernel_probe_desc *probe_desc;
-       void (*probe_callback)(void);
-       const struct lttng_kernel_event_field **fields; /* event payload */
-       unsigned int nr_fields;
+       const struct lttng_kernel_tracepoint_class *tp_class;
        struct module *owner;
 };
 
 struct lttng_kernel_probe_desc {
        const char *provider_name;
-       const struct lttng_kernel_event_desc **event_desc;
+       const struct lttng_kernel_event_desc * const *event_desc;
        unsigned int nr_events;
        struct list_head head;                  /* chain registered probes */
        struct list_head lazy_init_head;
@@ -347,7 +357,7 @@ struct lttng_kernel_event_recorder {
        struct lttng_kernel_event_common parent;
        struct lttng_kernel_event_recorder_private *priv;       /* Private event record interface */
 
-       struct lttng_channel *chan;
+       struct lttng_kernel_channel_buffer *chan;
 };
 
 struct lttng_kernel_notification_ctx {
@@ -373,46 +383,41 @@ struct lttng_kernel_channel_buffer_ops {
        int (*event_reserve)(struct lttng_kernel_ring_buffer_ctx *ctx);
        void (*event_commit)(struct lttng_kernel_ring_buffer_ctx *ctx);
        void (*event_write)(struct lttng_kernel_ring_buffer_ctx *ctx, const void *src,
-                           size_t len);
+                           size_t len, size_t alignment);
        void (*event_write_from_user)(struct lttng_kernel_ring_buffer_ctx *ctx,
-                                     const void *src, size_t len);
+                                     const void *src, size_t len, size_t alignment);
        void (*event_memset)(struct lttng_kernel_ring_buffer_ctx *ctx,
                             int c, size_t len);
        void (*event_strcpy)(struct lttng_kernel_ring_buffer_ctx *ctx, const char *src,
                             size_t len);
        void (*event_strcpy_from_user)(struct lttng_kernel_ring_buffer_ctx *ctx,
                                       const char __user *src, size_t len);
+       void (*lost_event_too_big)(struct lttng_kernel_channel_buffer *lttng_channel);
 };
 
-struct lttng_channel {
-       unsigned int id;
-       struct channel *chan;           /* Channel buffers */
+enum lttng_kernel_channel_type {
+       LTTNG_KERNEL_CHANNEL_TYPE_BUFFER = 0,
+};
+
+struct lttng_kernel_channel_common_private;
+
+/* Use container_of() to get child. */
+struct lttng_kernel_channel_common {
+       struct lttng_kernel_channel_common_private *priv;       /* Private channel interface. */
+
+       enum lttng_kernel_channel_type type;
+
        int enabled;
-       struct lttng_kernel_ctx *ctx;
-       /* Event ID management */
        struct lttng_kernel_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_kernel_channel_buffer_private;
+
+struct lttng_kernel_channel_buffer {
+       struct lttng_kernel_channel_common parent;
+       struct lttng_kernel_channel_buffer_private *priv;
+
        struct lttng_kernel_channel_buffer_ops *ops;
-       struct lttng_transport *transport;
-       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 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,
-               sys_exit_registered:1,
-               tstate:1;               /* Transient enable state */
 };
 
 #define LTTNG_DYNAMIC_LEN_STACK_SIZE   128
This page took 0.02562 seconds and 4 git commands to generate.