perf: Set sample_period
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 13 May 2016 15:42:20 +0000 (11:42 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jun 2016 15:48:35 +0000 (11:48 -0400)
Newer versions of perf need the sample_period.  Without it, all the
percentages in perf report are 0.

The sample period should be how many samples it takes to trigger an event
(e.g. overflow IRQ on a perf counter).  Perhaps we should always have been
saying at least sample_period = 1 (i.e. an event notif for every event).

We don't keep track of the actual period from perf's invocation.  We could
if we wanted to, but since percentages are relative, it's not a big deal at
this point.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/profile/perf/perf_format.h
tools/profile/perf/perfconv.c

index 474cd61..c34ea5e 100644 (file)
@@ -511,10 +511,10 @@ struct perf_record_comm {
 } __attribute__((packed));
 
 /* For type PERF_RECORD_SAMPLE
- * Configured with: PERF_SAMPLE_IP | PERF_SAMPLE_TID && PERF_SAMPLE_TIME &&
- * PERF_SAMPLE_ADDR && PERF_SAMPLE_ID && PERF_SAMPLE_CPU &&
- * PERF_SAMPLE_CALLCHAIN.
- */
+ *
+ * Configured with: PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME |
+ * PERF_SAMPLE_ADDR | PERF_SAMPLE_ID | PERF_SAMPLE_CPU |
+ * PERF_SAMPLE_CALLCHAIN. */
 struct perf_record_sample {
        struct perf_event_header header;
        uint64_t ip;
index bcd3f69..7453a2b 100644 (file)
@@ -300,10 +300,13 @@ static void add_default_attribute(struct mem_file *amf, struct mem_file *mmf,
        attr.config = config;
        attr.mmap = 1;
        attr.comm = 1;
+       /* We don't know the actual sample_period at this point, but the perf report
+        * percentages are all relative. */
+       attr.sample_period = 1;
+       /* Closely coupled with struct perf_record_sample */
        attr.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME |
-               PERF_SAMPLE_ADDR | PERF_SAMPLE_ID | PERF_SAMPLE_CPU |
-               PERF_SAMPLE_CALLCHAIN;
-
+                          PERF_SAMPLE_ADDR | PERF_SAMPLE_ID | PERF_SAMPLE_CPU |
+                          PERF_SAMPLE_CALLCHAIN;
        add_attribute(amf, mmf, &attr, &id, 1);
 }