• Steven Rostedt's avatar
    ring-buffer: fix ring_buffer_read crossing pages · 7e9391cf
    Steven Rostedt authored
    When the ring buffer uses an iterator (static read mode, not on the
    fly reading), when it crosses a page boundery, it will skip the first
    entry on the next page. The reason is that the last entry of a page
    is usually padding if the page is not full. The padding will not be
    returned to the user.
    
    The problem arises on ring_buffer_read because it also increments the
    iterator. Because both the read and peek use the same rb_iter_peek,
    the rb_iter_peak will return the padding but also increment to the next
    item. This is because the ring_buffer_peek will not incerment it
    itself.
    
    The ring_buffer_read will increment it again and then call rb_iter_peek
    again to get the next item. But that will be the second item, not the
    first one on the page.
    
    The reason this never showed up before, is because the ftrace utility
    always calls ring_buffer_peek first and only uses ring_buffer_read
    to increment to the next item. The ring_buffer_peek will always keep
    the pointer to a valid item and not padding. This just hid the bug.
    Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    7e9391cf
ring_buffer.c 95 KB