Move alignment into event write callback
[lttng-modules.git] / src / lttng-context-callstack-stackwalk-impl.h
index d3a57d86c110e7a67b37958208320f31458e3d7c..e73d1156ae7c0731e7918c194982e2446688f278 100644 (file)
@@ -195,14 +195,13 @@ size_t lttng_callstack_sequence_get_size(void *priv, struct lttng_kernel_probe_c
 static
 void lttng_callstack_length_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)
 {
        int cpu = ctx->priv.reserve_cpu;
        struct field_data *fdata = (struct field_data *) priv;
        struct lttng_stack_trace *trace = stack_trace_context(fdata, cpu);
        unsigned int nr_seq_entries;
 
-       lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned int));
        if (unlikely(!trace)) {
                nr_seq_entries = 0;
        } else {
@@ -210,32 +209,33 @@ void lttng_callstack_length_record(void *priv, struct lttng_kernel_probe_ctx *pr
                if (trace->nr_entries == MAX_ENTRIES)
                        nr_seq_entries++;
        }
-       chan->ops->event_write(ctx, &nr_seq_entries, sizeof(unsigned int));
+       chan->ops->event_write(ctx, &nr_seq_entries, sizeof(unsigned int), lttng_alignof(unsigned int));
 }
 
 static
 void lttng_callstack_sequence_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)
 {
        int cpu = ctx->priv.reserve_cpu;
        struct field_data *fdata = (struct field_data *) priv;
        struct lttng_stack_trace *trace = stack_trace_context(fdata, cpu);
        unsigned int nr_seq_entries;
 
-       lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned long));
        if (unlikely(!trace)) {
+               /* We need to align even if there are 0 elements. */
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(unsigned long));
                return;
        }
        nr_seq_entries = trace->nr_entries;
        if (trace->nr_entries == MAX_ENTRIES)
                nr_seq_entries++;
        chan->ops->event_write(ctx, trace->entries,
-                       sizeof(unsigned long) * trace->nr_entries);
+                       sizeof(unsigned long) * trace->nr_entries, lttng_alignof(unsigned long));
        /* Add our own ULONG_MAX delimiter to show incomplete stack. */
        if (trace->nr_entries == MAX_ENTRIES) {
                unsigned long delim = ULONG_MAX;
 
-               chan->ops->event_write(ctx, &delim, sizeof(unsigned long));
+               chan->ops->event_write(ctx, &delim, sizeof(unsigned long), 1);
        }
 }
This page took 0.023985 seconds and 4 git commands to generate.