aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2013-08-27 04:23:07 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-08-29 14:40:03 -0400
commitff3d527cebc1fa3707c617bfe9e74f53fcfb0955 (patch)
tree64181865fd8b48a2ea99d11724e79844c193b5cf /include
parentef89325f773bc9f2f4e6019bd7f3d968ba85df9a (diff)
perf: make events stream always parsable
The event stream is not always parsable because the format of a sample is dependent on the sample_type of the selected event. When there is more than one selected event and the sample_types are not the same then parsing becomes problematic. A sample can be matched to its selected event using the ID that is allocated when the event is opened. Unfortunately, to get the ID from the sample means first parsing it. This patch adds a new sample format bit PERF_SAMPLE_IDENTIFER that puts the ID at a fixed position so that the ID can be retrieved without parsing the sample. For sample events, that is the first position immediately after the header. For non-sample events, that is the last position. In this respect parsing samples requires that the sample_type and ID values are recorded. For example, perf tools records struct perf_event_attr and the IDs within the perf.data file. Those must be read first before it is possible to parse samples found later in the perf.data file. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Tested-by: Stephane Eranian <eranian@google.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1377591794-30553-6-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/uapi/linux/perf_event.h27
1 files changed, 20 insertions, 7 deletions
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 62c25a25291c..42cb7b62ca59 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -134,8 +134,9 @@ enum perf_event_sample_format {
134 PERF_SAMPLE_STACK_USER = 1U << 13, 134 PERF_SAMPLE_STACK_USER = 1U << 13,
135 PERF_SAMPLE_WEIGHT = 1U << 14, 135 PERF_SAMPLE_WEIGHT = 1U << 14,
136 PERF_SAMPLE_DATA_SRC = 1U << 15, 136 PERF_SAMPLE_DATA_SRC = 1U << 15,
137 PERF_SAMPLE_IDENTIFIER = 1U << 16,
137 138
138 PERF_SAMPLE_MAX = 1U << 16, /* non-ABI */ 139 PERF_SAMPLE_MAX = 1U << 17, /* non-ABI */
139}; 140};
140 141
141/* 142/*
@@ -492,12 +493,12 @@ enum perf_event_type {
492 /* 493 /*
493 * If perf_event_attr.sample_id_all is set then all event types will 494 * If perf_event_attr.sample_id_all is set then all event types will
494 * have the sample_type selected fields related to where/when 495 * have the sample_type selected fields related to where/when
495 * (identity) an event took place (TID, TIME, ID, CPU, STREAM_ID) 496 * (identity) an event took place (TID, TIME, ID, STREAM_ID, CPU,
496 * described in PERF_RECORD_SAMPLE below, it will be stashed just after 497 * IDENTIFIER) described in PERF_RECORD_SAMPLE below, it will be stashed
497 * the perf_event_header and the fields already present for the existing 498 * just after the perf_event_header and the fields already present for
498 * fields, i.e. at the end of the payload. That way a newer perf.data 499 * the existing fields, i.e. at the end of the payload. That way a newer
499 * file will be supported by older perf tools, with these new optional 500 * perf.data file will be supported by older perf tools, with these new
500 * fields being ignored. 501 * optional fields being ignored.
501 * 502 *
502 * struct sample_id { 503 * struct sample_id {
503 * { u32 pid, tid; } && PERF_SAMPLE_TID 504 * { u32 pid, tid; } && PERF_SAMPLE_TID
@@ -505,7 +506,12 @@ enum perf_event_type {
505 * { u64 id; } && PERF_SAMPLE_ID 506 * { u64 id; } && PERF_SAMPLE_ID
506 * { u64 stream_id;} && PERF_SAMPLE_STREAM_ID 507 * { u64 stream_id;} && PERF_SAMPLE_STREAM_ID
507 * { u32 cpu, res; } && PERF_SAMPLE_CPU 508 * { u32 cpu, res; } && PERF_SAMPLE_CPU
509 * { u64 id; } && PERF_SAMPLE_IDENTIFIER
508 * } && perf_event_attr::sample_id_all 510 * } && perf_event_attr::sample_id_all
511 *
512 * Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID. The
513 * advantage of PERF_SAMPLE_IDENTIFIER is that its position is fixed
514 * relative to header.size.
509 */ 515 */
510 516
511 /* 517 /*
@@ -594,6 +600,13 @@ enum perf_event_type {
594 * struct { 600 * struct {
595 * struct perf_event_header header; 601 * struct perf_event_header header;
596 * 602 *
603 * #
604 * # Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID.
605 * # The advantage of PERF_SAMPLE_IDENTIFIER is that its position
606 * # is fixed relative to header.
607 * #
608 *
609 * { u64 id; } && PERF_SAMPLE_IDENTIFIER
597 * { u64 ip; } && PERF_SAMPLE_IP 610 * { u64 ip; } && PERF_SAMPLE_IP
598 * { u32 pid, tid; } && PERF_SAMPLE_TID 611 * { u32 pid, tid; } && PERF_SAMPLE_TID
599 * { u64 time; } && PERF_SAMPLE_TIME 612 * { u64 time; } && PERF_SAMPLE_TIME