diff --git a/cmds/dump.c b/cmds/dump.c index 74719f11e..89733d400 100644 --- a/cmds/dump.c +++ b/cmds/dump.c @@ -1258,8 +1258,9 @@ static void print_graph_to_graphviz(struct uftrace_graph_node *node, struct uftr { struct uftrace_graph_node *child; unsigned long n_calls = node->nr_calls; + bool skip = node->skip; - if (n_calls) { + if (n_calls && !skip) { struct uftrace_graph_node *parent = node->parent; pr_out(" "); diff --git a/utils/graph.c b/utils/graph.c index 115eaed6b..c9afe497a 100644 --- a/utils/graph.c +++ b/utils/graph.c @@ -61,8 +61,11 @@ static int add_graph_entry(struct uftrace_task_graph *tg, char *name, size_t nod { struct uftrace_graph_node *node = NULL; struct uftrace_graph_node *curr = tg->node; + struct uftrace_graph_node *recursive_src = NULL; + struct uftrace_graph_node *add_calls_tgt = NULL; struct uftrace_fstack *fstack; static uint32_t next_id = 1; + static bool skip = false; if (tg->lost) return 1; /* ignore kernel functions after LOST */ @@ -77,6 +80,18 @@ static int add_graph_entry(struct uftrace_task_graph *tg, char *name, size_t nod if (curr == NULL || fstack == NULL) return -1; + if (name) { + if (curr && curr->parent) { + skip = !strcmp(name, curr->name) && !strcmp(name, curr->parent->name); + } + + while (curr && !strcmp(name, curr->name)) { + recursive_src = curr; + curr = curr->parent; + } + } + + curr = tg->node; list_for_each_entry(node, &curr->head, list) { if (name && !strcmp(name, node->name)) break; @@ -91,6 +106,7 @@ static int add_graph_entry(struct uftrace_task_graph *tg, char *name, size_t nod node->id = next_id++; node->addr = fstack->addr; node->name = xstrdup(name ?: "none"); + node->skip = skip; INIT_LIST_HEAD(&node->head); node->parent = curr; @@ -128,6 +144,13 @@ static int add_graph_entry(struct uftrace_task_graph *tg, char *name, size_t nod out: node->nr_calls++; + if (skip) { + list_for_each_entry(add_calls_tgt, &recursive_src->head, list) { + if (name && !strcmp(name, add_calls_tgt->name)) + break; + } + add_calls_tgt->nr_calls++; + } tg->node = node; if (entry_cb) diff --git a/utils/graph.h b/utils/graph.h index 598f36b3d..ef6ef46ba 100644 --- a/utils/graph.h +++ b/utils/graph.h @@ -17,6 +17,7 @@ struct uftrace_graph_node { uint64_t time; uint64_t child_time; uint32_t id; + bool skip; struct list_head head; struct list_head list; struct uftrace_graph_node *parent;