Skip to content

Commit

Permalink
perf callchain: Introduce callchain_cursor__copy()
Browse files Browse the repository at this point in the history
The callchain_cursor__copy() function is to save current callchain
captured by a cursor.  It'll be used to keep callchains when switching
to idle task for each cpu.

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
namhyung authored and acmel committed Dec 7, 2016
1 parent 6fa9425 commit 571f1eb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tools/perf/util/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,3 +1234,30 @@ int callchain_node__make_parent_list(struct callchain_node *node)
}
return -ENOMEM;
}

int callchain_cursor__copy(struct callchain_cursor *dst,
struct callchain_cursor *src)
{
int rc = 0;

callchain_cursor_reset(dst);
callchain_cursor_commit(src);

while (true) {
struct callchain_cursor_node *node;

node = callchain_cursor_current(src);
if (node == NULL)
break;

rc = callchain_cursor_append(dst, node->ip, node->map, node->sym,
node->branch, &node->branch_flags,
node->nr_loop_iter, node->samples);
if (rc)
break;

callchain_cursor_advance(src);
}

return rc;
}
3 changes: 3 additions & 0 deletions tools/perf/util/callchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ static inline void callchain_cursor_advance(struct callchain_cursor *cursor)
cursor->pos++;
}

int callchain_cursor__copy(struct callchain_cursor *dst,
struct callchain_cursor *src);

struct option;
struct hist_entry;

Expand Down

0 comments on commit 571f1eb

Please sign in to comment.