Skip to content

Commit

Permalink
ring-buffer: remove unneeded conditional in rb_reserve_next
Browse files Browse the repository at this point in the history
The code in __rb_reserve_next checks on page overflow if it is the
original commiter and then resets the page back to the original
setting.  Although this is fine, and the code is correct, it is
a bit fragil. Some experimental work I did breaks it easily.

The better and more robust solution is to have all commiters that
overflow the page, simply subtract what they added.

[ Impact: more robust ring buffer account management ]

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed May 6, 2009
1 parent 35cf723 commit 8e7abf1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,9 +1290,8 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
rb_event_set_padding(event);
}

if (tail <= BUF_PAGE_SIZE)
/* Set the write back to the previous setting */
local_set(&tail_page->write, tail);
/* Set the write back to the previous setting */
local_sub(length, &tail_page->write);

/*
* If this was a commit entry that failed,
Expand All @@ -1311,8 +1310,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,

out_reset:
/* reset write */
if (tail <= BUF_PAGE_SIZE)
local_set(&tail_page->write, tail);
local_sub(length, &tail_page->write);

if (likely(lock_taken))
__raw_spin_unlock(&cpu_buffer->lock);
Expand Down

0 comments on commit 8e7abf1

Please sign in to comment.