From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752078AbdLACgQ (ORCPT ); Thu, 30 Nov 2017 21:36:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:58578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751007AbdLACgP (ORCPT ); Thu, 30 Nov 2017 21:36:15 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8829219A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org Date: Fri, 1 Dec 2017 11:36:12 +0900 From: Masami Hiramatsu To: Andi Kleen Cc: acme@kernel.org, jolsa@kernel.org, mhiramat@kernel.org, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH 12/12] perf, tools, script: Implement dwarf resolving of instructions Message-Id: <20171201113612.9d7701cb43b3d2f7e6a637ce@kernel.org> In-Reply-To: <20171128002321.2878-13-andi@firstfloor.org> References: <20171128002321.2878-1-andi@firstfloor.org> <20171128002321.2878-13-andi@firstfloor.org> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Nov 2017 16:23:21 -0800 Andi Kleen wrote: > From: Andi Kleen > > Implement resolving arguments of instructions to dwarf variable names. > > When we sample an instruction, decode the instruction and try to > symbolize the register or destination it is using. Also print the type. > It builds on the perf probe debugging information reverse lookup > infrastructure added earlier. > > The dwarf decoding magic is all done using Masami Hiramatsu's perf probe code. > > This is useful for > > - The PTWRITE instruction: when the compiler generates debugging information > for PTWRITE arguments. The value logged by PTWRITE is available to the > PT decoder, so it can print the value. > > - It also works for other samples with an IP, so it's possible to follow > their memory access patterns (but not the values) > > For the sample we use the instruction decoder to decode the instruction > at the sample point, and then map the arguments to dwarf information. > > For structure reference we only print the numeric offset, but do not > resolve the field name. > > Absolute memory references are not supported Hmm, I think perf-probe also have same limitation. > > It doesn't distinguish SSE (but AVX) registers from GPRs > (this would require extending the instruction decoder to detect SSE > instructions) > > Example: > > From perf itself > > % perf record -e intel_pt//u -a sleep 1 > % perf script --itrace=i0ns -F insnvar,insn,ip,sym -f 2>&1 | xed -F insn: -A -64 | less > ... > 4f7e61 xyarray__max_y pushq %rbp > 4f7e62 xyarray__max_y mov %rsp, %rbp > 4f7e65 xyarray__max_y sub $0x20, %rsp > 4f7e69 xyarray__max_y movq %rdi, -0x18(%rbp) { -24(xy), struct xyarray* } > 4f7e6d xyarray__max_y movq %fs:0x28, %rax > 4f7e76 xyarray__max_y movq %rax, -0x8(%rbp) { -8(xy), struct xyarray* } > 4f7e7a xyarray__max_y xor %eax, %eax > 4f7e7c xyarray__max_y movq -0x18(%rbp), %rax { -24(xy), struct xyarray* } > 4f7e80 xyarray__max_y movq 0x20(%rax), %rax > 4f7e84 xyarray__max_y movq -0x8(%rbp), %rdx { -8(xy), struct xyarray* } > 4f7e88 xyarray__max_y xorq %fs:0x28, %rdx > 4f7e91 xyarray__max_y jz 0x7 > 4f7e98 xyarray__max_y leaveq > 4f7e99 xyarray__max_y retq Nice! :) > > In this example we now know that this function accesses two fields in struct xyarray * > > Open Issues: > - It is fairly slow. Some caching would likely help. OK, we can keep debuginfo open, but it may consume lot of memory. > - Frame pointer references are usually not correctly resolved, > which are common in unoptimized code. That's usually fine > because memory access on the stack is not very interesting. > - It cannot resolve some references. OK, let's find what kind of references can not be solved. > > But I find it already quite useful. > > Signed-off-by: Andi Kleen [..] > diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c > index 85fbeeb364bf..2a65ebed0998 100644 > --- a/tools/perf/util/probe-event.c > +++ b/tools/perf/util/probe-event.c > @@ -78,6 +78,9 @@ int init_probe_symbol_maps(bool user_only) > { > int ret; > > + if (host_machine) > + return 0; What is this code for? Please put comment or make it separated patch. Thanks! > + > symbol_conf.sort_by_name = true; > symbol_conf.allow_aliases = true; > ret = symbol__init(NULL); > -- > 2.13.6 > -- Masami Hiramatsu