mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
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>
|
||
|---|---|---|
| .. | ||
| blktrace.c | ||
| ftrace.c | ||
| Kconfig | ||
| kmemtrace.c | ||
| Makefile | ||
| ring_buffer.c | ||
| trace_boot.c | ||
| trace_branch.c | ||
| trace_clock.c | ||
| trace_event_profile.c | ||
| trace_event_types.h | ||
| trace_events_filter.c | ||
| trace_events.c | ||
| trace_export.c | ||
| trace_functions_graph.c | ||
| trace_functions.c | ||
| trace_hw_branches.c | ||
| trace_irqsoff.c | ||
| trace_mmiotrace.c | ||
| trace_nop.c | ||
| trace_output.c | ||
| trace_output.h | ||
| trace_power.c | ||
| trace_printk.c | ||
| trace_sched_switch.c | ||
| trace_sched_wakeup.c | ||
| trace_selftest_dynamic.c | ||
| trace_selftest.c | ||
| trace_stack.c | ||
| trace_stat.c | ||
| trace_stat.h | ||
| trace_syscalls.c | ||
| trace_sysprof.c | ||
| trace_workqueue.c | ||
| trace.c | ||
| trace.h | ||