aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-03-22 09:37:26 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-03-22 14:12:09 -0400
commit4bf9ce1b5ecffffeb8b9d7e925bac3e6b10109aa (patch)
tree6405f45496261cbc233d8b4c1870bb05c647d966 /tools/perf/util
parent5d7be90ed5cfb5dd3c9ab726d7daa91b86b81747 (diff)
perf diff: Fix to work with new hists design
The perf diff command is broken since: perf hists: Threaded addition and sorting of entries commit 1980c2ebd7020d82c024b8c4046849b38e78e7da Several places were broken: - hists data need to be collected into opened sessions instead of into events - session's hists data need to be initialized properly when the session is created - hist_entry__pcnt_snprintf: the percentage and displacement buffer preparation must not use 'ret' because it's used as a pointer to the final buffer Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20120322133726.GB1601@m.brq.redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/evsel.h2
-rw-r--r--tools/perf/util/hist.c8
-rw-r--r--tools/perf/util/session.c1
4 files changed, 8 insertions, 5 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 0221700075c5..d9da62a7234f 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -34,7 +34,7 @@ int __perf_evsel__sample_size(u64 sample_type)
34 return size; 34 return size;
35} 35}
36 36
37static void hists__init(struct hists *hists) 37void hists__init(struct hists *hists)
38{ 38{
39 memset(hists, 0, sizeof(*hists)); 39 memset(hists, 0, sizeof(*hists));
40 hists->entries_in_array[0] = hists->entries_in_array[1] = RB_ROOT; 40 hists->entries_in_array[0] = hists->entries_in_array[1] = RB_ROOT;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 3158ca3d69a1..3d6b3e4cb66b 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -170,4 +170,6 @@ static inline int perf_evsel__sample_size(struct perf_evsel *evsel)
170 return __perf_evsel__sample_size(evsel->attr.sample_type); 170 return __perf_evsel__sample_size(evsel->attr.sample_type);
171} 171}
172 172
173void hists__init(struct hists *hists);
174
173#endif /* __PERF_EVSEL_H */ 175#endif /* __PERF_EVSEL_H */
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 5fb19013ca0c..c61235f81260 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -891,9 +891,9 @@ static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s,
891 diff = new_percent - old_percent; 891 diff = new_percent - old_percent;
892 892
893 if (fabs(diff) >= 0.01) 893 if (fabs(diff) >= 0.01)
894 ret += scnprintf(bf, sizeof(bf), "%+4.2F%%", diff); 894 scnprintf(bf, sizeof(bf), "%+4.2F%%", diff);
895 else 895 else
896 ret += scnprintf(bf, sizeof(bf), " "); 896 scnprintf(bf, sizeof(bf), " ");
897 897
898 if (sep) 898 if (sep)
899 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf); 899 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf);
@@ -902,9 +902,9 @@ static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s,
902 902
903 if (show_displacement) { 903 if (show_displacement) {
904 if (displacement) 904 if (displacement)
905 ret += scnprintf(bf, sizeof(bf), "%+4ld", displacement); 905 scnprintf(bf, sizeof(bf), "%+4ld", displacement);
906 else 906 else
907 ret += scnprintf(bf, sizeof(bf), " "); 907 scnprintf(bf, sizeof(bf), " ");
908 908
909 if (sep) 909 if (sep)
910 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf); 910 ret += scnprintf(s + ret, size - ret, "%c%s", *sep, bf);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 002ebbf59f48..9412e3b05f68 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -140,6 +140,7 @@ struct perf_session *perf_session__new(const char *filename, int mode,
140 INIT_LIST_HEAD(&self->ordered_samples.sample_cache); 140 INIT_LIST_HEAD(&self->ordered_samples.sample_cache);
141 INIT_LIST_HEAD(&self->ordered_samples.to_free); 141 INIT_LIST_HEAD(&self->ordered_samples.to_free);
142 machine__init(&self->host_machine, "", HOST_KERNEL_ID); 142 machine__init(&self->host_machine, "", HOST_KERNEL_ID);
143 hists__init(&self->hists);
143 144
144 if (mode == O_RDONLY) { 145 if (mode == O_RDONLY) {
145 if (perf_session__open(self, force) < 0) 146 if (perf_session__open(self, force) < 0)