All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf probe: Fix failure to probe events on arm
@ 2015-06-15  8:06 He Kuang
  2015-06-15 14:49 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 13+ messages in thread
From: He Kuang @ 2015-06-15  8:06 UTC (permalink / raw)
  To: a.p.zijlstra, mingo, acme, masami.hiramatsu.pt, namhyung
  Cc: wangnan0, linux-kernel

Fix failure to probe events on arm, problem is introduced by commit
5a51fcd1f30c ("perf probe: Skip kernel symbols which is out of
.text"). For some architectures, label '_etext' is not in the .text
section(in .notes section for arm/arm64). Label out of .text section is
not loaded as symbols and we got a zero value when look up its address,
which causes all events be wrongly skiped.

This patch uses kernel map->end when failed to get the address of
'_etext' and fixes the problem.

Problem can be reproduced on arm as following:

  # perf probe --add='generic_perform_write'
  generic_perform_write+0 is out of .text, skip it.
  Probe point 'generic_perform_write' not found.
    Error: Failed to add events. Reason: No such file or directory (Code: -2)

After this patch:

  # perf probe --add='generic_perform_write'
  Added new event:
    probe:generic_perform_write (on generic_perform_write)

  You can now use it in all perf tools, such as:

    perf record -e probe:generic_perform_write -aR sleep 1

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/probe-event.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index daa24a2..ee26961 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -575,8 +575,22 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs,
 		pr_warning("Relocated base symbol is not found!\n");
 		return -EINVAL;
 	}
-	/* Get the address of _etext for checking non-probable text symbol */
+	/* Get the address of _etext for checking non-probable text symbol,
+	   for some architectures (e.g. arm, arm64), _etext is out of .text
+	   section and not loaded as symbols, use kernel map->end instead.
+	 */
 	etext_addr = kernel_get_symbol_address_by_name("_etext", false);
+	if (etext_addr == 0) {
+		struct map *map;
+
+		map = kernel_get_module_map(NULL);
+		if (!map) {
+			pr_err("Failed to get a map for kernel\n");
+			return -EINVAL;
+		}
+
+		etext_addr = map->end;
+	}
 
 	for (i = 0; i < ntevs; i++) {
 		if (tevs[i].point.address && !tevs[i].point.retprobe) {
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-06-25  7:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-15  8:06 [PATCH] perf probe: Fix failure to probe events on arm He Kuang
2015-06-15 14:49 ` Arnaldo Carvalho de Melo
2015-06-16  6:05   ` Masami Hiramatsu
2015-06-16 13:39     ` Arnaldo Carvalho de Melo
2015-06-16 15:26   ` hekuang
2015-06-17  8:52     ` Masami Hiramatsu
2015-06-17  9:43       ` He Kuang
2015-06-17 11:18         ` Masami Hiramatsu
2015-06-18  2:49           ` [PATCH v2] " He Kuang
2015-06-19 21:08             ` Arnaldo Carvalho de Melo
2015-06-23  3:07               ` Masami Hiramatsu
2015-06-23  3:07             ` Masami Hiramatsu
2015-06-25  7:57             ` [tip:perf/core] " tip-bot for He Kuang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.