android_kernel_xiaomi_sdm845/kernel/trace
Steven Rostedt d20e3b0384 tracing: add TRACE_FIELD_SPECIAL to record complex entries
Tom Zanussi pointed out that the simple TRACE_FIELD was not enough to
record trace data that required memcpy. This patch addresses this issue
by adding a TRACE_FIELD_SPECIAL. The format is similar to TRACE_FIELD
but looks like so:

  TRACE_FIELD_SPECIAL(type_item, item, cmd)

What TRACE_FIELD gave was:

  TRACE_FIELD(type, item, assign)

The TRACE_FIELD would be used in declaring a structure:

  struct {
	type	item;
  };

And later assign it via:

  entry->item = assign;

What TRACE_FIELD_SPECIAL gives us is:

In the declaration of the structure:

  struct {
	type_item;
  };

And the assignment:

  cmd;

This change log will explain the one example used in the patch:

 TRACE_EVENT_FORMAT(sched_switch,
	TPPROTO(struct rq *rq, struct task_struct *prev,
		struct task_struct *next),
	TPARGS(rq, prev, next),
	TPFMT("task %s:%d ==> %s:%d",
	      prev->comm, prev->pid, next->comm, next->pid),
	TRACE_STRUCT(
		TRACE_FIELD(pid_t, prev_pid, prev->pid)
		TRACE_FIELD(int, prev_prio, prev->prio)
		TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
				    next_comm,
				    TPCMD(memcpy(TRACE_ENTRY->next_comm,
						 next->comm,
						 TASK_COMM_LEN)))
		TRACE_FIELD(pid_t, next_pid, next->pid)
		TRACE_FIELD(int, next_prio, next->prio)
	),
	TPRAWFMT("prev %d:%d ==> next %s:%d:%d")
	);

 The struct will be create as:

  struct {
	pid_t		prev_pid;
	int		prev_prio;
	char next_comm[TASK_COMM_LEN];
	pid_t		next_pid;
	int		next_prio;
  };

Note the TRACE_ENTRY in the cmd part of TRACE_SPECIAL. TRACE_ENTRY will
be set by the tracer to point to the structure inside the trace buffer.

  entry->prev_pid	= prev->pid;
  entry->prev_prio	= prev->prio;
  memcpy(entry->next_comm, next->comm, TASK_COMM_LEN);
  entry->next_pid	= next->pid;
  entry->next_prio	= next->prio

Reported-by: Tom Zanussi <tzanussi@gmail.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
2009-03-02 10:53:15 -05:00
..
blktrace.c Merge branch 'linus' into tracing/blktrace 2009-02-19 09:00:35 +01:00
events.c tracing: add raw trace point recording infrastructure 2009-02-28 03:09:32 -05:00
ftrace.c Merge branch 'tip/x86/ftrace' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/ftrace 2009-02-22 18:12:01 +01:00
Kconfig tracing: add event trace infrastructure 2009-02-24 21:54:05 -05:00
kmemtrace.c tracing: Introduce trace_buffer_{lock_reserve,unlock_commit} 2009-02-06 01:01:41 +01:00
Makefile tracing: implement trace_clock_*() APIs 2009-02-26 18:44:06 +01:00
ring_buffer.c tracing: implement trace_clock_*() APIs 2009-02-26 18:44:06 +01:00
trace_boot.c tracing: Introduce trace_buffer_{lock_reserve,unlock_commit} 2009-02-06 01:01:41 +01:00
trace_branch.c tracing: remove unneeded variable 2009-02-10 12:32:18 -05:00
trace_clock.c tracing: implement trace_clock_*() APIs 2009-02-26 18:44:06 +01:00
trace_events_stage_1.h tracing: add TRACE_FIELD_SPECIAL to record complex entries 2009-03-02 10:53:15 -05:00
trace_events_stage_2.h tracing: add TRACE_FIELD_SPECIAL to record complex entries 2009-03-02 10:53:15 -05:00
trace_events_stage_3.h tracing: add TRACE_FIELD_SPECIAL to record complex entries 2009-03-02 10:53:15 -05:00
trace_events.c tracing: add raw fast tracing interface for trace events 2009-02-28 04:04:03 -05:00
trace_functions_graph.c tracing/function-graph-tracer: fix merge 2009-02-19 13:01:37 +01:00
trace_functions.c tracing/core: use appropriate waiting on trace_pipe 2009-02-18 01:40:20 +01:00
trace_hw_branches.c tracing/hw-branch-tracing: convert bts-tracer mutex to a spinlock 2009-02-25 09:16:01 +01:00
trace_irqsoff.c tracing: fix typing mistake in hint message and comments 2009-02-17 12:38:24 -05:00
trace_mmiotrace.c mmiotrace: count events lost due to not recording 2009-02-15 20:02:42 +01:00
trace_nop.c trace: Call tracing_reset_online_cpus before tracer->init() 2009-02-06 01:01:41 +01:00
trace_output.c Merge branch 'tip/tracing/core/devel' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/ftrace 2009-02-09 10:35:12 +01:00
trace_output.h trace: make the trace_event callbacks return enum print_line_t 2009-02-04 20:48:39 +01:00
trace_power.c tracing: convert c/p state power tracer to use tracepoints 2009-02-13 09:06:18 -05:00
trace_sched_switch.c tracing/core: use appropriate waiting on trace_pipe 2009-02-18 01:40:20 +01:00
trace_sched_wakeup.c tracing/core: use appropriate waiting on trace_pipe 2009-02-18 01:40:20 +01:00
trace_selftest_dynamic.c ftrace: fix dynamic ftrace selftest 2008-05-23 21:13:23 +02:00
trace_selftest.c Merge branches 'tracing/blktrace', 'tracing/ftrace' and 'tracing/urgent' into tracing/core 2009-02-19 10:20:17 +01:00
trace_stack.c trace: better use of stack_trace_enabled for boot up code 2008-12-18 12:56:56 +01:00
trace_stat.c tracing: fix typing mistake in hint message and comments 2009-02-17 12:38:24 -05:00
trace_stat.h tracing/ftrace: separate events tracing and stats tracing engine 2009-01-14 12:11:37 +01:00
trace_sysprof.c tracing: fix typing mistake in hint message and comments 2009-02-17 12:38:24 -05:00
trace_workqueue.c trace_workqueue: use percpu data for workqueue stat 2009-01-20 13:06:59 +01:00
trace.c tracing: add interface to write into current tracer buffer 2009-02-28 03:06:44 -05:00
trace.h tracing: add raw fast tracing interface for trace events 2009-02-28 04:04:03 -05:00