linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Sandipan Das <sandipan@linux.ibm.com>,
	Aneesh Kumar <aneesh.kumar@linux.vnet.ibm.com>,
	Jiri Olsa <jolsa@redhat.com>,
	Ravi Bangoria <ravi.bangoria@linux.ibm.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 01/35] perf probe powerpc: Fix trace event post-processing
Date: Wed, 15 Aug 2018 12:05:37 -0300	[thread overview]
Message-ID: <20180815150611.32080-2-acme@kernel.org> (raw)
In-Reply-To: <20180815150611.32080-1-acme@kernel.org>

From: Sandipan Das <sandipan@linux.ibm.com>

In some cases, a symbol may have multiple aliases. Attempting to add an
entry probe for such symbols results in a probe being added at an
incorrect location while it fails altogether for return probes. This is
only applicable for binaries with debug information.

During the arch-dependent post-processing, the offset from the start of
the symbol at which the probe is to be attached is determined and added
to the start address of the symbol to get the probe's location.  In case
there are multiple aliases, this offset gets added multiple times for
each alias of the symbol and we end up with an incorrect probe location.

This can be verified on a powerpc64le system as shown below.

  $ nm /lib/modules/$(uname -r)/build/vmlinux | grep "sys_open$"
  ...
  c000000000414290 T __se_sys_open
  c000000000414290 T sys_open

  $ objdump -d /lib/modules/$(uname -r)/build/vmlinux | grep -A 10 "<__se_sys_open>:"

  c000000000414290 <__se_sys_open>:
  c000000000414290:       19 01 4c 3c     addis   r2,r12,281
  c000000000414294:       70 c4 42 38     addi    r2,r2,-15248
  c000000000414298:       a6 02 08 7c     mflr    r0
  c00000000041429c:       e8 ff a1 fb     std     r29,-24(r1)
  c0000000004142a0:       f0 ff c1 fb     std     r30,-16(r1)
  c0000000004142a4:       f8 ff e1 fb     std     r31,-8(r1)
  c0000000004142a8:       10 00 01 f8     std     r0,16(r1)
  c0000000004142ac:       c1 ff 21 f8     stdu    r1,-64(r1)
  c0000000004142b0:       78 23 9f 7c     mr      r31,r4
  c0000000004142b4:       78 1b 7e 7c     mr      r30,r3

  For both the entry probe and the return probe, the probe location
  should be _text+4276888 (0xc000000000414298). Since another alias
  exists for 'sys_open', the post-processing code will end up adding
  the offset (8 for powerpc64le) twice and perf will attempt to add
  the probe at _text+4276896 (0xc0000000004142a0) instead.

Before:

  # perf probe -v -a sys_open

  probe-definition(0): sys_open
  symbol:sys_open file:(null) line:0 offset:0 return:0 lazy:(null)
  0 arguments
  Looking at the vmlinux_path (8 entries long)
  Using /lib/modules/4.18.0-rc8+/build/vmlinux for symbols
  Open Debuginfo file: /lib/modules/4.18.0-rc8+/build/vmlinux
  Try to find probe point from debuginfo.
  Symbol sys_open address found : c000000000414290
  Matched function: __se_sys_open [2ad03a0]
  Probe point found: __se_sys_open+0
  Found 1 probe_trace_events.
  Opening /sys/kernel/debug/tracing/kprobe_events write=1
  Writing event: p:probe/sys_open _text+4276896
  Added new event:
    probe:sys_open       (on sys_open)
  ...

  # perf probe -v -a sys_open%return $retval

  probe-definition(0): sys_open%return
  symbol:sys_open file:(null) line:0 offset:0 return:1 lazy:(null)
  0 arguments
  Looking at the vmlinux_path (8 entries long)
  Using /lib/modules/4.18.0-rc8+/build/vmlinux for symbols
  Open Debuginfo file: /lib/modules/4.18.0-rc8+/build/vmlinux
  Try to find probe point from debuginfo.
  Symbol sys_open address found : c000000000414290
  Matched function: __se_sys_open [2ad03a0]
  Probe point found: __se_sys_open+0
  Found 1 probe_trace_events.
  Opening /sys/kernel/debug/tracing/README write=0
  Opening /sys/kernel/debug/tracing/kprobe_events write=1
  Parsing probe_events: p:probe/sys_open _text+4276896
  Group:probe Event:sys_open probe:p
  Writing event: r:probe/sys_open__return _text+4276896
  Failed to write event: Invalid argument
    Error: Failed to add events. Reason: Invalid argument (Code: -22)

