#include <sys/ipc.h>
#include <sys/shm.h>
#include <fcntl.h>
-#include <ust/kernelcompat.h>
#include <stdlib.h>
+
+#include <ust/clock.h>
+
#include "buffers.h"
#include "channels.h"
#include "tracer.h"
kref_init(&chan->kref);
- mutex_lock(&ust_buffers_channels_mutex);
+ pthread_mutex_lock(&ust_buffers_channels_mutex);
for(i=0; i<chan->n_cpus; i++) {
result = ust_buffers_open_buf(chan, i);
if (result == -1)
goto error;
}
list_add(&chan->list, &ust_buffers_channels);
- mutex_unlock(&ust_buffers_channels_mutex);
+ pthread_mutex_unlock(&ust_buffers_channels_mutex);
return 0;
}
kref_put(&chan->kref, ust_buffers_destroy_channel);
- mutex_unlock(&ust_buffers_channels_mutex);
+ pthread_mutex_unlock(&ust_buffers_channels_mutex);
return -1;
}
if(!chan)
return;
- mutex_lock(&ust_buffers_channels_mutex);
+ pthread_mutex_lock(&ust_buffers_channels_mutex);
for(i=0; i<chan->n_cpus; i++) {
/* FIXME: if we make it here, then all buffers were necessarily allocated. Moreover, we don't
* initialize to NULL so we cannot use this check. Should we? */
list_del(&chan->list);
kref_put(&chan->kref, ust_buffers_destroy_channel);
- mutex_unlock(&ust_buffers_channels_mutex);
+ pthread_mutex_unlock(&ust_buffers_channels_mutex);
}
/*
return -1;
}
-/*
- * LTTng channel flush function.
- *
- * Must be called when no tracing is active in the channel, because of
- * accesses across CPUs.
- */
-static notrace void ltt_relay_buffer_flush(struct ust_buffer *buf)
-{
- int result;
-
-//ust// buf->finalized = 1;
- ltt_force_switch(buf, FORCE_FLUSH);
-
- result = write(buf->data_ready_fd_write, "1", 1);
- if(result == -1) {
- PERROR("write (in ltt_relay_buffer_flush)");
- ERR("this should never happen!");
- }
-}
-
static void ltt_relay_async_wakeup_chan(struct ust_channel *ltt_channel)
{
//ust// unsigned int i;
if (channel->buf[cpu]) {
struct ust_buffer *buf = channel->buf[cpu];
- ltt_relay_buffer_flush(buf);
+ ltt_force_switch(buf, FORCE_FLUSH);
//ust// ltt_relay_wake_writers(ltt_buf);
/* closing the pipe tells the consumer the buffer is finished */
* This compiler barrier is upgraded into a smp_wmb() by the IPI
* sent by get_subbuf() when it does its smp_rmb().
*/
- barrier();
+ smp_wmb();
uatomic_add(&buf->commit_count[oldidx].cc, padding_size);
commit_count = uatomic_read(&buf->commit_count[oldidx].cc);
ltt_check_deliver(chan, buf, offsets->old - 1, commit_count, oldidx);
* This compiler barrier is upgraded into a smp_wmb() by the IPI
* sent by get_subbuf() when it does its smp_rmb().
*/
- barrier();
+ smp_wmb();
uatomic_add(&buf->commit_count[beginidx].cc, ltt_subbuffer_header_size());
commit_count = uatomic_read(&buf->commit_count[beginidx].cc);
/* Check if the written buffer has to be delivered */
* This compiler barrier is upgraded into a smp_wmb() by the IPI
* sent by get_subbuf() when it does its smp_rmb().
*/
- barrier();
+ smp_wmb();
uatomic_add(&buf->commit_count[endidx].cc, padding_size);
commit_count = uatomic_read(&buf->commit_count[endidx].cc);
ltt_check_deliver(chan, buf,