Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 156630
b: refs/heads/master
c: 2544603
h: refs/heads/master
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Aug 9, 2009
1 parent 393aada commit 5571467
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b1a88349c37624755b28ac3b3152b48f52c1f487
refs/heads/master: 25446036cbfc2c89faacdb4fb4603943d2197dc6
47 changes: 44 additions & 3 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,21 @@ ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain, int depth,
return ret;
}

static struct symbol *rem_sq_bracket;
static struct callchain_list rem_hits;

static void init_rem_hits(void)
{
rem_sq_bracket = malloc(sizeof(*rem_sq_bracket) + 6);
if (!rem_sq_bracket) {
fprintf(stderr, "Not enough memory to display remaining hits\n");
return;
}

strcpy(rem_sq_bracket->name, "[...]");
rem_hits.sym = rem_sq_bracket;
}

static size_t
callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
u64 total_samples, int depth, int depth_mask)
Expand All @@ -900,6 +915,7 @@ callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
struct callchain_list *chain;
int new_depth_mask = depth_mask;
u64 new_total;
u64 remaining;
size_t ret = 0;
int i;

Expand All @@ -908,17 +924,25 @@ callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
else
new_total = total_samples;

remaining = new_total;

node = rb_first(&self->rb_root);
while (node) {
u64 cumul;

child = rb_entry(node, struct callchain_node, rb_node);
cumul = cumul_hits(child);
remaining -= cumul;

/*
* The depth mask manages the output of pipes that show
* the depth. We don't want to keep the pipes of the current
* level for the last child of this depth
* level for the last child of this depth.
* Except if we have remaining filtered hits. They will
* supersede the last child
*/
next = rb_next(node);
if (!next)
if (!next && (callchain_param.mode != CHAIN_GRAPH_REL || !remaining))
new_depth_mask &= ~(1 << (depth - 1));

/*
Expand All @@ -933,14 +957,27 @@ callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
ret += ipchain__fprintf_graph(fp, chain, depth,
new_depth_mask, i++,
new_total,
cumul_hits(child));
cumul);
}
ret += callchain__fprintf_graph(fp, child, new_total,
depth + 1,
new_depth_mask | (1 << depth));
node = next;
}

if (callchain_param.mode == CHAIN_GRAPH_REL &&
remaining && remaining != new_total) {

if (!rem_sq_bracket)
return ret;

new_depth_mask &= ~(1 << (depth - 1));

ret += ipchain__fprintf_graph(fp, &rem_hits, depth,
new_depth_mask, 0, new_total,
remaining);
}

return ret;
}

Expand Down Expand Up @@ -1361,6 +1398,8 @@ static size_t output__fprintf(FILE *fp, u64 total_samples)
unsigned int width;
char *col_width = col_width_list_str;

init_rem_hits();

fprintf(fp, "# Samples: %Ld\n", (u64)total_samples);
fprintf(fp, "#\n");

Expand Down Expand Up @@ -1432,6 +1471,8 @@ static size_t output__fprintf(FILE *fp, u64 total_samples)
}
fprintf(fp, "\n");

free(rem_sq_bracket);

return ret;
}

Expand Down

0 comments on commit 5571467

Please sign in to comment.