alistair23-linux/kernel/trace
Frederic Weisbecker f413cdb80c perf_counter: Fix/complete ftrace event records sampling
This patch implements the kernel side support for ftrace event
record sampling.

A new counter sampling attribute is added:

   PERF_SAMPLE_TP_RECORD

which requests ftrace events record sampling. In this case
if a PERF_TYPE_TRACEPOINT counter is active and a tracepoint
fires, we emit the tracepoint binary record to the
perfcounter event buffer, as a sample.

Result, after setting PERF_SAMPLE_TP_RECORD attribute from perf
record:

 perf record -f -F 1 -a -e workqueue:workqueue_execution
 perf report -D

 0x21e18 [0x48]: event: 9
 .
 . ... raw event: size 72 bytes
 .  0000:  09 00 00 00 01 00 48 00 d0 c7 00 81 ff ff ff ff  ......H........
 .  0010:  0a 00 00 00 0a 00 00 00 21 00 00 00 00 00 00 00  ........!......
 .  0020:  2b 00 01 02 0a 00 00 00 0a 00 00 00 65 76 65 6e  +...........eve
 .  0030:  74 73 2f 31 00 00 00 00 00 00 00 00 0a 00 00 00  ts/1...........
 .  0040:  e0 b1 31 81 ff ff ff ff                          .......
.
0x21e18 [0x48]: PERF_EVENT_SAMPLE (IP, 1): 10: 0xffffffff8100c7d0 period: 33

The raw ftrace binary record starts at offset 0020.

Translation:

 struct trace_entry {
	type		= 0x2b = 43;
	flags		= 1;
	preempt_count	= 2;
	pid		= 0xa = 10;
	tgid		= 0xa = 10;
 }

 thread_comm = "events/1"
 thread_pid  = 0xa = 10;
 func	    = 0xffffffff8131b1e0 = flush_to_ldisc()

What will come next?

 - Userspace support ('perf trace'), 'flight data recorder' mode
   for perf trace, etc.

 - The unconditional copy from the profiling callback brings
   some costs however if someone wants no such sampling to
   occur, and needs to be fixed in the future. For that we need
   to have an instant access to the perf counter attribute.
   This is a matter of a flag to add in the struct ftrace_event.

 - Take care of the events recursivity! Don't ever try to record
   a lock event for example, it seems some locking is used in
   the profiling fast path and lead to a tracing recursivity.
   That will be fixed using raw spinlock or recursivity
   protection.

 - [...]

 - Profit! :-)

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Gabriel Munteanu <eduard.munteanu@linux360.ro>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-08-09 12:53:48 +02:00
..
blktrace.c headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
ftrace.c tracing: only truncate ftrace files when O_TRUNC is set 2009-07-23 10:07:18 -04:00
Kconfig tracing/fastboot: Document the need of initcall_debug 2009-06-29 10:22:10 +02:00
kmemtrace.c cpumask: use new operators in kernel/trace 2009-06-15 11:36:42 -04:00
Makefile tracing/events: convert block trace points to TRACE_EVENT() 2009-06-09 12:34:23 -04:00
ring_buffer.c ring-buffer: Fix memleak in ring_buffer_free() 2009-08-07 12:46:39 -04:00
ring_buffer_benchmark.c ring-buffer: have benchmark test print to trace buffer 2009-06-17 17:01:09 -04:00
trace.c perf_counter: Fix/complete ftrace event records sampling 2009-08-09 12:53:48 +02:00
trace.h perf_counter: Fix/complete ftrace event records sampling 2009-08-09 12:53:48 +02:00
trace_boot.c
trace_branch.c
trace_clock.c
trace_event_profile.c ftrace: Fix perf-tracepoint OOPS 2009-08-06 06:26:09 +02:00
trace_event_types.h trace_export: Repair missed fields 2009-06-26 20:48:40 +02:00
trace_events.c ftrace: Fix perf-tracepoint OOPS 2009-08-06 06:26:09 +02:00
trace_events_filter.c tracing/filters: Always free pred on filter_add_subsystem_pred() failure 2009-08-08 17:56:13 +02:00
trace_export.c
trace_functions.c tracing/function: Fix the return value of ftrace_trace_onoff_callback() 2009-07-16 23:34:32 -04:00
trace_functions_graph.c tracing: Fix invalid function_graph entry 2009-07-28 23:17:23 +02:00
trace_hw_branches.c
trace_irqsoff.c
trace_mmiotrace.c
trace_nop.c
trace_output.c tracing: Fix trace_print_seq() 2009-07-02 08:51:13 +02:00
trace_output.h tracing: add protection around module events unload 2009-06-09 17:29:07 -04:00
trace_power.c
trace_printk.c tracing: show proper address for trace-printk format 2009-07-23 10:07:17 -04:00
trace_sched_switch.c
trace_sched_wakeup.c
trace_selftest.c
trace_selftest_dynamic.c
trace_stack.c trace_stack: Fix seqfile memory leak 2009-07-23 09:52:09 -04:00
trace_stat.c tracing/stat: Fix seqfile memory leak 2009-07-23 09:53:55 -04:00
trace_stat.h
trace_syscalls.c
trace_sysprof.c Merge branch 'timers-for-linus-migration' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-06-15 10:06:19 -07:00
trace_workqueue.c trace_workqueue: remove blank line between each cpu 2009-06-02 01:14:26 +02:00