diff options
-rw-r--r-- | include/uapi/linux/perf_event.h | 27 | ||||
-rw-r--r-- | kernel/events/core.c | 11 |
2 files changed, 30 insertions, 8 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 |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 928fae7ca8c7..15d0f2418e54 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -1213,6 +1213,9 @@ static void perf_event__id_header_size(struct perf_event *event) | |||
1213 | if (sample_type & PERF_SAMPLE_TIME) | 1213 | if (sample_type & PERF_SAMPLE_TIME) |
1214 | size += sizeof(data->time); | 1214 | size += sizeof(data->time); |
1215 | 1215 | ||
1216 | if (sample_type & PERF_SAMPLE_IDENTIFIER) | ||
1217 | size += sizeof(data->id); | ||
1218 | |||
1216 | if (sample_type & PERF_SAMPLE_ID) | 1219 | if (sample_type & PERF_SAMPLE_ID) |
1217 | size += sizeof(data->id); | 1220 | size += sizeof(data->id); |
1218 | 1221 | ||
@@ -4280,7 +4283,7 @@ static void __perf_event_header__init_id(struct perf_event_header *header, | |||
4280 | if (sample_type & PERF_SAMPLE_TIME) | 4283 | if (sample_type & PERF_SAMPLE_TIME) |
4281 | data->time = perf_clock(); | 4284 | data->time = perf_clock(); |
4282 | 4285 | ||
4283 | if (sample_type & PERF_SAMPLE_ID) | 4286 | if (sample_type & (PERF_SAMPLE_ID | PERF_SAMPLE_IDENTIFIER)) |
4284 | data->id = primary_event_id(event); | 4287 | data->id = primary_event_id(event); |
4285 | 4288 | ||
4286 | if (sample_type & PERF_SAMPLE_STREAM_ID) | 4289 | if (sample_type & PERF_SAMPLE_STREAM_ID) |
@@ -4319,6 +4322,9 @@ static void __perf_event__output_id_sample(struct perf_output_handle *handle, | |||
4319 | 4322 | ||
4320 | if (sample_type & PERF_SAMPLE_CPU) | 4323 | if (sample_type & PERF_SAMPLE_CPU) |
4321 | perf_output_put(handle, data->cpu_entry); | 4324 | perf_output_put(handle, data->cpu_entry); |
4325 | |||
4326 | if (sample_type & PERF_SAMPLE_IDENTIFIER) | ||
4327 | perf_output_put(handle, data->id); | ||
4322 | } | 4328 | } |
4323 | 4329 | ||
4324 | void perf_event__output_id_sample(struct perf_event *event, | 4330 | void perf_event__output_id_sample(struct perf_event *event, |
@@ -4432,6 +4438,9 @@ void perf_output_sample(struct perf_output_handle *handle, | |||
4432 | 4438 | ||
4433 | perf_output_put(handle, *header); | 4439 | perf_output_put(handle, *header); |
4434 | 4440 | ||
4441 | if (sample_type & PERF_SAMPLE_IDENTIFIER) | ||
4442 | perf_output_put(handle, data->id); | ||
4443 | |||
4435 | if (sample_type & PERF_SAMPLE_IP) | 4444 | if (sample_type & PERF_SAMPLE_IP) |
4436 | perf_output_put(handle, data->ip); | 4445 | perf_output_put(handle, data->ip); |
4437 | 4446 | ||