All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: 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>,
	Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL 4.18 068/113] perf probe powerpc: Fix trace event post-processing
Date: Thu, 30 Aug 2018 18:07:24 +0000	[thread overview]
Message-ID: <20180830180714.36167-2-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180830180714.36167-1-alexander.levin@microsoft.com>

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

[ Upstream commit 354b064b8ebc1e1ede58550ca9e08bfa81e6af43 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.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.17.1

  reply	other threads:[~2018-08-30 22:10 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 18:07 [PATCH AUTOSEL 4.18 067/113] powerpc: Fix size calculation using resource_size() Sasha Levin
2018-08-30 18:07 ` Sasha Levin [this message]
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 069/113] block: bvec_nr_vecs() returns value for wrong slab Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 070/113] brcmfmac: fix brcmf_wiphy_wowl_params() NULL pointer dereference Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 071/113] s390/dasd: fix hanging offline processing due to canceled worker Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 072/113] s390/dasd: fix panic for failed online processing Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 073/113] ACPI / scan: Initialize status to ACPI_STA_DEFAULT Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 074/113] blk-mq: count the hctx as active before allocating tag Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 075/113] scsi: aic94xx: fix an error code in aic94xx_init() Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 076/113] NFSv4: Fix error handling in nfs4_sp4_select_mode() Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 077/113] ALSA: hda/ca0132 - Add DSP setup defaults for Recon3D Sasha Levin
2018-08-30 20:13   ` Takashi Iwai
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 078/113] ALSA: hda/ca0132 - Add quirk ID and enum " Sasha Levin
2018-08-30 20:08   ` Takashi Iwai
2018-08-30 20:10     ` Connor McAdams
2018-08-31 16:07       ` Sasha Levin
2018-09-02  6:30         ` Takashi Iwai
2018-09-02 12:56           ` Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 079/113] ALSA: hda/ca0132 - Add alt_functions unsolicited response Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 080/113] Input: do not use WARN() in input_alloc_absinfo() Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 081/113] xen/balloon: fix balloon initialization for PVH Dom0 Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 082/113] PCI: mvebu: Fix I/O space end address calculation Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 083/113] dm kcopyd: avoid softlockup in run_complete_job Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 084/113] staging: comedi: ni_mio_common: fix subdevice flags for PFI subdevice Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 085/113] ASoC: rt5677: Fix initialization of rt5677_of_match.data Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 086/113] iommu/omap: Fix cache flushes on L2 table entries Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 087/113] selftests/powerpc: Kill child processes on SIGINT Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 088/113] selinux: cleanup dentry and inodes on error in selinuxfs Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 089/113] RDS: IB: fix 'passing zero to ERR_PTR()' warning Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 090/113] cfq: Suppress compiler warnings about comparisons Sasha Levin
2018-08-30 18:07 ` [PATCH AUTOSEL 4.18 091/113] smb3: fix reset of bytes read and written stats Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 092/113] CIFS: fix memory leak and remove dead code Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 093/113] SMB3: Number of requests sent should be displayed for SMB3 not just CIFS Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 094/113] smb3: if server does not support posix do not allow posix mount option Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 095/113] powerpc/platforms/85xx: fix t1042rdb_diu.c build errors & warning Sasha Levin
2018-08-30 18:08   ` Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 096/113] powerpc/64s: Make rfi_flush_fallback a little more robust Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 097/113] um: fix parallel building with O= option Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 098/113] powerpc/pseries: Avoid using the size greater than RTAS_ERROR_LOG_MAX Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 099/113] clk: rockchip: Add pclk_rkpwm_pmu to PMU critical clocks in rk3399 Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 100/113] drm/amd/display: Read back max backlight value at boot Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 101/113] KVM: vmx: track host_state.loaded using a loaded_vmcs pointer Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 102/113] kvm: nVMX: Fix fault vector for VMX operation at CPL > 0 Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 103/113] drm/etnaviv: fix crash in GPU suspend when init failed due to buffer placement Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 104/113] btrfs: Exit gracefully when chunk map cannot be inserted to the tree Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 105/113] btrfs: replace: Reset on-disk dev stats value after replace Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 106/113] btrfs: fix in-memory value of total_devices after seed device deletion Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 107/113] btrfs: Rewrite retry logic in do_chunk_alloc Sasha Levin
2018-09-05  9:22   ` David Sterba
2018-09-07  0:16     ` Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 108/113] btrfs: relocation: Only remove reloc rb_trees if reloc control has been initialized Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 109/113] btrfs: tree-checker: Detect invalid and empty essential trees Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 110/113] btrfs: check-integrity: Fix NULL pointer dereference for degraded mount Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 111/113] btrfs: lift uuid_mutex to callers of btrfs_open_devices Sasha Levin
2018-09-05  9:29   ` David Sterba
2018-09-07  0:17     ` Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 112/113] btrfs: Don't remove block group that still has pinned down bytes Sasha Levin
2018-08-30 18:08 ` [PATCH AUTOSEL 4.18 113/113] btrfs: Fix a C compliance issue Sasha Levin

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=20180830180714.36167-2-alexander.levin@microsoft.com \
    --to=alexander.levin@microsoft.com \
    --cc=acme@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=jolsa@redhat.com \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=sandipan@linux.ibm.com \
    --cc=stable@vger.kernel.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.