Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1271294

[PATCH 1/3] perf tools: Move initial entry call into get_entries function

From Jiri Olsa <jolsa@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 1/3] perf tools: Move initial entry call into get_entries function
Date 2015-11-17 16:10 +0100
Message-ID <qvQ3o-6Fs-13@gated-at.bofh.it> (permalink)
References <qvQ3o-6Fs-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Moving initial entry call into get_entries function
so all entries processing is on one place. It will
be useful for next change that adds ordering logic.

Link: http://lkml.kernel.org/n/tip-p8wsesmi0y1abyik381pl32j@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/util/unwind-libunwind.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index c83832b555e5..0ae8844fe7a6 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -614,10 +614,22 @@ void unwind__finish_access(struct thread *thread)
 static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
 		       void *arg, int max_stack)
 {
+	u64 val;
 	unw_addr_space_t addr_space;
 	unw_cursor_t c;
 	int ret;
 
+	ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP);
+	if (ret)
+		return ret;
+
+	ret = entry(val, ui->thread, cb, arg);
+	if (ret)
+		return -ENOMEM;
+
+	if (--max_stack == 0)
+		return 0;
+
 	addr_space = thread__priv(ui->thread);
 	if (addr_space == NULL)
 		return -1;
@@ -640,24 +652,17 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 			struct thread *thread,
 			struct perf_sample *data, int max_stack)
 {
-	u64 ip;
 	struct unwind_info ui = {
 		.sample       = data,
 		.thread       = thread,
 		.machine      = thread->mg->machine,
 	};
-	int ret;
 
 	if (!data->user_regs.regs)
 		return -EINVAL;
 
-	ret = perf_reg_value(&ip, &data->user_regs, PERF_REG_IP);
-	if (ret)
-		return ret;
-
-	ret = entry(ip, thread, cb, arg);
-	if (ret)
-		return -ENOMEM;
+	if (max_stack <= 0)
+		return -EINVAL;
 
-	return --max_stack > 0 ? get_entries(&ui, cb, arg, max_stack) : 0;
+	return get_entries(&ui, cb, arg, max_stack);
 }
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] perf tools: Move initial entry call into get_entries function Jiri Olsa <jolsa@kernel.org> - 2015-11-17 16:10 +0100
  [tip:perf/core] perf callchain:   Move initial entry call into get_entries function tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-26 09:20 +0100

csiph-web