aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-11-08 16:03:09 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-11-08 16:08:15 -0500
commit494d70a18137d18f0728fab7ad4f56aba29d1982 (patch)
tree0056cc3dd78a3fcedf47950685a76dbc4218ecae /tools
parent95529be47855be6350dfd0b9cd09ea863ca7421f (diff)
perf hists: Introduce hists__link
That given two hists will find the hist_entries (buckets) in the second hists that are for the same bucket in the first and link them, then it will look for all buckets in the second that don't have a counterpart in the first and will create a dummy counterpart that will then be linked to the entry in the second. For multiple events this will be done pairing the leader with all the other events in the group, so that in the end the leader will have all the buckets in all the hists in a group, dummy or not while the other hists will be left untouched. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-l9l9ieozqdhn9lieokd95okw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/hist.c60
-rw-r--r--tools/perf/util/hist.h1
2 files changed, 61 insertions, 0 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index c1de3b05fe09..7c6e73b1b7ea 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -717,6 +717,42 @@ void hists__inc_nr_events(struct hists *hists, u32 type)
717 ++hists->stats.nr_events[type]; 717 ++hists->stats.nr_events[type];
718} 718}
719 719
720static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
721 struct hist_entry *pair)
722{
723 struct rb_node **p = &hists->entries.rb_node;
724 struct rb_node *parent = NULL;
725 struct hist_entry *he;
726 int cmp;
727
728 while (*p != NULL) {
729 parent = *p;
730 he = rb_entry(parent, struct hist_entry, rb_node);
731
732 cmp = hist_entry__cmp(pair, he);
733
734 if (!cmp)
735 goto out;
736
737 if (cmp < 0)
738 p = &(*p)->rb_left;
739 else
740 p = &(*p)->rb_right;
741 }
742
743 he = hist_entry__new(pair);
744 if (he) {
745 he->stat.nr_events = 0;
746 he->stat.period = 0;
747 he->hists = hists;
748 rb_link_node(&he->rb_node, parent, p);
749 rb_insert_color(&he->rb_node, &hists->entries);
750 hists__inc_nr_entries(hists, he);
751 }
752out:
753 return he;
754}
755
720static struct hist_entry *hists__find_entry(struct hists *hists, 756static struct hist_entry *hists__find_entry(struct hists *hists,
721 struct hist_entry *he) 757 struct hist_entry *he)
722{ 758{
@@ -753,3 +789,27 @@ void hists__match(struct hists *leader, struct hists *other)
753 hist__entry_add_pair(pos, pair); 789 hist__entry_add_pair(pos, pair);
754 } 790 }
755} 791}
792
793/*
794 * Look for entries in the other hists that are not present in the leader, if
795 * we find them, just add a dummy entry on the leader hists, with period=0,
796 * nr_events=0, to serve as the list header.
797 */
798int hists__link(struct hists *leader, struct hists *other)
799{
800 struct rb_node *nd;
801 struct hist_entry *pos, *pair;
802
803 for (nd = rb_first(&other->entries); nd; nd = rb_next(nd)) {
804 pos = rb_entry(nd, struct hist_entry, rb_node);
805
806 if (!hist_entry__has_pairs(pos)) {
807 pair = hists__add_dummy_entry(leader, pos);
808 if (pair == NULL)
809 return -1;
810 hist__entry_add_pair(pair, pos);
811 }
812 }
813
814 return 0;
815}
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index ff1c3963e04f..1278c2c72a96 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -116,6 +116,7 @@ void hists__reset_col_len(struct hists *hists);
116void hists__calc_col_len(struct hists *hists, struct hist_entry *he); 116void hists__calc_col_len(struct hists *hists, struct hist_entry *he);
117 117
118void hists__match(struct hists *leader, struct hists *other); 118void hists__match(struct hists *leader, struct hists *other);
119int hists__link(struct hists *leader, struct hists *other);
119 120
120struct perf_hpp { 121struct perf_hpp {
121 char *buf; 122 char *buf;