Skip to content

Commit 3e6c8f8

Browse files
committed
tracing: Move ftrace_trace_stack() out of trace.c and into trace.h
The file trace.c has become a catchall for most things tracing. Start making it smaller by breaking out various aspects into their own files. Make ftrace_trace_stack() into a static inline that tests if stack tracing is enabled and if so to call __ftrace_trace_stack() to do the stack trace. This keeps the test inlined in the fast paths and only does the function call if stack tracing is enabled. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: https://patch.msgid.link/20260208032449.974218132@kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 0e730bc commit 3e6c8f8

2 files changed

Lines changed: 35 additions & 41 deletions

File tree

kernel/trace/trace.c

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,32 +1032,6 @@ static inline void trace_access_lock_init(void)
10321032

10331033
#endif
10341034

1035-
#ifdef CONFIG_STACKTRACE
1036-
static void __ftrace_trace_stack(struct trace_array *tr,
1037-
struct trace_buffer *buffer,
1038-
unsigned int trace_ctx,
1039-
int skip, struct pt_regs *regs);
1040-
static inline void ftrace_trace_stack(struct trace_array *tr,
1041-
struct trace_buffer *buffer,
1042-
unsigned int trace_ctx,
1043-
int skip, struct pt_regs *regs);
1044-
1045-
#else
1046-
static inline void __ftrace_trace_stack(struct trace_array *tr,
1047-
struct trace_buffer *buffer,
1048-
unsigned int trace_ctx,
1049-
int skip, struct pt_regs *regs)
1050-
{
1051-
}
1052-
static inline void ftrace_trace_stack(struct trace_array *tr,
1053-
struct trace_buffer *buffer,
1054-
unsigned long trace_ctx,
1055-
int skip, struct pt_regs *regs)
1056-
{
1057-
}
1058-
1059-
#endif
1060-
10611035
void tracer_tracing_on(struct trace_array *tr)
10621036
{
10631037
if (tr->array_buffer.buffer)
@@ -2964,10 +2938,10 @@ struct ftrace_stacks {
29642938
static DEFINE_PER_CPU(struct ftrace_stacks, ftrace_stacks);
29652939
static DEFINE_PER_CPU(int, ftrace_stack_reserve);
29662940

2967-
static void __ftrace_trace_stack(struct trace_array *tr,
2968-
struct trace_buffer *buffer,
2969-
unsigned int trace_ctx,
2970-
int skip, struct pt_regs *regs)
2941+
void __ftrace_trace_stack(struct trace_array *tr,
2942+
struct trace_buffer *buffer,
2943+
unsigned int trace_ctx,
2944+
int skip, struct pt_regs *regs)
29712945
{
29722946
struct ring_buffer_event *event;
29732947
unsigned int size, nr_entries;
@@ -3050,17 +3024,6 @@ static void __ftrace_trace_stack(struct trace_array *tr,
30503024
trace_clear_recursion(bit);
30513025
}
30523026

3053-
static inline void ftrace_trace_stack(struct trace_array *tr,
3054-
struct trace_buffer *buffer,
3055-
unsigned int trace_ctx,
3056-
int skip, struct pt_regs *regs)
3057-
{
3058-
if (!(tr->trace_flags & TRACE_ITER(STACKTRACE)))
3059-
return;
3060-
3061-
__ftrace_trace_stack(tr, buffer, trace_ctx, skip, regs);
3062-
}
3063-
30643027
void __trace_stack(struct trace_array *tr, unsigned int trace_ctx,
30653028
int skip)
30663029
{

kernel/trace/trace.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,6 +2279,37 @@ static inline void sanitize_event_name(char *name)
22792279
*name = '_';
22802280
}
22812281

2282+
#ifdef CONFIG_STACKTRACE
2283+
void __ftrace_trace_stack(struct trace_array *tr,
2284+
struct trace_buffer *buffer,
2285+
unsigned int trace_ctx,
2286+
int skip, struct pt_regs *regs);
2287+
2288+
static __always_inline void ftrace_trace_stack(struct trace_array *tr,
2289+
struct trace_buffer *buffer,
2290+
unsigned int trace_ctx,
2291+
int skip, struct pt_regs *regs)
2292+
{
2293+
if (!(tr->trace_flags & TRACE_ITER(STACKTRACE)))
2294+
return;
2295+
2296+
__ftrace_trace_stack(tr, buffer, trace_ctx, skip, regs);
2297+
}
2298+
#else
2299+
static inline void __ftrace_trace_stack(struct trace_array *tr,
2300+
struct trace_buffer *buffer,
2301+
unsigned int trace_ctx,
2302+
int skip, struct pt_regs *regs)
2303+
{
2304+
}
2305+
static inline void ftrace_trace_stack(struct trace_array *tr,
2306+
struct trace_buffer *buffer,
2307+
unsigned long trace_ctx,
2308+
int skip, struct pt_regs *regs)
2309+
{
2310+
}
2311+
#endif
2312+
22822313
/*
22832314
* This is a generic way to read and write a u64 value from a file in tracefs.
22842315
*

0 commit comments

Comments
 (0)