From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932906AbcLGS1d (ORCPT ); Wed, 7 Dec 2016 13:27:33 -0500 Received: from terminus.zytor.com ([198.137.202.10]:53816 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932226AbcLGS1b (ORCPT ); Wed, 7 Dec 2016 13:27:31 -0500 Date: Wed, 7 Dec 2016 10:25:07 -0800 From: tip-bot for Namhyung Kim Message-ID: Cc: minchan@kernel.org, peterz@infradead.org, acme@redhat.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, andi@firstfloor.org, dsahern@gmail.com, jolsa@kernel.org, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org Reply-To: linux-kernel@vger.kernel.org, acme@redhat.com, peterz@infradead.org, minchan@kernel.org, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, jolsa@kernel.org, dsahern@gmail.com, andi@firstfloor.org, namhyung@kernel.org In-Reply-To: <20161206034010.6499-3-namhyung@kernel.org> References: <20161206034010.6499-3-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf callchain: Introduce callchain_cursor__copy() Git-Commit-ID: 571f1eb9b967a52732d2e1f41f1b62e27c900325 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 571f1eb9b967a52732d2e1f41f1b62e27c900325 Gitweb: http://git.kernel.org/tip/571f1eb9b967a52732d2e1f41f1b62e27c900325 Author: Namhyung Kim AuthorDate: Tue, 6 Dec 2016 12:40:02 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 7 Dec 2016 12:00:33 -0300 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 Cc: Andi Kleen Cc: David Ahern Cc: Jiri Olsa Cc: Minchan Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20161206034010.6499-3-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/callchain.c | 27 +++++++++++++++++++++++++++ tools/perf/util/callchain.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 823befd..4292251 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -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; +} diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index d9c70dc..35c8e37 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) cursor->pos++; } +int callchain_cursor__copy(struct callchain_cursor *dst, + struct callchain_cursor *src); + struct option; struct hist_entry;