Skip to content

Commit

Permalink
tracing: Only create stacktrace option when STACKTRACE is configured
Browse files Browse the repository at this point in the history
Only create the stacktrace trace option when CONFIG_STACKTRACE is
configured.

Cleaned up the ftrace_trace_stack() function call a little to allow better
encapsulation of the stacktrace trace flag.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (Red Hat) committed Sep 29, 2015
1 parent 8179e8a commit 73dddbb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
28 changes: 15 additions & 13 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ static inline void trace_access_lock_init(void)
static void __ftrace_trace_stack(struct ring_buffer *buffer,
unsigned long flags,
int skip, int pc, struct pt_regs *regs);
static void ftrace_trace_stack(struct ring_buffer *buffer, unsigned long flags,
int skip, int pc);
static inline void ftrace_trace_stack(struct ring_buffer *buffer,
unsigned long flags,
int skip, int pc, struct pt_regs *regs);

#else
static inline void __ftrace_trace_stack(struct ring_buffer *buffer,
Expand All @@ -482,7 +483,8 @@ static inline void __ftrace_trace_stack(struct ring_buffer *buffer,
{
}
static inline void ftrace_trace_stack(struct ring_buffer *buffer,
unsigned long flags, int skip, int pc)
unsigned long flags,
int skip, int pc, struct pt_regs *regs)
{
}

Expand Down Expand Up @@ -571,7 +573,7 @@ int __trace_puts(unsigned long ip, const char *str, int size)
entry->buf[size] = '\0';

__buffer_unlock_commit(buffer, event);
ftrace_trace_stack(buffer, irq_flags, 4, pc);
ftrace_trace_stack(buffer, irq_flags, 4, pc, NULL);

return size;
}
Expand Down Expand Up @@ -611,7 +613,7 @@ int __trace_bputs(unsigned long ip, const char *str)
entry->str = str;

__buffer_unlock_commit(buffer, event);
ftrace_trace_stack(buffer, irq_flags, 4, pc);
ftrace_trace_stack(buffer, irq_flags, 4, pc, NULL);

return 1;
}
Expand Down Expand Up @@ -1685,7 +1687,7 @@ void trace_buffer_unlock_commit(struct trace_array *tr,
{
__buffer_unlock_commit(buffer, event);

ftrace_trace_stack(buffer, flags, 6, pc);
ftrace_trace_stack(buffer, flags, 6, pc, NULL);
ftrace_trace_userstack(buffer, flags, pc);
}
EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit);
Expand Down Expand Up @@ -1737,8 +1739,7 @@ void trace_buffer_unlock_commit_regs(struct trace_array *tr,
{
__buffer_unlock_commit(buffer, event);

if (trace_flags & TRACE_ITER_STACKTRACE)
__ftrace_trace_stack(buffer, flags, 0, pc, regs);
ftrace_trace_stack(buffer, flags, 6, pc, regs);
ftrace_trace_userstack(buffer, flags, pc);
}
EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit_regs);
Expand Down Expand Up @@ -1867,13 +1868,14 @@ static void __ftrace_trace_stack(struct ring_buffer *buffer,

}

static void ftrace_trace_stack(struct ring_buffer *buffer, unsigned long flags,
int skip, int pc)
static inline void ftrace_trace_stack(struct ring_buffer *buffer,
unsigned long flags,
int skip, int pc, struct pt_regs *regs)
{
if (!(trace_flags & TRACE_ITER_STACKTRACE))
return;

__ftrace_trace_stack(buffer, flags, skip, pc, NULL);
__ftrace_trace_stack(buffer, flags, skip, pc, regs);
}

void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
Expand Down Expand Up @@ -2158,7 +2160,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
memcpy(entry->buf, tbuffer, sizeof(u32) * len);
if (!call_filter_check_discard(call, entry, buffer, event)) {
__buffer_unlock_commit(buffer, event);
ftrace_trace_stack(buffer, flags, 6, pc);
ftrace_trace_stack(buffer, flags, 6, pc, NULL);
}

out:
Expand Down Expand Up @@ -2210,7 +2212,7 @@ __trace_array_vprintk(struct ring_buffer *buffer,
memcpy(&entry->buf, tbuffer, len + 1);
if (!call_filter_check_discard(call, entry, buffer, event)) {
__buffer_unlock_commit(buffer, event);
ftrace_trace_stack(buffer, flags, 6, pc);
ftrace_trace_stack(buffer, flags, 6, pc, NULL);
}
out:
preempt_enable_notrace();
Expand Down
9 changes: 8 additions & 1 deletion kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,13 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
# define FUNCTION_DEFAULT_FLAGS 0UL
#endif

#ifdef CONFIG_STACKTRACE
# define STACK_FLAGS \
C(STACKTRACE, "stacktrace"),
#else
# define STACK_FLAGS
#endif

/*
* trace_iterator_flags is an enumeration that defines bit
* positions into trace_flags that controls the output.
Expand All @@ -927,7 +934,6 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
C(HEX, "hex"), \
C(BIN, "bin"), \
C(BLOCK, "block"), \
C(STACKTRACE, "stacktrace"), \
C(PRINTK, "trace_printk"), \
C(ANNOTATE, "annotate"), \
C(USERSTACKTRACE, "userstacktrace"), \
Expand All @@ -942,6 +948,7 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
C(MARKERS, "markers"), \
FUNCTION_FLAGS \
FGRAPH_FLAGS \
STACK_FLAGS \
BRANCH_FLAGS

/*
Expand Down

0 comments on commit 73dddbb

Please sign in to comment.