-static void ltt_relay_print_subbuffer_errors(
- struct ust_channel *channel,
- long cons_off, int cpu)
-{
- struct ust_buffer *ltt_buf = channel->buf[cpu];
- long cons_idx, commit_count, commit_count_sb, write_offset;
-
- cons_idx = SUBBUF_INDEX(cons_off, channel);
- commit_count = uatomic_read(<t_buf->commit_count[cons_idx].cc);
- commit_count_sb = uatomic_read(<t_buf->commit_count[cons_idx].cc_sb);
-
- /*
- * 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(<t_buf->offset);
- WARN( "LTT : unread channel %s offset is %ld "
- "and cons_off : %ld (cpu %d)\n",
- channel->channel_name, write_offset, cons_off, cpu);
- /* Check each sub-buffer for non filled commit count */
- if (((commit_count - channel->subbuf_size) & channel->commit_count_mask)
- - (BUFFER_TRUNC(cons_off, channel) >> channel->n_subbufs_order) != 0) {
- ERR("LTT : %s : subbuffer %lu has non filled "
- "commit count [cc, cc_sb] [%lu,%lu].\n",
- channel->channel_name, cons_idx, commit_count, commit_count_sb);
- }
- ERR("LTT : %s : commit count : %lu, subbuf size %zd\n",
- channel->channel_name, commit_count,
- channel->subbuf_size);
-}
-
-static void ltt_relay_print_errors(struct ust_trace *trace,
- struct ust_channel *channel, int cpu)
-{
- struct ust_buffer *ltt_buf = channel->buf[cpu];
- long cons_off;
-
- /*
- * Can be called in the error path of allocation when
- * trans_channel_data is not yet set.
- */
- if (!channel)
- return;
-
-//ust// for (cons_off = 0; cons_off < rchan->alloc_size;
-//ust// cons_off = SUBBUF_ALIGN(cons_off, rchan))
-//ust// ust_buffers_print_written(ltt_chan, cons_off, cpu);
- for (cons_off = uatomic_read(<t_buf->consumed);
- (SUBBUF_TRUNC(uatomic_read(<t_buf->offset),
- channel)
- - cons_off) > 0;
- cons_off = SUBBUF_ALIGN(cons_off, channel))
- ltt_relay_print_subbuffer_errors(channel, cons_off, cpu);
-}
-
-static void ltt_relay_print_buffer_errors(struct ust_channel *channel, int cpu)
-{
- struct ust_trace *trace = channel->trace;
- struct ust_buffer *ltt_buf = channel->buf[cpu];
-
- if (uatomic_read(<t_buf->events_lost))
- ERR("channel %s: %ld events lost (cpu %d)",
- channel->channel_name,
- uatomic_read(<t_buf->events_lost), cpu);
- if (uatomic_read(<t_buf->corrupted_subbuffers))
- ERR("channel %s : %ld corrupted subbuffers (cpu %d)",
- channel->channel_name,
- uatomic_read(<t_buf->corrupted_subbuffers), cpu);
-
- ltt_relay_print_errors(trace, channel, cpu);
-}
-
-static void ltt_relay_release_channel(struct kref *kref)
-{
- struct ust_channel *ltt_chan = _ust_container_of(kref,
- struct ust_channel, kref);
- free(ltt_chan->buf);
-}
-
-/*
- * Create ltt buffer.
- */
-//ust// static int ltt_relay_create_buffer(struct ust_trace *trace,
-//ust// struct ltt_channel_struct *ltt_chan, struct rchan_buf *buf,
-//ust// unsigned int cpu, unsigned int n_subbufs)
-//ust// {
-//ust// struct ltt_channel_buf_struct *ltt_buf =
-//ust// percpu_ptr(ltt_chan->buf, cpu);
-//ust// unsigned int j;
-//ust//
-//ust// ltt_buf->commit_count =
-//ust// kzalloc_node(sizeof(ltt_buf->commit_count) * n_subbufs,
-//ust// GFP_KERNEL, cpu_to_node(cpu));
-//ust// if (!ltt_buf->commit_count)
-//ust// return -ENOMEM;
-//ust// kref_get(&trace->kref);
-//ust// kref_get(&trace->ltt_transport_kref);
-//ust// kref_get(<t_chan->kref);
-//ust// uatomic_set(<t_buf->offset, ltt_subbuffer_header_size());
-//ust// uatomic_set(<t_buf->consumed, 0);
-//ust// uatomic_set(<t_buf->active_readers, 0);
-//ust// for (j = 0; j < n_subbufs; j++)
-//ust// uatomic_set(<t_buf->commit_count[j], 0);
-//ust// init_waitqueue_head(<t_buf->write_wait);
-//ust// uatomic_set(<t_buf->wakeup_readers, 0);
-//ust// spin_lock_init(<t_buf->full_lock);
-//ust//
-//ust// ltt_buffer_begin_callback(buf, trace->start_tsc, 0);
-//ust// /* atomic_add made on local variable on data that belongs to
-//ust// * various CPUs : ok because tracing not started (for this cpu). */
-//ust// uatomic_add(<t_buf->commit_count[0], ltt_subbuffer_header_size());
-//ust//
-//ust// uatomic_set(<t_buf->events_lost, 0);
-//ust// uatomic_set(<t_buf->corrupted_subbuffers, 0);
-//ust//
-//ust// return 0;
-//ust// }
-
-static int ust_buffers_init_buffer(struct ust_trace *trace,
- struct ust_channel *ltt_chan, struct ust_buffer *buf,
- unsigned int n_subbufs)
-{
- unsigned int j;
- int fds[2];
- int result;
-
- buf->commit_count =
- zmalloc(sizeof(*buf->commit_count) * n_subbufs);
- if (!buf->commit_count)
- return -ENOMEM;
- kref_get(&trace->kref);
- kref_get(&trace->ltt_transport_kref);
- kref_get(<t_chan->kref);
- uatomic_set(&buf->offset, ltt_subbuffer_header_size());
- uatomic_set(&buf->consumed, 0);
- uatomic_set(&buf->active_readers, 0);
- for (j = 0; j < n_subbufs; j++) {
- uatomic_set(&buf->commit_count[j].cc, 0);
- uatomic_set(&buf->commit_count[j].cc_sb, 0);
- }
-//ust// init_waitqueue_head(&buf->write_wait);
-//ust// uatomic_set(&buf->wakeup_readers, 0);
-//ust// spin_lock_init(&buf->full_lock);
-
- ltt_buffer_begin(buf, trace->start_tsc, 0);
-
- uatomic_add(&buf->commit_count[0].cc, ltt_subbuffer_header_size());
-
- uatomic_set(&buf->events_lost, 0);
- uatomic_set(&buf->corrupted_subbuffers, 0);
-
- result = pipe(fds);
- if(result == -1) {
- PERROR("pipe");
- return -1;
- }
- buf->data_ready_fd_read = fds[0];
- buf->data_ready_fd_write = fds[1];
-
-//ust// buf->commit_seq = malloc(sizeof(buf->commit_seq) * n_subbufs);
-//ust// if(!ltt_buf->commit_seq) {
-//ust// return -1;
-//ust// }
- memset(buf->commit_seq, 0, sizeof(buf->commit_seq[0]) * n_subbufs);
-
- /* FIXME: decrementally destroy on error */
-
- return 0;
-}
-
-/* FIXME: use this function */
-static void ust_buffers_destroy_buffer(struct ust_channel *ltt_chan, int cpu)
-{
- struct ust_trace *trace = ltt_chan->trace;
- struct ust_buffer *ltt_buf = ltt_chan->buf[cpu];
-
- kref_put(<t_chan->trace->ltt_transport_kref,
- ltt_release_transport);
- ltt_relay_print_buffer_errors(ltt_chan, cpu);
-//ust// free(ltt_buf->commit_seq);
- free(ltt_buf->commit_count);
- ltt_buf->commit_count = NULL;
- kref_put(<t_chan->kref, ltt_relay_release_channel);
- kref_put(&trace->kref, ltt_release_trace);
-//ust// wake_up_interruptible(&trace->kref_wq);
-}
-
-static int ust_buffers_alloc_channel_buf_structs(struct ust_channel *chan)