]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
perf callchain: Introduce callchain_cursor__copy()
authorNamhyung Kim <namhyung@kernel.org>
Tue, 6 Dec 2016 03:40:02 +0000 (12:40 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 7 Dec 2016 15:00:33 +0000 (12:00 -0300)
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>
tools/perf/util/callchain.c
tools/perf/util/callchain.h

index 823befd8209a473b39e9b96965a353fd9b293a69..42922512c1c62fe09eb12f301c281ceb57c2bf3c 100644 (file)
@@ -1234,3 +1234,30 @@ out:
        }
        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;
+}
index d9c70dccf06ad50ca72cc98e22a7b6f8eb42f0c3..35c8e379530f2f1e02d050a25a2ef786ee10a819 100644 (file)
@@ -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;