After:

  # perf probe -v -a sys_open

  probe-definition(0): sys_open
  symbol:sys_open file:(null) line:0 offset:0 return:0 lazy:(null)
  0 arguments
  Looking at the vmlinux_path (8 entries long)
  Using /lib/modules/4.18.0-rc8+/build/vmlinux for symbols
  Open Debuginfo file: /lib/modules/4.18.0-rc8+/build/vmlinux
  Try to find probe point from debuginfo.
  Symbol sys_open address found : c000000000414290
  Matched function: __se_sys_open [2ad03a0]
  Probe point found: __se_sys_open+0
  Found 1 probe_trace_events.
  Opening /sys/kernel/debug/tracing/kprobe_events write=1
  Writing event: p:probe/sys_open _text+4276888
  Added new event:
    probe:sys_open       (on sys_open)
  ...

  # perf probe -v -a sys_open%return $retval

  probe-definition(0): sys_open%return
  symbol:sys_open file:(null) line:0 offset:0 return:1 lazy:(null)
  0 arguments
  Looking at the vmlinux_path (8 entries long)
  Using /lib/modules/4.18.0-rc8+/build/vmlinux for symbols
  Open Debuginfo file: /lib/modules/4.18.0-rc8+/build/vmlinux
  Try to find probe point from debuginfo.
  Symbol sys_open address found : c000000000414290
  Matched function: __se_sys_open [2ad03a0]
  Probe point found: __se_sys_open+0
  Found 1 probe_trace_events.
  Opening /sys/kernel/debug/tracing/README write=0
  Opening /sys/kernel/debug/tracing/kprobe_events write=1
  Parsing probe_events: p:probe/sys_open _text+4276888
  Group:probe Event:sys_open probe:p
  Writing event: r:probe/sys_open__return _text+4276888
  Added new event:
    probe:sys_open__return (on sys_open%return)
  ...

Reported-by: Aneesh Kumar <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Aneesh Kumar <aneesh.kumar@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Fixes: 99e608b5954c ("perf probe ppc64le: Fix probe location when using DWARF")
Link: http://lkml.kernel.org/r/20180809161929.35058-1-sandipan@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/arch/powerpc/util/sym-handling.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
index 53d83d7e6a09..20e7d74d86cd 100644
--- a/tools/perf/arch/powerpc/util/sym-handling.c
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -141,8 +141,10 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
 	for (i = 0; i < ntevs; i++) {
 		tev = &pev->tevs[i];
 		map__for_each_symbol(map, sym, tmp) {
-			if (map->unmap_ip(map, sym->start) == tev->point.address)
+			if (map->unmap_ip(map, sym->start) == tev->point.address) {
 				arch__fix_tev_from_maps(pev, tev, map, sym);
+				break;
+			}
 		}
 	}
 }
-- 
2.14.4


  reply	other threads:[~2018-08-15 15:07 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-15 15:05 [GIT PULL 00/35] perf/core improvements and fixes Arnaldo Carvalho de Melo
2018-08-15 15:05 ` Arnaldo Carvalho de Melo [this message]
2018-08-15 15:05 ` [PATCH 02/35] tools lib traceevent, perf tools: Rename struct pevent to struct tep_handle Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 03/35] tools lib traceevent, perf tools: Rename 'struct pevent_record' to 'struct tep_record' Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 04/35] tools lib traceevent, perf tools: Rename pevent plugin related APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 05/35] tools lib traceevent, perf tools: Rename pevent alloc / free APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 06/35] tools lib traceevent, perf tools: Rename pevent find APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 07/35] tools lib traceevent, perf tools: Rename pevent parse APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 08/35] tools lib traceevent, perf tools: Rename pevent print APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 09/35] tools lib traceevent, perf tools: Rename pevent_read_number_* APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 10/35] tools lib traceevent, perf tools: Rename pevent_register_* APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 11/35] tools lib traceevent, perf tools: Rename pevent_set_* APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 12/35] tools lib traceevent, perf tools: Rename traceevent_* APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 13/35] tools lib traceevent, perf tools: Rename 'enum pevent_flag' to 'enum tep_flag' Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 14/35] tools lib traceevent, tools lib lockdep: Rename 'enum pevent_errno' to 'enum tep_errno' Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 15/35] tools lib traceevent: Rename pevent_function* APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 16/35] tools lib traceevent, perf tools: Rename traceevent_plugin_* APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 17/35] tools lib traceevent: Rename pevent_filter* APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 18/35] tools lib traceevent: Rename pevent_register / unregister APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 19/35] tools lib traceevent: Rename pevent_data_ APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 20/35] tools lib traceevent: Rename pevent field APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 21/35] tools lib traceevent: Rename pevent_find_* APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 22/35] tools lib traceevent: Rename various pevent get/set/is APIs Arnaldo Carvalho de Melo
2018-08-15 15:05 ` [PATCH 23/35] tools lib traceevent: Rename internal parser related APIs Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 24/35] tools lib traceevent: Rename various pevent APIs Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 25/35] tools lib traceevent: Rename static variables and functions in event-parse.c Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 26/35] perf tools: Check for null when copying nsinfo Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 27/35] perf tools: Fix check-headers.sh AND list path of execution Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 28/35] perf tools: Make check-headers.sh check based on kernel dir Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 29/35] perf tools: Move syscall_64.tbl check into check-headers.sh Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 30/35] perf arm spe: Fix uninitialized record error variable Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 31/35] perf python: Remove -mcet and -fcf-protection when building with clang Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 32/35] perf auxtrace: Fix queue resize Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 33/35] kallsyms: Simplify update_iter_mod() Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 34/35] kallsyms, x86: Export addresses of PTI entry trampolines Arnaldo Carvalho de Melo
2018-08-15 15:06 ` [PATCH 35/35] x86: Add entry trampolines to kcore Arnaldo Carvalho de Melo
2018-08-15 15:21 ` [GIT PULL 00/35] perf/core improvements and fixes Andy Lutomirski
2018-08-18 11:17 ` Ingo Molnar

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=20180815150611.32080-2-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=sandipan@linux.ibm.com \
    --cc=williams@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).