Move alignment into event write callback
[lttng-modules.git] / include / lttng / tracepoint-event-impl.h
index 35b0059b1739ef11968de2b0adc093d632a9a287..e3a858a397c5d49a8dfde63e97f5d61cf8e9b764 100644 (file)
@@ -201,7 +201,7 @@ void __event_template_proto___##_name(void);
 #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN
 # undef LTTNG_TRACEPOINT_ENUM
 # define LTTNG_TRACEPOINT_ENUM(_name, _values)                         \
-       static const struct lttng_kernel_enum_entry *__enum_values__##_name[] = { \
+       static const struct lttng_kernel_enum_entry * const __enum_values__##_name[] = { \
                _values                                                 \
        };
 #endif
@@ -341,7 +341,7 @@ static __used struct lttng_kernel_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM
 
 #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS
 #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE_NOARGS(_name, _locvar, _code_pre, _fields, _code_post) \
-       static const struct lttng_kernel_event_field *__event_fields___##_name[] = { \
+       static const struct lttng_kernel_event_field * const __event_fields___##_name[] = { \
                _fields                                                      \
        };                                                                   \
        static const struct lttng_kernel_tracepoint_class lttng_kernel__event_class___##_name = { \
@@ -813,8 +813,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)        \
 #define _ctf_integer_ext_fetched(_type, _item, _src, _byte_order, _base, _nowrite) \
        {                                                               \
                _type __tmp = _src;                                     \
-               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\
-               __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
+               __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp), lttng_alignof(__tmp)); \
        }
 
 #undef _ctf_integer_ext_isuser0
@@ -840,21 +839,19 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)              \
 
 #undef _ctf_array_encoded
 #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _byte_order, _base, _user, _nowrite) \
-       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));        \
        if (_user) {                                                    \
-               __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
+               __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \
        } else {                                                        \
-               __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
+               __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \
        }
 
 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
 #undef _ctf_array_bitfield
 #define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
-       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));        \
        if (_user) {                                                    \
-               __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
+               __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \
        } else {                                                        \
-               __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
+               __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length), lttng_alignof(_type)); \
        }
 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
 /*
@@ -890,7 +887,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)        \
                        default:                                        \
                                BUG_ON(1);                              \
                        }                                               \
-                       __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
+                       __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type), 1); \
                }                                                       \
        }
 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
@@ -900,16 +897,14 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)              \
                        _src_length, _encoding, _byte_order, _base, _user, _nowrite) \
        {                                                               \
                _length_type __tmpl = this_cpu_ptr(&lttng_dynamic_len_stack)->stack[__dynamic_len_idx]; \
-               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
-               __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
+               __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type));\
        }                                                               \
-       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));        \
        if (_user) {                                                    \
                __chan->ops->event_write_from_user(&__ctx, _src,        \
-                       sizeof(_type) * __get_dynamic_len(dest));       \
+                       sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \
        } else {                                                        \
                __chan->ops->event_write(&__ctx, _src,                  \
-                       sizeof(_type) * __get_dynamic_len(dest));       \
+                       sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \
        }
 
 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
@@ -919,16 +914,14 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)              \
                        _user, _nowrite)                        \
        {                                                               \
                _length_type __tmpl = this_cpu_ptr(&lttng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
-               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
-               __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
+               __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type)); \
        }                                                               \
-       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));        \
        if (_user) {                                                    \
                __chan->ops->event_write_from_user(&__ctx, _src,        \
-                       sizeof(_type) * __get_dynamic_len(dest));       \
+                       sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \
        } else {                                                        \
                __chan->ops->event_write(&__ctx, _src,                  \
-                       sizeof(_type) * __get_dynamic_len(dest));       \
+                       sizeof(_type) * __get_dynamic_len(dest), lttng_alignof(_type)); \
        }
 #else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
 /*
@@ -940,8 +933,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)        \
                        _user, _nowrite)                        \
        {                                                       \
                _length_type __tmpl = this_cpu_ptr(&lttng_dynamic_len_stack)->stack[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
-               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
-               __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
+               __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type), lttng_alignof(_length_type)); \
        }                                                               \
        lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type));        \
        {                                                               \
@@ -972,7 +964,7 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar)        \
                        default:                                        \
                                BUG_ON(1);                              \
                        }                                               \
-                       __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
+                       __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type), 1); \
                }                                                       \
        }
 #endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
@@ -1074,15 +1066,15 @@ static void __event_probe__##_name(_data_proto)                                         \
        {                                                                               \
                struct lttng_kernel_event_recorder *__event_recorder =                  \
                        container_of(__event, struct lttng_kernel_event_recorder, parent); \
-               struct lttng_channel *__chan = __event_recorder->chan;                  \
-               struct lttng_kernel_session *__session = __chan->session;               \
+               struct lttng_kernel_channel_buffer *__chan = __event_recorder->chan;    \
+               struct lttng_kernel_session *__session = __chan->parent.session;        \
                struct lttng_kernel_id_tracker_rcu *__lf;                               \
                                                                                        \
                if (!_TP_SESSION_CHECK(session, __session))                             \
                        return;                                                         \
                if (unlikely(!LTTNG_READ_ONCE(__session->active)))                      \
                        return;                                                         \
-               if (unlikely(!LTTNG_READ_ONCE(__chan->enabled)))                        \
+               if (unlikely(!LTTNG_READ_ONCE(__chan->parent.enabled)))                 \
                        return;                                                         \
                __lf = lttng_rcu_dereference(__session->pid_tracker.p);                 \
                if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid)))      \
@@ -1131,7 +1123,7 @@ static void __event_probe__##_name(_data_proto)                                           \
        {                                                                               \
                struct lttng_kernel_event_recorder *__event_recorder =                  \
                        container_of(__event, struct lttng_kernel_event_recorder, parent); \
-               struct lttng_channel *__chan = __event_recorder->chan;                  \
+               struct lttng_kernel_channel_buffer *__chan = __event_recorder->chan;    \
                struct lttng_kernel_ring_buffer_ctx __ctx;                              \
                ssize_t __event_len;                                                    \
                size_t __event_align;                                                   \
@@ -1139,7 +1131,7 @@ static void __event_probe__##_name(_data_proto)                                           \
                                                                                        \
                __event_len = __event_get_size__##_name(_locvar_args);                  \
                if (unlikely(__event_len < 0)) {                                        \
-                       lib_ring_buffer_lost_event_too_big(__chan->chan);               \
+                       __chan->ops->lost_event_too_big(__chan);                        \
                        goto __post;                                                    \
                }                                                                       \
                __event_align = __event_get_align__##_name(_locvar_args);               \
@@ -1245,7 +1237,7 @@ static const struct lttng_kernel_event_desc __event_desc___##_map = {     \
 #define TP_ID1(_token, _system)        _token##_system
 #define TP_ID(_token, _system) TP_ID1(_token, _system)
 
-static const struct lttng_kernel_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
+static const struct lttng_kernel_event_desc * const TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 };
 
This page took 0.026778 seconds and 4 git commands to generate.