History

ring-buffer: Update read stamp with first real commit on page

Do not update the read stamp after swapping out the reader page from the write buffer. If the reader page is swapped out of the buffer before an event is written to it, then the read_stamp may get an out of date timestamp, as the page timestamp is updated on the first commit to that page. rb_get_reader_page() only returns a page if it has an event on it, otherwise it will return NULL. At that point, check if the page being returned has events and has not been read yet. Then at that point update the read_stamp to match the time stamp of the reader page.

Steven Rostedt (Red Hat) committed 10 years ago

Commit b81f4721 parent 1ec21831 file · +5 −7Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/ring_buffer.c+5−7
@@ -1887,12 +1887,6 @@ rb_event_index(struct ring_buffer_event *event) · 1886 unmodified lines
1887 return (addr & ~PAGE_MASK) - BUF_PAGE_HDR_SIZE;1887 return (addr & ~PAGE_MASK) - BUF_PAGE_HDR_SIZE;
1888}1888}
1889 1889
1890static void rb_reset_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
1891{
1892 cpu_buffer->read_stamp = cpu_buffer->reader_page->page->time_stamp;
1893 cpu_buffer->reader_page->read = 0;
1894}
1895
1896static void rb_inc_iter(struct ring_buffer_iter *iter)1890static void rb_inc_iter(struct ring_buffer_iter *iter)
1897{1891{
1898 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;1892 struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
@@ -3626,7 +3620,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer) · 1727 unmodified lines
3626 3620
3627 /* Finally update the reader page to the new head */3621 /* Finally update the reader page to the new head */
3628 cpu_buffer->reader_page = reader;3622 cpu_buffer->reader_page = reader;
3629 rb_reset_reader_page(cpu_buffer);3623 cpu_buffer->reader_page->read = 0;
3630 3624
3631 if (overwrite != cpu_buffer->last_overrun) {3625 if (overwrite != cpu_buffer->last_overrun) {
3632 cpu_buffer->lost_events = overwrite - cpu_buffer->last_overrun;3626 cpu_buffer->lost_events = overwrite - cpu_buffer->last_overrun;
@@ -3636,6 +3630,10 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer) · 3 unmodified lines
3636 goto again;3630 goto again;
3637 3631
3638 out:3632 out:
3633 /* Update the read_stamp on the first event */
3634 if (reader && reader->read == 0)
3635 cpu_buffer->read_stamp = reader->page->time_stamp;
3636
3639 arch_spin_unlock(&cpu_buffer->lock);3637 arch_spin_unlock(&cpu_buffer->lock);
3640 local_irq_restore(flags);3638 local_irq_restore(flags);
3641 3639

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t