]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
ring-buffer: Have ring_buffer_iter_empty() return true when empty
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 19 Apr 2017 18:29:46 +0000 (14:29 -0400)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Fri, 5 May 2017 13:13:47 +0000 (10:13 -0300)
commit0c1f7ac8ab4097c9f4d3e27b1533e3c6f1231214
treeb19d868577c67e8391693a1a2676bd5e1f25c387
parent0b2aee5954c51b0c298a61bf290a2e5db328d7ac
ring-buffer: Have ring_buffer_iter_empty() return true when empty

BugLink: http://bugs.launchpad.net/bugs/1687638
commit 78f7a45dac2a2d2002f98a3a95f7979867868d73 upstream.

I noticed that reading the snapshot file when it is empty no longer gives a
status. It suppose to show the status of the snapshot buffer as well as how
to allocate and use it. For example:

 ># cat snapshot
 # tracer: nop
 #
 #
 # * Snapshot is allocated *
 #
 # Snapshot commands:
 # echo 0 > snapshot : Clears and frees snapshot buffer
 # echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.
 #                      Takes a snapshot of the main buffer.
 # echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)
 #                      (Doesn't have to be '2' works with any number that
 #                       is not a '0' or '1')

But instead it just showed an empty buffer:

 ># cat snapshot
 # tracer: nop
 #
 # entries-in-buffer/entries-written: 0/0   #P:4
 #
 #                              _-----=> irqs-off
 #                             / _----=> need-resched
 #                            | / _---=> hardirq/softirq
 #                            || / _--=> preempt-depth
 #                            ||| /     delay
 #           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
 #              | |       |   ||||       |         |

What happened was that it was using the ring_buffer_iter_empty() function to
see if it was empty, and if it was, it showed the status. But that function
was returning false when it was empty. The reason was that the iter header
page was on the reader page, and the reader page was empty, but so was the
buffer itself. The check only tested to see if the iter was on the commit
page, but the commit page was no longer pointing to the reader page, but as
all pages were empty, the buffer is also.

Fixes: 651e22f2701b ("ring-buffer: Always reset iterator to reader page")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
kernel/trace/ring_buffer.c