File perf-annotate-store-the-sample-period-in-each-histogram-bucket.patch of Package perf
xxxxxxxxxx
1
From: Taeung Song <treeze.taeung@gmail.com>
2
Date: Thu, 20 Jul 2017 17:18:05 -0300
3
Subject: perf annotate: Store the sample period in each histogram bucket
4
Git-commit: 461c17f00f400f95116880d91d20a7fcd84263a9
5
Patch-mainline: v4.14-rc1
6
References: bsc#1070010 (git-fixes)
7
Signed-off-By: Tony Jones <tonyj@suse.de>
8
9
We'll use it soon, when fixing --show-total-period.
10
11
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
12
Cc: Adrian Hunter <adrian.hunter@intel.com>
13
Cc: David Ahern <dsahern@gmail.com>
14
Cc: Jiri Olsa <jolsa@kernel.org>
15
Cc: Namhyung Kim <namhyung@kernel.org>
16
Cc: Wang Nan <wangnan0@huawei.com>
17
Link: http://lkml.kernel.org/r/1500500215-16646-1-git-send-email-treeze.taeung@gmail.com
18
[ split from a larger patch, do the math in __symbol__inc_addr_samples() ]
19
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
20
---
21
tools/perf/util/annotate.c | 17 ++++++++++++-----
22
tools/perf/util/annotate.h | 1 +
23
2 files changed, 13 insertions(+), 5 deletions(-)
24
25
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
26
index c2fe16d5e473..00e085fc945b 100644
27
--- a/tools/perf/util/annotate.c
28
+++ b/tools/perf/util/annotate.c
29
30
31
static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
32
struct annotation *notes, int evidx, u64 addr,
33
- struct perf_sample *sample __maybe_unused)
34
+ struct perf_sample *sample)
35
{
36
unsigned offset;
37
struct sym_hist *h;
38
39
h = annotation__histogram(notes, evidx);
40
h->nr_samples++;
41
h->addr[offset].nr_samples++;
42
+ h->period += sample->period;
43
+ h->addr[offset].period += sample->period;
44
45
pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64
46
- ", evidx=%d] => %" PRIu64 "\n", sym->start, sym->name,
47
- addr, addr - sym->start, evidx, h->addr[offset].nr_samples);
48
+ ", evidx=%d] => nr_samples: %" PRIu64 ", period: %" PRIu64 "\n",
49
+ sym->start, sym->name, addr, addr - sym->start, evidx,
50
+ h->addr[offset].nr_samples, h->addr[offset].period);
51
return 0;
52
}
53
54
55
struct source_line *src_line = notes->src->lines;
56
double percent = 0.0;
57
58
- sample->nr_samples = 0;
59
+ sample->nr_samples = sample->period = 0;
60
61
if (src_line) {
62
size_t sizeof_src_line = sizeof(*src_line) +
63
64
} else {
65
struct sym_hist *h = annotation__histogram(notes, evidx);
66
unsigned int hits = 0;
67
+ u64 period = 0;
68
69
- while (offset < end)
70
+ while (offset < end) {
71
hits += h->addr[offset++].nr_samples;
72
+ period += h->addr[offset++].period;
73
+ }
74
75
if (h->nr_samples) {
76
+ sample->period = period;
77
sample->nr_samples = hits;
78
percent = 100.0 * hits / h->nr_samples;
79
}
80
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
81
index 720f18195046..9ce575c25fd9 100644
82
--- a/tools/perf/util/annotate.h
83
+++ b/tools/perf/util/annotate.h
84
85
86
struct sym_hist {
87
u64 nr_samples;
88
+ u64 period;
89
struct sym_hist_entry addr[0];
90
};
91
92
93