Fix: don't perform extra flush on metadata channel
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 20 May 2016 00:30:07 +0000 (20:30 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 20 May 2016 00:42:32 +0000 (20:42 -0400)
The metadata channel requires that the LTTng client layer and the ring
buffer keep a notion of the amount of data produced in the channel.

This issue has been introduced recently by commit
"Fix: flush empty packets on snapshot channel".

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/frontend_internal.h
lib/ringbuffer/ring_buffer_frontend.c
lib/ringbuffer/ring_buffer_vfs.c
lttng-abi.c

index 47c080297ebd45ffd723de7c78caa6130fa672d3..2bc540370631ab53364a7f8fe318e776b386aabc 100644 (file)
@@ -159,6 +159,9 @@ void lib_ring_buffer_switch_slow(struct lib_ring_buffer *buf,
 extern
 void lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf);
 
+extern
+void lib_ring_buffer_switch_remote_empty(struct lib_ring_buffer *buf);
+
 /* Buffer write helpers */
 
 static inline
index 708bc6d39af56e50629b34f9e3c66c849d5f9c0c..6eec323232b8d2910b19603d82bbd47c2735f011 100644 (file)
@@ -900,15 +900,6 @@ int lib_ring_buffer_snapshot(struct lib_ring_buffer *buf,
        unsigned long consumed_cur, write_offset;
        int finalized;
 
-       /*
-        * First, ensure we perform a "final" flush onto the stream.  This will
-        * ensure we create a packet of padding if we encounter an empty
-        * packet. This ensures the time-stamps right before the snapshot is
-        * used as end of packet timestamp.
-        */
-       if (!buf->quiescent)
-               _lib_ring_buffer_switch_remote(buf, SWITCH_FLUSH);
-
 retry:
        finalized = ACCESS_ONCE(buf->finalized);
        /*
@@ -1659,6 +1650,13 @@ void lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf)
 }
 EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_remote);
 
+/* Switch sub-buffer even if current sub-buffer is empty. */
+void lib_ring_buffer_switch_remote_empty(struct lib_ring_buffer *buf)
+{
+       _lib_ring_buffer_switch_remote(buf, SWITCH_FLUSH);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_remote_empty);
+
 /*
  * Returns :
  * 0 if ok
index 4389b5f6562ff9e03326cd1724f1b6086123ae79..71991ebb29554ba9b2df713a73750d6e79acc843 100644 (file)
@@ -191,6 +191,15 @@ long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd,
 
        switch (cmd) {
        case RING_BUFFER_SNAPSHOT:
+               /*
+                * First, ensure we perform a "final" flush onto the
+                * stream.  This will ensure we create a packet of
+                * padding if we encounter an empty packet. This ensures
+                * the time-stamps right before the snapshot is used as
+                * end of packet timestamp.
+                */
+               if (!buf->quiescent)
+                       lib_ring_buffer_switch_remote_empty(buf);
                return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot,
                                            &buf->prod_snapshot);
        case RING_BUFFER_SNAPSHOT_GET_CONSUMED:
@@ -320,6 +329,15 @@ long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
 
        switch (cmd) {
        case RING_BUFFER_COMPAT_SNAPSHOT:
+               /*
+                * First, ensure we perform a "final" flush onto the
+                * stream.  This will ensure we create a packet of
+                * padding if we encounter an empty packet. This ensures
+                * the time-stamps right before the snapshot is used as
+                * end of packet timestamp.
+                */
+               if (!buf->quiescent)
+                       lib_ring_buffer_switch_remote_empty(buf);
                return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot,
                                                &buf->prod_snapshot);
        case RING_BUFFER_COMPAT_SNAPSHOT_GET_CONSUMED:
index 196aed84e421fa96708e13e247aee2277b255485..0f01d3d7df558b3ad6515edddc5006d865693d8b 100644 (file)
@@ -629,6 +629,18 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,
                        goto err;
                break;
        }
+       case RING_BUFFER_SNAPSHOT:
+       {
+               /*
+                * Force the buffer to quiescent so the ring buffer
+                * don't attempt to perform a SWITCH_FLUSH, which would
+                * desynchronize the client accounting of the amount of
+                * data available in the buffer from the ring buffer
+                * view.
+                */
+               buf->quiescent = true;
+               break;
+       }
        default:
                break;
        }
@@ -699,6 +711,18 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
                        goto err;
                break;
        }
+       case RING_BUFFER_SNAPSHOT:
+       {
+               /*
+                * Force the buffer to quiescent so the ring buffer
+                * don't attempt to perform a SWITCH_FLUSH, which would
+                * desynchronize the client accounting of the amount of
+                * data available in the buffer from the ring buffer
+                * view.
+                */
+               buf->quiescent = true;
+               break;
+       }
        default:
                break;
        }
This page took 0.030055 seconds and 4 git commands to generate.