Add flush buffers command
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 23 Oct 2011 23:28:21 +0000 (19:28 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 23 Oct 2011 23:28:21 +0000 (19:28 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/ust/lttng-events.h
include/ust/lttng-ust-abi.h
include/ust/lttng-ust-ctl.h
libust/ltt-ring-buffer-client.h
libust/ltt-ring-buffer-metadata-client.h
libust/lttng-ust-abi.c
libustctl/ustctl.c

index e09443f10485bcec527263fd31e582ca64b0c81a..950604e4f620a243f0c9b227cb83216ca45e9d42 100644 (file)
@@ -235,6 +235,7 @@ struct ltt_channel_ops {
        //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
        int (*is_finalized)(struct channel *chan);
        int (*is_disabled)(struct channel *chan);
+       int (*flush_buffers)(struct channel *chan, struct shm_handle *handle);
 };
 
 struct ltt_channel {
index 303493eeb4e1404ea4241b7054c9f138813ab475..5eb131f8feae510410881964bab28d85dacf700a 100644 (file)
@@ -111,6 +111,8 @@ struct lttng_ust_context {
 /* Event and Channel FD commands */
 #define LTTNG_UST_CONTEXT                      \
        _UST_CMDW(0x70, struct lttng_ust_context)
+#define LTTNG_UST_FLUSH_BUFFERS                        \
+       _UST_CMD(0x71)
 
 /* Event, Channel and Session commands */
 #define LTTNG_UST_ENABLE                       _UST_CMD(0x80)
index ddadd61e8b846528095a59c4ba52cc9c1dacb7f1..0a0feae99c2906a062c553d8dd61fc0a6a4a3edf 100644 (file)
@@ -67,6 +67,9 @@ int ustctl_tracepoint_list(int sock); /* not implemented yet */
 int ustctl_tracer_version(int sock, struct lttng_ust_tracer_version *v);
 int ustctl_wait_quiescent(int sock);
 
+/* Flush each buffers in this channel */
+int ustctl_flush_buffers(int sock, struct object_data *channel_data);
+
 /* not implemented yet */
 struct lttng_ust_calibrate;
 int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate);
index 270cb1e9f1a77c2f4073e728225ffc35aa5ed696..abe405d0f949068ef7a9d4385d697c9db939d401 100644 (file)
@@ -503,6 +503,25 @@ int ltt_is_disabled(struct channel *chan)
        return lib_ring_buffer_channel_is_disabled(chan);
 }
 
+static
+int ltt_flush_buffers(struct channel *chan, struct shm_handle *handle)
+{
+       struct lib_ring_buffer *buf;
+       int cpu;
+
+       for_each_channel_cpu(cpu, chan) {
+               int shm_fd, wait_fd;
+               uint64_t memory_map_size;
+
+               buf = channel_get_ring_buffer(&client_config, chan,
+                               cpu, handle, &shm_fd, &wait_fd,
+                               &memory_map_size);
+               lib_ring_buffer_switch(&client_config, buf,
+                               SWITCH_ACTIVE, handle);
+       }
+       return 0;
+}
+
 static struct ltt_transport ltt_relay_transport = {
        .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING "-mmap",
        .ops = {
@@ -518,6 +537,7 @@ static struct ltt_transport ltt_relay_transport = {
                //.get_hp_wait_queue = ltt_get_hp_wait_queue,
                .is_finalized = ltt_is_finalized,
                .is_disabled = ltt_is_disabled,
+               .flush_buffers = ltt_flush_buffers,
        },
 };
 
index 302e020ef579604380e3f004d22d40f76227b610..4415ab667657a2153faad17156d4ec6ec962f507 100644 (file)
@@ -269,6 +269,21 @@ int ltt_is_disabled(struct channel *chan)
        return lib_ring_buffer_channel_is_disabled(chan);
 }
 
+static
+int ltt_flush_buffers(struct channel *chan, struct shm_handle *handle)
+{
+       struct lib_ring_buffer *buf;
+       int shm_fd, wait_fd;
+       uint64_t memory_map_size;
+
+       buf = channel_get_ring_buffer(&client_config, chan,
+                       0, handle, &shm_fd, &wait_fd,
+                       &memory_map_size);
+       lib_ring_buffer_switch(&client_config, buf,
+                       SWITCH_ACTIVE, handle);
+       return 0;
+}
+
 static struct ltt_transport ltt_relay_transport = {
        .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING "-mmap",
        .ops = {
@@ -284,6 +299,7 @@ static struct ltt_transport ltt_relay_transport = {
                //.get_hp_wait_queue = ltt_get_hp_wait_queue,
                .is_finalized = ltt_is_finalized,
                .is_disabled = ltt_is_disabled,
+               .flush_buffers = ltt_flush_buffers,
        },
 };
 
index 1d32e777be7c62126f44c7281c0d4539c5835660..6848c938e09673369a1b0a6be46d22f61a0da6eb 100644 (file)
@@ -632,6 +632,8 @@ long lttng_channel_cmd(int objd, unsigned int cmd, unsigned long arg)
                return ltt_channel_enable(channel);
        case LTTNG_UST_DISABLE:
                return ltt_channel_disable(channel);
+       case LTTNG_UST_FLUSH_BUFFERS:
+               return channel->ops->flush_buffers(channel->chan, channel->handle);
        default:
                return -EINVAL;
        }
@@ -653,6 +655,8 @@ long lttng_channel_cmd(int objd, unsigned int cmd, unsigned long arg)
 static
 long lttng_metadata_cmd(int objd, unsigned int cmd, unsigned long arg)
 {
+       struct ltt_channel *channel = objd_private(objd);
+
        switch (cmd) {
        case LTTNG_UST_STREAM:
        {
@@ -662,6 +666,8 @@ long lttng_metadata_cmd(int objd, unsigned int cmd, unsigned long arg)
                /* stream used as output */
                return lttng_abi_open_stream(objd, stream);
        }
+       case LTTNG_UST_FLUSH_BUFFERS:
+               return channel->ops->flush_buffers(channel->chan, channel->handle);
        default:
                return -EINVAL;
        }
@@ -727,13 +733,10 @@ static const struct objd_ops lttng_metadata_ops = {
  *
  *     This object descriptor implements lttng commands:
  *             (None for now. Access is done directly though shm.)
- *             TODO: Add buffer flush.
  */
 static
 long lttng_rb_cmd(int objd, unsigned int cmd, unsigned long arg)
 {
-       //struct stream_priv_data *priv = objd_private(objd);
-
        switch (cmd) {
        default:
                return -EINVAL;
index cec7e24cab8a0b7eef95d995530843330138457c..51826c13fb0f2e31acd334dbb972499081a187b1 100644 (file)
@@ -401,6 +401,17 @@ int ustctl_wait_quiescent(int sock)
        return 0;
 }
 
+int ustctl_flush_buffers(int sock, struct object_data *channel_data)
+{
+       struct ustcomm_ust_msg lum;
+       struct ustcomm_ust_reply lur;
+
+       memset(&lum, 0, sizeof(lum));
+       lum.handle = channel_data->handle;
+       lum.cmd = LTTNG_UST_FLUSH_BUFFERS;
+       return ustcomm_send_app_cmd(sock, &lum, &lur);
+}
+
 int ustctl_calibrate(int sock, struct lttng_ust_calibrate *calibrate)
 {
        return -ENOSYS;
This page took 0.029069 seconds and 4 git commands to generate.