linux-hardened/kernel/trace
Steven Rostedt (Red Hat) d4ecbfc49b tracing: Fix stack tracer with fentry use
When gcc 4.6 on x86 is used, the function tracer will use the new
option -mfentry which does a call to "fentry" at every function
instead of "mcount". The significance of this is that fentry is
called as the first operation of the function instead of the mcount
usage of being called after the stack.

This causes the stack tracer to show some bogus results for the size
of the last function traced, as well as showing "ftrace_call" instead
of the function. This is due to the stack frame not being set up
by the function that is about to be traced.

 # cat stack_trace
        Depth    Size   Location    (48 entries)
        -----    ----   --------
  0)     4824     216   ftrace_call+0x5/0x2f
  1)     4608     112   ____cache_alloc+0xb7/0x22d
  2)     4496      80   kmem_cache_alloc+0x63/0x12f

The 216 size for ftrace_call includes both the ftrace_call stack
(which includes the saving of registers it does), as well as the
stack size of the parent.

To fix this, if CC_USING_FENTRY is defined, then the stack_tracer
will reserve the first item in stack_dump_trace[] array when
calling save_stack_trace(), and it will fill it in with the parent ip.
Then the code will look for the parent pointer on the stack and
give the real size of the parent's stack pointer:

 # cat stack_trace
        Depth    Size   Location    (14 entries)
        -----    ----   --------
  0)     2640      48   update_group_power+0x26/0x187
  1)     2592     224   update_sd_lb_stats+0x2a5/0x4ac
  2)     2368     160   find_busiest_group+0x31/0x1f1
  3)     2208     256   load_balance+0xd9/0x662

I'm Cc'ing stable, although it's not urgent, as it only shows bogus
size for item #0, the rest of the trace is legit. It should still be
corrected in previous stable releases.

Cc: stable@vger.kernel.org
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2013-03-15 00:36:07 -04:00
..
blktrace.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
ftrace.c ftrace: Use manual free after synchronize_sched() not call_rcu_sched() 2013-03-15 00:36:03 -04:00
Kconfig tracing: Add config option to allow snapshot to swap per cpu 2013-03-15 00:35:47 -04:00
Makefile trace: Stop compiling in trace_clock unconditionally 2012-09-13 22:52:08 -04:00
power-traces.c
ring_buffer.c ring-buffer: Do not use schedule_work_on() for current CPU 2013-03-15 00:35:52 -04:00
ring_buffer_benchmark.c
rpm-traces.c
trace.c tracing: Add skip argument to trace_dump_stack() 2013-03-15 00:36:05 -04:00
trace.h tracing: Add internal ftrace trace_puts() for ftrace to use 2013-03-15 00:35:56 -04:00
trace_branch.c tracing: Fix the branch tracer that broke with buffer change 2013-03-15 00:35:54 -04:00
trace_clock.c Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2013-02-19 17:49:41 -08:00
trace_entries.h tracing: Add trace_puts() for even faster trace_printk() tracing 2013-03-15 00:35:55 -04:00
trace_event_perf.c perf/core improvements and fixes: 2012-08-21 11:27:00 +02:00
trace_events.c tracing: Add function probe triggers to enable/disable events 2013-03-15 00:36:04 -04:00
trace_events_filter.c tracing: Separate out trace events from global variables 2013-03-15 00:34:40 -04:00
trace_events_filter_test.h
trace_export.c tracing: Fix some section mismatch warnings 2013-03-15 00:34:54 -04:00
trace_functions.c tracing: Add function probe to trigger stack traces 2013-03-15 00:36:05 -04:00
trace_functions_graph.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
trace_irqsoff.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
trace_kdb.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
trace_kprobe.c tracing: Use irq_work for wake ups and remove *_nowake_*() functions 2012-11-02 10:21:52 -04:00
trace_mmiotrace.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
trace_nop.c
trace_output.c tracing: Add trace_puts() for even faster trace_printk() tracing 2013-03-15 00:35:55 -04:00
trace_output.h tracing: Add trace_puts() for even faster trace_printk() tracing 2013-03-15 00:35:55 -04:00
trace_printk.c
trace_probe.c tracing: Replace strict_strto* with kstrto* 2012-10-31 16:45:23 -04:00
trace_probe.h uprobes/tracing: Introduce is_trace_uprobe_enabled() 2013-02-08 18:24:30 +01:00
trace_sched_switch.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
trace_sched_wakeup.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
trace_selftest.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
trace_selftest_dynamic.c
trace_stack.c tracing: Fix stack tracer with fentry use 2013-03-15 00:36:07 -04:00
trace_stat.c
trace_stat.h
trace_syscalls.c tracing: Consolidate max_tr into main trace_array structure 2013-03-15 00:35:40 -04:00
trace_uprobe.c uprobes/perf: Avoid uprobe_apply() whenever possible 2013-02-08 18:28:08 +01:00