Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1794369imm; Sat, 18 Aug 2018 04:44:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyR5gEGk5lpl1v/CwdNrX3EcEcAGi2B7j7v42IDhzhZGJqkuOXeiktznanjHCJRhu+bGdy9 X-Received: by 2002:a63:e255:: with SMTP id y21-v6mr36171042pgj.160.1534592690218; Sat, 18 Aug 2018 04:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534592690; cv=none; d=google.com; s=arc-20160816; b=a9hwg3nGBDsTSRdnotHZp1d8RjfvWb29zsRqLaQp0ItIelR1KTwHSz7g2tYNj7Gh4E PMpSd9p/jqziK5Dn7uQHoaiW0LGyV0KUCbcfXJcD7ReY6qvwf0YHqPa6XzLQ8Fc/R+cm NQHUUrKBi7ZY/8xLHeKggKFCT9jftDRCqx5xa75S1xcmXyB+c3elqc7Va3bFKmQWpSjF ZQfhC338ADqEfch8RmndPxwqzV86X9Idx8RF1gH9rQAQDjUCEuK1PrPkVpBmvoSgSCzr EhrkzyKW9rmxSXob7mtTqZrWiSU6kUblhP1EXUeD518RkOxcstE76tjkcxi451YjAiZ9 RVWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=Yd1Ycf6+Sg2SKd13HesoPrjPLultLL3hoDN8GC8Enuw=; b=H1d4VsO/YjfULOzZapAxoIMYR+PACn/AqkdhdZo3dccCeHJ81JJzOH+XFpZIYz79x+ k8H5nCiQ+6JQZGzFyv2RLql8+CmsAw2+oVBX6gESEyfJqf15xCIzzjJFsAS5R1BTHUz2 YepVgb3sWI0V2zO5fSRotMAU/nB+vBo+oPeCKB36i21niqaMwc+lpi6yl/OOhzLsClhH hZ+V7uF/c6SO880zDe0t5q+tNyXk+jVpR0DrvnL1VIy84umO9/+tMiivDI7zvfkVAHtX liofuIxzGU75wN+PjrSqhkHcqnvS9mjISSW9/GSOAJbxmq1W0PyNY69IaSOi1CGaVGQL ROqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h126-v6si4161308pgc.429.2018.08.18.04.44.35; Sat, 18 Aug 2018 04:44:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbeHROu3 (ORCPT + 99 others); Sat, 18 Aug 2018 10:50:29 -0400 Received: from terminus.zytor.com ([198.137.202.136]:57105 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbeHROu3 (ORCPT ); Sat, 18 Aug 2018 10:50:29 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w7IBgwd41288041 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 18 Aug 2018 04:42:58 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w7IBgwbj1288038; Sat, 18 Aug 2018 04:42:58 -0700 Date: Sat, 18 Aug 2018 04:42:58 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Sandipan Das Message-ID: Cc: sandipan@linux.ibm.com, tglx@linutronix.de, ravi.bangoria@linux.ibm.com, hpa@zytor.com, jolsa@redhat.com, aneesh.kumar@linux.vnet.ibm.com, acme@redhat.com, mingo@kernel.org, naveen.n.rao@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, acme@redhat.com, aneesh.kumar@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, naveen.n.rao@linux.vnet.ibm.com, sandipan@linux.ibm.com, jolsa@redhat.com, hpa@zytor.com, tglx@linutronix.de, ravi.bangoria@linux.ibm.com In-Reply-To: <20180809161929.35058-1-sandipan@linux.ibm.com> References: <20180809161929.35058-1-sandipan@linux.ibm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf probe powerpc: Fix trace event post-processing Git-Commit-ID: 354b064b8ebc1e1ede58550ca9e08bfa81e6af43 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 354b064b8ebc1e1ede58550ca9e08bfa81e6af43 Gitweb: https://git.kernel.org/tip/354b064b8ebc1e1ede58550ca9e08bfa81e6af43 Author: Sandipan Das AuthorDate: Thu, 9 Aug 2018 21:49:29 +0530 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 9 Aug 2018 14:40:11 -0300 perf probe powerpc: Fix trace event post-processing 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 Signed-off-by: Sandipan Das Acked-by: Naveen N. Rao Cc: Aneesh Kumar Cc: Jiri Olsa Cc: Ravi Bangoria 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 --- 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; + } } } }