diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-06-10 15:45:22 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-10 20:39:01 -0400 |
commit | ea1900e571d40a3ce60c835c2f21e1fd8c5cb663 (patch) | |
tree | aca5108ea57e89626e0796f3285985e6a1512f9a /tools/perf | |
parent | 66fff22483d8542dfb4d61a28d21277bbde321e8 (diff) |
perf_counter tools: Normalize data using per sample period data
When we use variable period sampling, add the period to the sample
data and use that to normalize the samples.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-record.c | 3 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 18 |
2 files changed, 13 insertions, 8 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index c10553c3460f..919f23ca4199 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -350,8 +350,9 @@ static void create_counter(int counter, int cpu, pid_t pid) | |||
350 | struct perf_counter_attr *attr = attrs + counter; | 350 | struct perf_counter_attr *attr = attrs + counter; |
351 | int track = 1; | 351 | int track = 1; |
352 | 352 | ||
353 | attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_PERIOD; | 353 | attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID; |
354 | if (freq) { | 354 | if (freq) { |
355 | attr->sample_type |= PERF_SAMPLE_PERIOD; | ||
355 | attr->freq = 1; | 356 | attr->freq = 1; |
356 | attr->sample_freq = freq; | 357 | attr->sample_freq = freq; |
357 | } | 358 | } |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 9a0e31e79e9d..f57fd5c5531a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -456,7 +456,7 @@ struct hist_entry { | |||
456 | uint64_t ip; | 456 | uint64_t ip; |
457 | char level; | 457 | char level; |
458 | 458 | ||
459 | uint32_t count; | 459 | uint64_t count; |
460 | }; | 460 | }; |
461 | 461 | ||
462 | /* | 462 | /* |
@@ -726,7 +726,7 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples) | |||
726 | 726 | ||
727 | static int | 727 | static int |
728 | hist_entry__add(struct thread *thread, struct map *map, struct dso *dso, | 728 | hist_entry__add(struct thread *thread, struct map *map, struct dso *dso, |
729 | struct symbol *sym, uint64_t ip, char level) | 729 | struct symbol *sym, uint64_t ip, char level, uint64_t count) |
730 | { | 730 | { |
731 | struct rb_node **p = &hist.rb_node; | 731 | struct rb_node **p = &hist.rb_node; |
732 | struct rb_node *parent = NULL; | 732 | struct rb_node *parent = NULL; |
@@ -738,7 +738,7 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso, | |||
738 | .sym = sym, | 738 | .sym = sym, |
739 | .ip = ip, | 739 | .ip = ip, |
740 | .level = level, | 740 | .level = level, |
741 | .count = 1, | 741 | .count = count, |
742 | }; | 742 | }; |
743 | int cmp; | 743 | int cmp; |
744 | 744 | ||
@@ -749,7 +749,7 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso, | |||
749 | cmp = hist_entry__cmp(&entry, he); | 749 | cmp = hist_entry__cmp(&entry, he); |
750 | 750 | ||
751 | if (!cmp) { | 751 | if (!cmp) { |
752 | he->count++; | 752 | he->count += count; |
753 | return 0; | 753 | return 0; |
754 | } | 754 | } |
755 | 755 | ||
@@ -942,15 +942,19 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head) | |||
942 | struct dso *dso = NULL; | 942 | struct dso *dso = NULL; |
943 | struct thread *thread = threads__findnew(event->ip.pid); | 943 | struct thread *thread = threads__findnew(event->ip.pid); |
944 | uint64_t ip = event->ip.ip; | 944 | uint64_t ip = event->ip.ip; |
945 | uint64_t period = 1; | ||
945 | struct map *map = NULL; | 946 | struct map *map = NULL; |
946 | 947 | ||
948 | if (event->header.type & PERF_SAMPLE_PERIOD) | ||
949 | period = event->ip.period; | ||
950 | |||
947 | dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p period: %Ld\n", | 951 | dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p period: %Ld\n", |
948 | (void *)(offset + head), | 952 | (void *)(offset + head), |
949 | (void *)(long)(event->header.size), | 953 | (void *)(long)(event->header.size), |
950 | event->header.misc, | 954 | event->header.misc, |
951 | event->ip.pid, | 955 | event->ip.pid, |
952 | (void *)(long)ip, | 956 | (void *)(long)ip, |
953 | (long long)event->ip.period); | 957 | (long long)period); |
954 | 958 | ||
955 | dprintf(" ... thread: %s:%d\n", thread->comm, thread->pid); | 959 | dprintf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
956 | 960 | ||
@@ -1001,13 +1005,13 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head) | |||
1001 | if (dso) | 1005 | if (dso) |
1002 | sym = dso->find_symbol(dso, ip); | 1006 | sym = dso->find_symbol(dso, ip); |
1003 | 1007 | ||
1004 | if (hist_entry__add(thread, map, dso, sym, ip, level)) { | 1008 | if (hist_entry__add(thread, map, dso, sym, ip, level, period)) { |
1005 | fprintf(stderr, | 1009 | fprintf(stderr, |
1006 | "problem incrementing symbol count, skipping event\n"); | 1010 | "problem incrementing symbol count, skipping event\n"); |
1007 | return -1; | 1011 | return -1; |
1008 | } | 1012 | } |
1009 | } | 1013 | } |
1010 | total++; | 1014 | total += period; |
1011 | 1015 | ||
1012 | return 0; | 1016 | return 0; |
1013 | } | 1017 | } |