ring_buffer: fix typing mistake
authorLai Jiangshan <laijs@cn.fujitsu.com>
Mon, 9 Feb 2009 06:21:14 +0000 (14:21 +0800)
committerSteven Rostedt <srostedt@redhat.com>
Tue, 10 Feb 2009 14:17:19 +0000 (09:17 -0500)
Impact: Fix bug

I found several very very curious line.
It's so curious that it may be brought by typing mistake.

When (cpu_buffer->reader_page == cpu_buffer->commit_page):

1) We haven't copied it for bpage is changed:
   bpage = cpu_buffer->reader_page->page;
   memcpy(bpage->data, cpu_buffer->reader_page->page->data + read ... )
2) We need update cpu_buffer->reader_page->read, but
   "cpu_buffer->reader_page += read;" is not right.

[
  This bug was a typo. The commit->reader_page is a page pointer
  and not an index into the page. The line should have been
  commit->reader_page->read += read.  The other changes
  by Lai are nice clean ups to the code.  - SDR
]

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
kernel/trace/ring_buffer.c

index 53ba3a6d16d026ff122b86c735781dd5c3ce23a4..eca2827208384f21bf6278dfd94873ae4bbaf9d1 100644 (file)
@@ -2406,7 +2406,7 @@ void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data)
  * to swap with a page in the ring buffer.
  *
  * for example:
- *     rpage = ring_buffer_alloc_page(buffer);
+ *     rpage = ring_buffer_alloc_read_page(buffer);
  *     if (!rpage)
  *             return error;
  *     ret = ring_buffer_read_page(buffer, &rpage, cpu, 0);
@@ -2461,18 +2461,17 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
         */
        if (cpu_buffer->reader_page == cpu_buffer->commit_page) {
                unsigned int read = cpu_buffer->reader_page->read;
+               unsigned int commit = rb_page_commit(cpu_buffer->reader_page);
 
                if (full)
                        goto out;
                /* The writer is still on the reader page, we must copy */
-               bpage = cpu_buffer->reader_page->page;
                memcpy(bpage->data,
                       cpu_buffer->reader_page->page->data + read,
-                      local_read(&bpage->commit) - read);
+                      commit - read);
 
                /* consume what was read */
-               cpu_buffer->reader_page += read;
-
+               cpu_buffer->reader_page->read = commit;
        } else {
                /* swap the pages */
                rb_init_page(bpage);