All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: [PATCH perf/core v2 1/4] perf-probe: Fix to show correct locations for events on modules
Date: Wed, 11 Jan 2017 14:59:38 +0900	[thread overview]
Message-ID: <148411436777.9978.1440275861947194930.stgit@devbox> (raw)
In-Reply-To: <148411429514.9978.10060675441541429175.stgit@devbox>

Fix to show correct locations for events on modules by relocating
given address instead of retrying after failure.

This happens when the module text size is enough big, bigger than
sh_addr, because original code retries withgiven address + sh_addr
if it failed to find CU DIE at the given address. Any address
smaller than sh_addr always fails and it retries with correct
address, but the address which bigger than sh_addr will get a CU
DIE which is on given address (not adjusted by sh_addr).

In my environment(x86-64), the sh_addr of ".text" section is
0x10030. Since i915 is a huge kernel module, we can see this
issue as below.

  $ grep "[Tt] .*\[i915\]" /proc/kallsyms | sort | head -n1
  ffffffffc0270000 t i915_switcheroo_can_switch	[i915]

ffffffffc0270000 + 0x10030 = ffffffffc0280030, so we'll check
symbols cross this boundary.

  $ grep "[Tt] .*\[i915\]" /proc/kallsyms | grep -B1 ^ffffffffc028\
  | head -n 2
  ffffffffc027ff80 t haswell_init_clock_gating	[i915]
  ffffffffc0280110 t valleyview_init_clock_gating	[i915]

So setup probes on both function and see what happen.

  $ sudo ./perf probe -m i915 -a haswell_init_clock_gating \
        -a valleyview_init_clock_gating
  Added new events:
    probe:haswell_init_clock_gating (on haswell_init_clock_gating in i915)
    probe:valleyview_init_clock_gating (on valleyview_init_clock_gating in i915)

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

  	perf record -e probe:valleyview_init_clock_gating -aR sleep 1

  $ sudo ./perf probe -l
    probe:haswell_init_clock_gating (on haswell_init_clock_gating@gpu/drm/i915/intel_pm.c in i915)
    probe:valleyview_init_clock_gating (on i915_vga_set_decode:4@gpu/drm/i915/i915_drv.c in i915)

As you can see, haswell_init_clock_gating is correctly shown,
but valleyview_init_clock_gating is not.

With this patch, both events are shown correctly.

  $ sudo ./perf probe -l
    probe:haswell_init_clock_gating (on haswell_init_clock_gating@gpu/drm/i915/intel_pm.c in i915)
    probe:valleyview_init_clock_gating (on valleyview_init_clock_gating@gpu/drm/i915/intel_pm.c in i915)

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
  Changes in v2:
    - Rewrite patch description with precise instructions.
---
 tools/perf/util/probe-finder.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index df4debe..0278fe1 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1543,16 +1543,12 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
 	Dwarf_Addr _addr = 0, baseaddr = 0;
 	const char *fname = NULL, *func = NULL, *basefunc = NULL, *tmp;
 	int baseline = 0, lineno = 0, ret = 0;
-	bool reloc = false;
 
-retry:
+	/* We always need to relocate the address for aranges */
+	if (debuginfo__get_text_offset(dbg, &baseaddr) == 0)
+		addr += baseaddr;
 	/* Find cu die */
 	if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr, &cudie)) {
-		if (!reloc && debuginfo__get_text_offset(dbg, &baseaddr) == 0) {
-			addr += baseaddr;
-			reloc = true;
-			goto retry;
-		}
 		pr_warning("Failed to find debug information for address %lx\n",
 			   addr);
 		ret = -EINVAL;

  reply	other threads:[~2017-01-11  6:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11  5:58 [PATCH perf/core v2 0/4] perf-probe: Fix and improve module probe events Masami Hiramatsu
2017-01-11  5:59 ` Masami Hiramatsu [this message]
2017-01-16 18:32   ` [PATCH perf/core v2 1/4] perf-probe: Fix to show correct locations for events on modules Arnaldo Carvalho de Melo
2017-01-18  9:22   ` [tip:perf/urgent] perf probe: " tip-bot for Masami Hiramatsu
2017-01-11  6:00 ` [PATCH perf/core v2 2/4] perf-probe: Add error checks to offline probe post-processing Masami Hiramatsu
2017-01-18  9:22   ` [tip:perf/urgent] perf probe: " tip-bot for Masami Hiramatsu
2017-01-11  6:01 ` [PATCH perf/core v2 3/4] perf-probe: Fix to probe on gcc generated functions in modules Masami Hiramatsu
2017-01-18  9:23   ` [tip:perf/urgent] perf probe: " tip-bot for Masami Hiramatsu
2017-01-11  6:03 ` [PATCH perf/core v2 4/4] perf-probe: Find probe events without target module Masami Hiramatsu
2017-01-16 18:44   ` Arnaldo Carvalho de Melo
2017-01-16 22:21     ` Masami Hiramatsu
2017-01-16  8:08 ` [PATCH perf/core v2 0/4] perf-probe: Fix and improve module probe events Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=148411436777.9978.1440275861947194930.stgit@devbox \
    --to=mhiramat@kernel.org \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.