Skip to content

Commit d9abde2

Browse files
Steven Rostedtrostedt
authored andcommitted
ring-buffer: Micro-optimize with some strategic inlining
By using inline and noinline, we are able to make the fast path of recording an event 4% faster. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 140ff89 commit d9abde2

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

‎kernel/trace/ring_buffer.c‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,7 @@ static void rb_start_commit(struct ring_buffer_per_cpu *cpu_buffer)
20782078
local_inc(&cpu_buffer->commits);
20792079
}
20802080

2081-
static void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
2081+
static inline void rb_end_commit(struct ring_buffer_per_cpu *cpu_buffer)
20822082
{
20832083
unsigned long commits;
20842084

@@ -2193,13 +2193,9 @@ rb_reserve_next_event(struct ring_buffer *buffer,
21932193

21942194
#define TRACE_RECURSIVE_DEPTH 16
21952195

2196-
static int trace_recursive_lock(void)
2196+
/* Keep this code out of the fast path cache */
2197+
static noinline void trace_recursive_fail(void)
21972198
{
2198-
current->trace_recursion++;
2199-
2200-
if (likely(current->trace_recursion < TRACE_RECURSIVE_DEPTH))
2201-
return 0;
2202-
22032199
/* Disable all tracing before we do anything else */
22042200
tracing_off_permanent();
22052201

@@ -2211,10 +2207,21 @@ static int trace_recursive_lock(void)
22112207
in_nmi());
22122208

22132209
WARN_ON_ONCE(1);
2210+
}
2211+
2212+
static inline int trace_recursive_lock(void)
2213+
{
2214+
current->trace_recursion++;
2215+
2216+
if (likely(current->trace_recursion < TRACE_RECURSIVE_DEPTH))
2217+
return 0;
2218+
2219+
trace_recursive_fail();
2220+
22142221
return -1;
22152222
}
22162223

2217-
static void trace_recursive_unlock(void)
2224+
static inline void trace_recursive_unlock(void)
22182225
{
22192226
WARN_ON_ONCE(!current->trace_recursion);
22202227

0 commit comments

Comments
 (0)