aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2016-12-05 22:40:02 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-12-07 10:00:33 -0500
commit571f1eb9b967a52732d2e1f41f1b62e27c900325 (patch)
tree05b780fa0ef975f55c1695a14f3631215e4d59f2
parent6fa94258ce2673adc707b2ec5668464f2cf83ed3 (diff)
perf callchain: Introduce callchain_cursor__copy()
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 <namhyung@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Minchan Kim <minchan@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20161206034010.6499-3-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/callchain.c27
-rw-r--r--tools/perf/util/callchain.h3
2 files changed, 30 insertions, 0 deletions
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 823befd8209a..42922512c1c6 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -1234,3 +1234,30 @@ out:
1234 } 1234 }
1235 return -ENOMEM; 1235 return -ENOMEM;
1236} 1236}
1237
1238int callchain_cursor__copy(struct callchain_cursor *dst,
1239 struct callchain_cursor *src)
1240{
1241 int rc = 0;
1242
1243 callchain_cursor_reset(dst);
1244 callchain_cursor_commit(src);
1245
1246 while (true) {
1247 struct callchain_cursor_node *node;
1248
1249 node = callchain_cursor_current(src);
1250 if (node == NULL)
1251 break;
1252
1253 rc = callchain_cursor_append(dst, node->ip, node->map, node->sym,
1254 node->branch, &node->branch_flags,
1255 node->nr_loop_iter, node->samples);
1256 if (rc)
1257 break;
1258
1259 callchain_cursor_advance(src);
1260 }
1261
1262 return rc;
1263}
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index d9c70dccf06a..35c8e379530f 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -216,6 +216,9 @@ static inline void callchain_cursor_advance(struct callchain_cursor *cursor)
216 cursor->pos++; 216 cursor->pos++;
217} 217}
218 218
219int callchain_cursor__copy(struct callchain_cursor *dst,
220 struct callchain_cursor *src);
221
219struct option; 222struct option;
220struct hist_entry; 223struct hist_entry;
221 224