Skip to content

Commit

Permalink
ring_buffer: implement new locking
Browse files Browse the repository at this point in the history
The old "lock always" scheme had issues with lockdep, and was not very
efficient anyways.

This patch does a new design to be partially lockless on writes.
Writes will add new entries to the per cpu pages by simply disabling
interrupts. When a write needs to go to another page than it will
grab the lock.

A new "read page" has been added so that the reader can pull out a page
from the ring buffer to read without worrying about the writer writing over
it. This allows us to not take the lock for all reads. The lock is
now only taken when a read needs to go to a new page.

This is far from lockless, and interrupts still need to be disabled,
but it is a step towards a more lockless solution, and it also
solves a lot of the issues that were noticed by the first conversion
of ftrace to the ring buffers.

Note: the ring_buffer_{un}lock API has been removed.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Steven Rostedt authored and Ingo Molnar committed Oct 14, 2008
1 parent 70255b5 commit d769041
Show file tree
Hide file tree
Showing 3 changed files with 247 additions and 167 deletions.
3 changes: 0 additions & 3 deletions include/linux/ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ ring_buffer_event_time_delta(struct ring_buffer_event *event)
return event->time_delta;
}

void ring_buffer_lock(struct ring_buffer *buffer, unsigned long *flags);
void ring_buffer_unlock(struct ring_buffer *buffer, unsigned long flags);

/*
* size is in bytes for each per CPU buffer.
*/
Expand Down
Loading

0 comments on commit d769041

Please sign in to comment.