]> bbs.cooldavid.org Git - net-next-2.6.git/commit - kernel/trace/ring_buffer.c
ring-buffer: move big if statement down
authorSteven Rostedt <srostedt@redhat.com>
Wed, 6 May 2009 01:16:11 +0000 (21:16 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 6 May 2009 01:16:11 +0000 (21:16 -0400)
commitaa20ae8444fc6c318272c643f856d8d8ad3e198d
tree662d8f33c284a43a41d5c9e9edfe13238bd3535e
parent94487d6d53af5acae10cf9fd52f74498994d46b1
ring-buffer: move big if statement down

In the hot path of the ring buffer "__rb_reserve_next" there's a big
if statement that does not even return back to the work flow.

code;

if (cross to next page) {

[ lots of code ]

return;
}

more code;

The condition is even the unlikely path, although we do not denote it
with an unlikely because gcc is fine with it. The condition is true when
the write crosses a page boundary, and we need to start at a new page.

Having this if statement makes it hard to read, but calling another
function to do the work is also not appropriate, because we are using a lot
of variables that were set before the if statement, and we do not want to
send them as parameters.

This patch changes it to a goto:

code;

if (cross to next page)
goto next_page;

more code;

return;

next_page:

[ lots of code]

This makes the code easier to understand, and a bit more obvious.

The output from gcc is practically identical. For some reason, gcc decided
to use different registers when I switched it to a goto. But other than that,
the logic is the same.

[ Impact: easier to read code ]

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ring_buffer.c