Add ustctl_snapshot_sample_positions ustctl command
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 5 May 2017 14:33:06 +0000 (10:33 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 5 May 2017 14:41:01 +0000 (10:41 -0400)
The protocol's minor version is bumped since a new API entry
point is introduced. The so name's "current" and "age" fields are
bumped in accordance with the libtool guidelines[1].

[1] https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
configure.ac
include/lttng/ust-ctl.h
liblttng-ust-ctl/ustctl.c
libringbuffer/frontend.h
libringbuffer/ring_buffer_frontend.c

index 023cfd4e3811ac52b020bec794a948d2bbf681e3..77b212cd7091d3c0b805059db0b8d72cd50f2cce 100644 (file)
@@ -22,7 +22,7 @@ AC_SUBST([LTTNG_UST_LIBRARY_VERSION], [0:0:0])
 
 # This is the library version of liblttng-ust-ctl, used internally by
 # liblttng-ust, lttng-sessiond, and lttng-consumerd.
-AC_SUBST([LTTNG_UST_CTL_LIBRARY_VERSION], [2:0:0])
+AC_SUBST([LTTNG_UST_CTL_LIBRARY_VERSION], [3:0:1])
 
 AC_CONFIG_AUX_DIR([config])
 AC_CANONICAL_TARGET
index 7b750fd4438812f530357e3355d86a672215af5c..f6c1dc4527c4d64a4318a54375d3e5ee70c94e99 100644 (file)
@@ -226,6 +226,7 @@ int ustctl_put_next_subbuf(struct ustctl_consumer_stream *stream);
 /* snapshot */
 
 int ustctl_snapshot(struct ustctl_consumer_stream *stream);
+int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream);
 int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream,
                unsigned long *pos);
 int ustctl_snapshot_get_produced(struct ustctl_consumer_stream *stream,
index 7b41b992fc03dc511554bb52e5fc350ac435e8cf..8e2e8f1b8b4eabf7e617a585198d5dc296db2ee1 100644 (file)
@@ -1501,6 +1501,25 @@ int ustctl_snapshot(struct ustctl_consumer_stream *stream)
                        &buf->prod_snapshot, consumer_chan->chan->handle);
 }
 
+/*
+ * Get a snapshot of the current ring buffer producer and consumer positions
+ * even if the consumed and produced positions are contained within the same
+ * subbuffer.
+ */
+int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream)
+{
+       struct lttng_ust_lib_ring_buffer *buf;
+       struct ustctl_consumer_channel *consumer_chan;
+
+       if (!stream)
+               return -EINVAL;
+       buf = stream->buf;
+       consumer_chan = stream->chan;
+       return lib_ring_buffer_snapshot_sample_positions(buf,
+                       &buf->cons_snapshot, &buf->prod_snapshot,
+                       consumer_chan->chan->handle);
+}
+
 /* Get the consumer position (iteration start) */
 int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream,
                unsigned long *pos)
index 160fd45532f39573b09178f6924bba71b1f65264..a2f74596eb9c06f319236309d2f36cdae2eaca99 100644 (file)
@@ -131,6 +131,11 @@ extern int lib_ring_buffer_snapshot(struct lttng_ust_lib_ring_buffer *buf,
                                    unsigned long *consumed,
                                    unsigned long *produced,
                                    struct lttng_ust_shm_handle *handle);
+extern int lib_ring_buffer_snapshot_sample_positions(
+                                   struct lttng_ust_lib_ring_buffer *buf,
+                                   unsigned long *consumed,
+                                   unsigned long *produced,
+                                   struct lttng_ust_shm_handle *handle);
 extern void lib_ring_buffer_move_consumer(struct lttng_ust_lib_ring_buffer *buf,
                                          unsigned long consumed_new,
                                          struct lttng_ust_shm_handle *handle);
index 6dd81e14b0bbb6e767b44687d725c210b43661fc..9b16685251ee1e1d8da49801c1f11ca61ec2060a 100644 (file)
@@ -1305,6 +1305,44 @@ nodata:
                return -EAGAIN;
 }
 
+/**
+ * Performs the same function as lib_ring_buffer_snapshot(), but the positions
+ * are saved regardless of whether the consumed and produced positions are
+ * in the same subbuffer.
+ * @buf: ring buffer
+ * @consumed: consumed byte count indicating the last position read
+ * @produced: produced byte count indicating the last position written
+ *
+ * This function is meant to provide information on the exact producer and
+ * consumer positions without regard for the "snapshot" feature.
+ */
+int lib_ring_buffer_snapshot_sample_positions(
+                            struct lttng_ust_lib_ring_buffer *buf,
+                            unsigned long *consumed, unsigned long *produced,
+                            struct lttng_ust_shm_handle *handle)
+{
+       struct channel *chan;
+       const struct lttng_ust_lib_ring_buffer_config *config;
+       unsigned long consumed_cur, write_offset;
+
+       chan = shmp(handle, buf->backend.chan);
+       if (!chan)
+               return -EPERM;
+       config = &chan->backend.config;
+       cmm_smp_rmb();
+       *consumed = uatomic_read(&buf->consumed);
+       /*
+        * No need to issue a memory barrier between consumed count read and
+        * write offset read, because consumed count can only change
+        * concurrently in overwrite mode, and we keep a sequence counter
+        * identifier derived from the write offset to check we are getting
+        * the same sub-buffer we are expecting (the sub-buffers are atomically
+        * "tagged" upon writes, tags are checked upon read).
+        */
+       *produced = v_read(config, &buf->offset);
+       return 0;
+}
+
 /**
  * lib_ring_buffer_move_consumer - move consumed counter forward
  * @buf: ring buffer
This page took 0.028955 seconds and 4 git commands to generate.