From: Mathieu Desnoyers Date: Sun, 23 Oct 2011 23:28:21 +0000 (-0400) Subject: Add flush buffers command X-Git-Tag: v1.9.1~159 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=43861eabbb8d36a63e9b0d0cee5ed1193436d600;p=lttng-ust.git Add flush buffers command Signed-off-by: Mathieu Desnoyers --- diff --git a/include/ust/lttng-events.h b/include/ust/lttng-events.h index e09443f1..950604e4 100644 --- a/include/ust/lttng-events.h +++ b/include/ust/lttng-events.h @@ -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 { diff --git a/include/ust/lttng-ust-abi.h b/include/ust/lttng-ust-abi.h index 303493ee..5eb131f8 100644 --- a/include/ust/lttng-ust-abi.h +++ b/include/ust/lttng-ust-abi.h @@ -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) diff --git a/include/ust/lttng-ust-ctl.h b/include/ust/lttng-ust-ctl.h index ddadd61e..0a0feae9 100644 --- a/include/ust/lttng-ust-ctl.h +++ b/include/ust/lttng-ust-ctl.h @@ -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); diff --git a/libust/ltt-ring-buffer-client.h b/libust/ltt-ring-buffer-client.h index 270cb1e9..abe405d0 100644 --- a/libust/ltt-ring-buffer-client.h +++ b/libust/ltt-ring-buffer-client.h @@ -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, }, }; diff --git a/libust/ltt-ring-buffer-metadata-client.h b/libust/ltt-ring-buffer-metadata-client.h index 302e020e..4415ab66 100644 --- a/libust/ltt-ring-buffer-metadata-client.h +++ b/libust/ltt-ring-buffer-metadata-client.h @@ -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, }, }; diff --git a/libust/lttng-ust-abi.c b/libust/lttng-ust-abi.c index 1d32e777..6848c938 100644 --- a/libust/lttng-ust-abi.c +++ b/libust/lttng-ust-abi.c @@ -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; diff --git a/libustctl/ustctl.c b/libustctl/ustctl.c index cec7e24c..51826c13 100644 --- a/libustctl/ustctl.c +++ b/libustctl/ustctl.c @@ -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;