Received: by 10.192.165.156 with SMTP id m28csp2321822imm; Thu, 12 Apr 2018 12:16:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ZrJl127z0WrmIEVLclYH/04/2DF8R8jAoYPlZjv5bvyXo0y0AppHZv+zjRN903MMTyrFn X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr2279658plb.380.1523560585856; Thu, 12 Apr 2018 12:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523560585; cv=none; d=google.com; s=arc-20160816; b=kDAYhEzjiL0Pdflv5Xa8ifNhuhQKc0gvxZddzpr9FvQ57Uiv4IBtsEiCHfUc7o785A ooZD9YkuTF1Hj8btYmKkndFCeuT5nJPzSHZoPz0q0lv/+bxiIwGMWh4CYys3FTB9LCOM Bb9tz99ToG+osYDNWko55xJKm3CqhzBJVtRgleEkQ3YsU4J85k0SglRSltNbqPfqgdVb zO07Df3oyHMKPT4HPKteUGkR4+kQnGhOO8jky9Ij+p80Q/XR+63y3DQnjJqc0WZUn6ge Y01Wd8D/kSildkVAxiL2rl8+ryg+wANQ2jiw64AMzN2HkCm9ABfNAbDjumUH3Nk42GI+ wkDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=XZZG9zTsfQrP4NiyHjdOuQyHF1eOdvU8ZKptkU7X/XU=; b=yqVnyg5/swtCK9gKyIAa1k6si9tBUp9NQ+OHFJTlCKhDf8OwIu9LT9tPh4+YabxK51 1k/ttxsu2+WJTypH/OLAfhHi5c4wZZlf4cSMMsCAaCwsnoSOVXM4/GL5+vwt8B+2gSUb hvDcKoiM7JN83RG2PdNzHzqkTel1DFmh0r8tIVJUrI2CX6v8/iEHAqNvxG7v2NdV3cvO l9XoGgPs0h7f46sXdBCcoTBYx7JHxSbztyyS/GSG4XKID0r0EEX7rFeS0WZdUfsECAWc 1fgvckrHAUA/CV/2WKlKaPXloNcZFt1s2NEOy9vpcZCTKCQBO2fDm5SmCcsG88y/swx7 opgw== 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 c10si1335619pgp.260.2018.04.12.12.16.10; Thu, 12 Apr 2018 12:16:25 -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 S1753333AbeDLSnW (ORCPT + 99 others); Thu, 12 Apr 2018 14:43:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753317AbeDLSnV (ORCPT ); Thu, 12 Apr 2018 14:43:21 -0400 Received: from jouet.infradead.org (unknown [190.15.121.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E444206B2; Thu, 12 Apr 2018 18:43:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E444206B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org Received: by jouet.infradead.org (Postfix, from userid 1000) id D5E831444FE; Thu, 12 Apr 2018 15:43:16 -0300 (-03) Date: Thu, 12 Apr 2018 15:43:16 -0300 From: Arnaldo Carvalho de Melo To: Sandipan Das Cc: jolsa@redhat.com, linux-kernel@vger.kernel.org, naveen.n.rao@linux.vnet.ibm.com, ravi.bangoria@linux.vnet.ibm.com, Maynard Johnson , Sukadev Bhattiprolu Subject: Re: [PATCH 1/2] perf tools powerpc: Fix callchain ip filtering Message-ID: <20180412184316.GA10387@kernel.org> References: <20180412171129.4422-1-sandipan@linux.vnet.ibm.com> <20180412171129.4422-2-sandipan@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180412171129.4422-2-sandipan@linux.vnet.ibm.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Apr 12, 2018 at 10:41:28PM +0530, Sandipan Das escreveu: > For powerpc64, if a probe is added for a function without specifying > a line number, the corresponding trap instruction is placed at offset > 0 (for big endian) or 8 (for little endian) from the start address of > the function. This address is in the function prologue and the trap > instruction preceeds the instructions to set up the stack frame. So, the author for the fixed-by patch here is Sukadev Bhattiprolu , and the reporter for the problem that patch fixed is Maynard Johnson , who also tested that patch, I think it'd be better if they get CCed to have the opportunity to ack/comment, but since everybody is at IBM, perhaps those guys are not anymore involved with ppc at IBM? I'm CCing anyway :-) - Arnaldo > Therefore, at this point during execution, the return address for the > function is yet to be written to its caller's stack frame. So, the LR > value at index 2 of the callchain ips provided by the kernel is still > valid and must not be skipped. > > This can be observed on a powerpc64le system running Fedora 27 as > shown below. > > # perf probe -x /usr/lib64/libc-2.26.so -a inet_pton > # perf record -e probe_libc:inet_pton/max-stack=3/ ping -6 -c 1 ::1 > # perf script > > Without this patch, the output is: > > ping 27909 [007] 532219.943481: probe_libc:inet_pton: (7fff99b0af28) > 15af28 __GI___inet_pton (/usr/lib64/libc-2.26.so) > 1105b4 getaddrinfo (/usr/lib64/libc-2.26.so) > > With this patch applied, the output is: > > ping 27909 [007] 532219.943481: probe_libc:inet_pton: (7fff99b0af28) > 15af28 __GI___inet_pton (/usr/lib64/libc-2.26.so) > 10fa54 gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so) > 1105b4 getaddrinfo (/usr/lib64/libc-2.26.so) > > Fixes: a60335ba3298 ("perf tools powerpc: Adjust callchain based on DWARF debug info") > Signed-off-by: Sandipan Das > --- > tools/perf/arch/powerpc/util/skip-callchain-idx.c | 58 ++++++++++++++++------- > 1 file changed, 41 insertions(+), 17 deletions(-) > > diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c > index 0c370f81e002..f5179f5bb306 100644 > --- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c > +++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c > @@ -212,6 +212,37 @@ static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc) > return rc; > } > > +/* > + * Return: > + * 0 if return address for the program counter @pc is on stack > + * 1 if return address is in LR and no new stack frame was allocated > + * 2 if return address is in LR and a new frame was allocated (but not > + * yet used) > + * -1 in case of errors > + */ > +static int get_return_addr(struct thread *thread, u64 ip) > +{ > + struct addr_location al; > + struct dso *dso = NULL; > + int rc = -1; > + > + thread__find_addr_location(thread, PERF_RECORD_MISC_USER, > + MAP__FUNCTION, ip, &al); > + > + if (!al.map || !al.map->dso) { > + pr_debug("%" PRIx64 " dso is NULL\n", ip); > + return rc; > + } > + > + dso = al.map->dso; > + rc = check_return_addr(dso, al.map->start, ip); > + > + pr_debug("[DSO %s, sym %s, ip 0x%" PRIx64 "] rc %d\n", > + dso->long_name, al.sym->name, ip, rc); > + > + return rc; > +} > + > /* > * The callchain saved by the kernel always includes the link register (LR). > * > @@ -237,32 +268,25 @@ static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc) > */ > int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain) > { > - struct addr_location al; > - struct dso *dso = NULL; > int rc; > - u64 ip; > u64 skip_slot = -1; > > if (chain->nr < 3) > return skip_slot; > > - ip = chain->ips[2]; > + rc = get_return_addr(thread, chain->ips[1]); > > - thread__find_addr_location(thread, PERF_RECORD_MISC_USER, > - MAP__FUNCTION, ip, &al); > - > - if (al.map) > - dso = al.map->dso; > - > - if (!dso) { > - pr_debug("%" PRIx64 " dso is NULL\n", ip); > + if (rc == 1) > + /* Return address is still in LR and has not been updated > + * in caller's stack frame. This is because the probe was > + * placed at an offset from the start of the function that > + * comes before the prologue code to set up the stack frame. > + * So, an attempt to skip an entry based on chain->ips[2], > + * i.e. the LR value, should not be made. > + */ > return skip_slot; > - } > > - rc = check_return_addr(dso, al.map->start, ip); > - > - pr_debug("[DSO %s, sym %s, ip 0x%" PRIx64 "] rc %d\n", > - dso->long_name, al.sym->name, ip, rc); > + rc = get_return_addr(thread, chain->ips[2]); > > if (rc == 0) { > /* > -- > 2.14.3