Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dump: Handle cycles in graphviz #1978

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

deepseafishy
Copy link

These commits include skipping the recursive calls during the dump of graphviz, and correctly adding number of calls of the skipped entries to the initial recursive call.

Fixed: #1500

Identify if the current graph entry must be skipped druing `dump`, which
is done during the add_graph_entry() procedure.

Basic idea is to find recursive calls, but the first recursive call
cannot be skipped. For example, if the call trace shows:

main - fib - fib - fib

then the first (fib - fib) must be present but the second must be
skipped, making the graph look like:

main - fib - fib

To separate recursive calls from the first recursive call, determine
if the node's name is the same with curr and additionally check if
curr->parent's name is the same as well.

Signed-off-by: Daon Park <[email protected]>
If a node is skipped due to being a recursive call, then it's nr_calls
must be correctly appended to the first recursive call. During the
`add_graph_entry()` procedure, it looks for the source of the first
recursive call and saves it to recursive_src. Next, if the current
graph entry node is skipped, then the nr_calls is added to the
add_calls_tgt.

Signed-off-by: Daon Park <[email protected]>
If a node is marked as True in the skip variable, the dump file will
not record that node.

Signed-off-by: Daon Park <[email protected]>
During a search for the source of the recursive call, it must check for
NULL pointers.

This passes the unittest 51 graph_basic.

Signed-off-by: Daon Park <[email protected]>
During a search for the destination node for the nr_calls, it must
check for NULL pointers.

This passes the unittest 52 graph_command.

Signed-off-by: Daon Park <[email protected]>
During the determination of a node skip, it must check for NULL
pointers in the name.

This passes the unittest 105 tui_command.

Signed-off-by: Daon Park <[email protected]>
Copy link
Owner

@namhyung namhyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thanks for your contribution.

First, you don't need to create a new PR for code changes. Just keep the PR and force-push changes to your branch.

Second, Please remove commits to add NULL checks and squash them to the original changes.

Third, I think you modified logic in the general code which will affect other graph codes that might not want to merge recursive calls. If so, you may want to pass an option (or set it globally somewhere) to control the behavior.

@@ -63,6 +63,7 @@ static int add_graph_entry(struct uftrace_task_graph *tg, char *name, size_t nod
struct uftrace_graph_node *curr = tg->node;
struct uftrace_fstack *fstack;
static uint32_t next_id = 1;
static bool skip = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it needs to be 'static'.

if (name) {
if (curr && curr->parent) {
skip = !strcmp(name, curr->name) && !strcmp(name, curr->parent->name);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for curly brackets on a single line statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create a real call graph that can have cycles in --graphviz
2 participants