Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338976
b: refs/heads/master
c: 494d70a
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Nov 8, 2012
1 parent e29cb78 commit 5705490
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 95529be47855be6350dfd0b9cd09ea863ca7421f
refs/heads/master: 494d70a18137d18f0728fab7ad4f56aba29d1982
60 changes: 60 additions & 0 deletions trunk/tools/perf/util/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,42 @@ void hists__inc_nr_events(struct hists *hists, u32 type)
++hists->stats.nr_events[type];
}

static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
struct hist_entry *pair)
{
struct rb_node **p = &hists->entries.rb_node;
struct rb_node *parent = NULL;
struct hist_entry *he;
int cmp;

while (*p != NULL) {
parent = *p;
he = rb_entry(parent, struct hist_entry, rb_node);

cmp = hist_entry__cmp(pair, he);

if (!cmp)
goto out;

if (cmp < 0)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}

he = hist_entry__new(pair);
if (he) {
he->stat.nr_events = 0;
he->stat.period = 0;
he->hists = hists;
rb_link_node(&he->rb_node, parent, p);
rb_insert_color(&he->rb_node, &hists->entries);
hists__inc_nr_entries(hists, he);
}
out:
return he;
}

static struct hist_entry *hists__find_entry(struct hists *hists,
struct hist_entry *he)
{
Expand Down Expand Up @@ -753,3 +789,27 @@ void hists__match(struct hists *leader, struct hists *other)
hist__entry_add_pair(pos, pair);
}
}

/*
* Look for entries in the other hists that are not present in the leader, if
* we find them, just add a dummy entry on the leader hists, with period=0,
* nr_events=0, to serve as the list header.
*/
int hists__link(struct hists *leader, struct hists *other)
{
struct rb_node *nd;
struct hist_entry *pos, *pair;

for (nd = rb_first(&other->entries); nd; nd = rb_next(nd)) {
pos = rb_entry(nd, struct hist_entry, rb_node);

if (!hist_entry__has_pairs(pos)) {
pair = hists__add_dummy_entry(leader, pos);
if (pair == NULL)
return -1;
hist__entry_add_pair(pair, pos);
}
}

return 0;
}
1 change: 1 addition & 0 deletions trunk/tools/perf/util/hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ void hists__reset_col_len(struct hists *hists);
void hists__calc_col_len(struct hists *hists, struct hist_entry *he);

void hists__match(struct hists *leader, struct hists *other);
int hists__link(struct hists *leader, struct hists *other);

struct perf_hpp {
char *buf;
Expand Down

0 comments on commit 5705490

Please sign in to comment.