+
+static void ltt_relay_print_subbuffer_errors(
+ struct buffer_info *buf,
+ long cons_off, int cpu)
+{
+ struct ust_buffer *ust_buf = buf->bufstruct_mem;
+ long cons_idx, commit_count, commit_count_mask, write_offset;
+
+ cons_idx = SUBBUF_INDEX(cons_off, buf);
+ commit_count = uatomic_read(&ust_buf->commit_seq[cons_idx]);
+ commit_count_mask = (~0UL >> get_count_order(buf->n_subbufs));
+
+ /*
+ * No need to order commit_count and write_offset reads because we
+ * execute after trace is stopped when there are no readers left.
+ */
+ write_offset = uatomic_read(&ust_buf->offset);
+ WARN( "LTT : unread channel %s offset is %ld "
+ "and cons_off : %ld (cpu %d)\n",
+ buf->channel, write_offset, cons_off, cpu);
+ /* Check each sub-buffer for non filled commit count */
+ if (((commit_count - buf->subbuf_size) & commit_count_mask)
+ - (BUFFER_TRUNC(cons_off, buf) >> get_count_order(buf->n_subbufs)) != 0) {
+ ERR("LTT : %s : subbuffer %lu has non filled "
+ "commit count [seq] [%lu].\n",
+ buf->channel, cons_idx, commit_count);
+ }
+ ERR("LTT : %s : commit count : %lu, subbuf size %d\n",
+ buf->channel, commit_count,
+ buf->subbuf_size);
+}
+
+static void ltt_relay_print_errors(struct buffer_info *buf, int cpu)
+{
+ struct ust_buffer *ust_buf = buf->bufstruct_mem;
+ long cons_off;
+
+ for (cons_off = uatomic_read(&ust_buf->consumed);
+ (SUBBUF_TRUNC(uatomic_read(&ust_buf->offset), buf)
+ - cons_off) > 0;
+ cons_off = SUBBUF_ALIGN(cons_off, buf))
+ ltt_relay_print_subbuffer_errors(buf, cons_off, cpu);
+}
+
+static void ltt_relay_print_buffer_errors(struct buffer_info *buf, int cpu)
+{
+ struct ust_buffer *ust_buf = buf->bufstruct_mem;
+
+ if (uatomic_read(&ust_buf->events_lost))
+ ERR("channel %s: %ld events lost (cpu %d)",
+ buf->channel,
+ uatomic_read(&ust_buf->events_lost), cpu);
+ if (uatomic_read(&ust_buf->corrupted_subbuffers))
+ ERR("channel %s : %ld corrupted subbuffers (cpu %d)",
+ buf->channel,
+ uatomic_read(&ust_buf->corrupted_subbuffers), cpu);
+
+ ltt_relay_print_errors(buf, cpu);
+}
+