Commit ea1900e571d40a3ce60c835c2f21e1fd8c5cb663

Authored by Peter Zijlstra
Committed by Ingo Molnar
1 parent 66fff22483

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>

Showing 2 changed files with 13 additions and 8 deletions Side-by-side Diff

tools/perf/builtin-record.c
... ... @@ -350,8 +350,9 @@
350 350 struct perf_counter_attr *attr = attrs + counter;
351 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 354 if (freq) {
  355 + attr->sample_type |= PERF_SAMPLE_PERIOD;
355 356 attr->freq = 1;
356 357 attr->sample_freq = freq;
357 358 }
tools/perf/builtin-report.c
... ... @@ -456,7 +456,7 @@
456 456 uint64_t ip;
457 457 char level;
458 458  
459   - uint32_t count;
  459 + uint64_t count;
460 460 };
461 461  
462 462 /*
... ... @@ -726,7 +726,7 @@
726 726  
727 727 static int
728 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 731 struct rb_node **p = &hist.rb_node;
732 732 struct rb_node *parent = NULL;
... ... @@ -738,7 +738,7 @@
738 738 .sym = sym,
739 739 .ip = ip,
740 740 .level = level,
741   - .count = 1,
  741 + .count = count,
742 742 };
743 743 int cmp;
744 744  
... ... @@ -749,7 +749,7 @@
749 749 cmp = hist_entry__cmp(&entry, he);
750 750  
751 751 if (!cmp) {
752   - he->count++;
  752 + he->count += count;
753 753 return 0;
754 754 }
755 755  
756 756  
757 757  
... ... @@ -942,15 +942,19 @@
942 942 struct dso *dso = NULL;
943 943 struct thread *thread = threads__findnew(event->ip.pid);
944 944 uint64_t ip = event->ip.ip;
  945 + uint64_t period = 1;
945 946 struct map *map = NULL;
946 947  
  948 + if (event->header.type & PERF_SAMPLE_PERIOD)
  949 + period = event->ip.period;
  950 +
947 951 dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p period: %Ld\n",
948 952 (void *)(offset + head),
949 953 (void *)(long)(event->header.size),
950 954 event->header.misc,
951 955 event->ip.pid,
952 956 (void *)(long)ip,
953   - (long long)event->ip.period);
  957 + (long long)period);
954 958  
955 959 dprintf(" ... thread: %s:%d\n", thread->comm, thread->pid);
956 960  
957 961  
... ... @@ -1001,13 +1005,13 @@
1001 1005 if (dso)
1002 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 1009 fprintf(stderr,
1006 1010 "problem incrementing symbol count, skipping event\n");
1007 1011 return -1;
1008 1012 }
1009 1013 }
1010   - total++;
  1014 + total += period;
1011 1015  
1012 1016 return 0;
1013 1017 }