- size += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
- size += sizeof(unsigned int);
- size += lib_ring_buffer_align(offset, lttng_alignof(unsigned long));
- size += sizeof(unsigned long) * trace->nr_entries;
- return size;
+
+ if (fdata->mode == CALLSTACK_USER)
+ per_cpu(callstack_user_nesting, ctx->cpu)--;
+
+ /*
+ * Remove final ULONG_MAX delimiter. If we cannot find it, add
+ * our own marker to show that the stack is incomplete. This is
+ * more compact for a trace.
+ */
+ if (trace->nr_entries > 0
+ && trace->entries[trace->nr_entries - 1] == ULONG_MAX) {
+ trace->nr_entries--;
+ }
+ offset += lib_ring_buffer_align(offset, lttng_alignof(unsigned int));
+ offset += sizeof(unsigned int);
+ offset += lib_ring_buffer_align(offset, lttng_alignof(unsigned long));
+ offset += sizeof(unsigned long) * trace->nr_entries;
+ /* Add our own ULONG_MAX delimiter to show incomplete stack. */
+ if (trace->nr_entries == trace->max_entries)
+ offset += sizeof(unsigned long);
+ return offset - orig_offset;