History

perf: Update perf_event_type documentation

Due to a discussion with Adrian I had a good look at the perf_event_type record layout and found the documentation to be somewhat unclear.

Peter Zijlstra committed 13 years ago

Commit a5cdd401 parent 17f41572 files · +33 −16Browse files

Unified · Split

2 files
  1. include/uapi/linux/perf_event.h +17 −1
  2. kernel/events/core.c +16 −15
include/uapi/linux/perf_event.h+17−1
@@ -478,6 +478,16 @@ enum perf_event_type { · 477 unmodified lines
478478 * file will be supported by older perf tools, with these new optional
479479 * fields being ignored.
480480 *
481+ * struct sample_id {
482+ * { u32 pid, tid; } && PERF_SAMPLE_TID
483+ * { u64 time; } && PERF_SAMPLE_TIME
484+ * { u64 id; } && PERF_SAMPLE_ID
485+ * { u64 stream_id;} && PERF_SAMPLE_STREAM_ID
486+ * { u32 cpu, res; } && PERF_SAMPLE_CPU
487+ * } && perf_event_attr::sample_id_all
488+ */
489+
490+ /*
481491 * The MMAP events record the PROT_EXEC mappings so that we can
482492 * correlate userspace IPs to code. They have the following structure:
483493 *
@@ -498,6 +508,7 @@ enum perf_event_type { · 14 unmodified lines
498508 * struct perf_event_header header;
499509 * u64 id;
500510 * u64 lost;
511+ * struct sample_id sample_id;
501512 * };
502513 */
503514 PERF_RECORD_LOST = 2,
@@ -508,6 +519,7 @@ enum perf_event_type { · 4 unmodified lines
508519 *
509520 * u32 pid, tid;
510521 * char comm[];
522+ * struct sample_id sample_id;
511523 * };
512524 */
513525 PERF_RECORD_COMM = 3,
@@ -518,6 +530,7 @@ enum perf_event_type { · 4 unmodified lines
518530 * u32 pid, ppid;
519531 * u32 tid, ptid;
520532 * u64 time;
533+ * struct sample_id sample_id;
521534 * };
522535 */
523536 PERF_RECORD_EXIT = 4,
@@ -528,6 +541,7 @@ enum perf_event_type { · 4 unmodified lines
528541 * u64 time;
529542 * u64 id;
530543 * u64 stream_id;
544+ * struct sample_id sample_id;
531545 * };
532546 */
533547 PERF_RECORD_THROTTLE = 5,
@@ -539,6 +553,7 @@ enum perf_event_type { · 5 unmodified lines
539553 * u32 pid, ppid;
540554 * u32 tid, ptid;
541555 * u64 time;
556+ * struct sample_id sample_id;
542557 * };
543558 */
544559 PERF_RECORD_FORK = 7,
@@ -549,6 +564,7 @@ enum perf_event_type { · 4 unmodified lines
549564 * u32 pid, tid;
550565 *
551566 * struct read_format values;
567+ * struct sample_id sample_id;
552568 * };
553569 */
554570 PERF_RECORD_READ = 8,
@@ -596,7 +612,7 @@ enum perf_event_type { · 41 unmodified lines
596612 * u64 dyn_size; } && PERF_SAMPLE_STACK_USER
597613 *
598614 * { u64 weight; } && PERF_SAMPLE_WEIGHT
599− * { u64 data_src; } && PERF_SAMPLE_DATA_SRC
615+ * { u64 data_src; } && PERF_SAMPLE_DATA_SRC
600616 * };
601617 */
602618 PERF_RECORD_SAMPLE = 9,
kernel/events/core.c+16−15
@@ -4462,20 +4462,6 @@ void perf_output_sample(struct perf_output_handle *handle, · 4461 unmodified lines
44624462 }
44634463 }
44644464
4465− if (!event->attr.watermark) {
4466− int wakeup_events = event->attr.wakeup_events;
4467−
4468− if (wakeup_events) {
4469− struct ring_buffer *rb = handle->rb;
4470− int events = local_inc_return(&rb->events);
4471−
4472− if (events >= wakeup_events) {
4473− local_sub(wakeup_events, &rb->events);
4474− local_inc(&rb->wakeup);
4475− }
4476− }
4477− }
4478−
44794465 if (sample_type & PERF_SAMPLE_BRANCH_STACK) {
44804466 if (data->br_stack) {
44814467 size_t size;
@@ -4511,16 +4497,31 @@ void perf_output_sample(struct perf_output_handle *handle, · 29 unmodified lines
45114497 }
45124498 }
45134499
4514− if (sample_type & PERF_SAMPLE_STACK_USER)
4500+ if (sample_type & PERF_SAMPLE_STACK_USER) {
45154501 perf_output_sample_ustack(handle,
45164502 data->stack_user_size,
45174503 data->regs_user.regs);
4504+ }
45184505
45194506 if (sample_type & PERF_SAMPLE_WEIGHT)
45204507 perf_output_put(handle, data->weight);
45214508
45224509 if (sample_type & PERF_SAMPLE_DATA_SRC)
45234510 perf_output_put(handle, data->data_src.val);
4511+
4512+ if (!event->attr.watermark) {
4513+ int wakeup_events = event->attr.wakeup_events;
4514+
4515+ if (wakeup_events) {
4516+ struct ring_buffer *rb = handle->rb;
4517+ int events = local_inc_return(&rb->events);
4518+
4519+ if (events >= wakeup_events) {
4520+ local_sub(wakeup_events, &rb->events);
4521+ local_inc(&rb->wakeup);
4522+ }
4523+ }
4524+ }
45244525 }
45254526
45264527 void perf_prepare_sample(struct perf_event_header *header,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t