Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp457975yba; Fri, 5 Apr 2019 09:58:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzb8JGDHCGUWwsm1HAmqtSZbgWPoP8JT643Is3V9s5aZec6tzMMr38/eMdMw25lQ/rusU2s X-Received: by 2002:a62:b418:: with SMTP id h24mr13581127pfn.145.1554483517453; Fri, 05 Apr 2019 09:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554483517; cv=none; d=google.com; s=arc-20160816; b=VIJlvk+/J//d2+vp6JkhoIkM0suC3MQbm/2+cFRGTvTydiZHYLYv6qcaLHZ7LBti13 Bjhhtj7+Slw61L0zlE/xgX8m7IYN7PG5zbQP9YsdMEwGuajCDX1HeVIucxhEDdb7WZcx vgLkEcbCnycc3GdTrC4vHjdYJ7JLuN9FiCXmALYzEFA5r2nsz6IF9Y5Pj7aK/c4S9woh LcwUdcgt4/okRiDhWC3Ia7kMe4KRiQn2XePvXCAnQxnxwugn+XXDtDciF74azxYaLUDK fG2PAPJk+AeZx1KLog3P1gACtPWSfrYUfqD9h4DFpYVKd1rnbGxDSCRWRqi9gr/Wxm7L NgGA== 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; bh=p4EBFulawt/zTjKeUv+cPNLyBeByHZuTsyinzU+xaeA=; b=LsyA1b5ppyZh+CFbizFeAod/s/XVHf6btppDHjdAmc7qU+C6BsV0LvhdpWkoMw2CE6 2YBKCJimct9q5MgXzkB8v1QqVwIUkAzNU0/BOX2B5zI7efXngdHYlnpZtxnetO3NwaL/ eC7tz89vQpo5DYJNxwyT9maEFcSfd8ECppDpFk1j5AATJGdpYvMTp6gq1t8FJodryn8s 5cjgnN5sp/VaU3XtvLUBUOf6ybs9mMP99oB5cJrbcbVxyhctMiXCIysd870Za9y5ZMvZ SkDLNuAUaPpdKZYHBDVxeTEaK5C3SUx0KtH07ng7dTUS5zk2SRkVyfdY7DtnhZfDGALu MNgw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 140si19225454pga.460.2019.04.05.09.58.22; Fri, 05 Apr 2019 09:58:37 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731507AbfDEQ50 (ORCPT + 99 others); Fri, 5 Apr 2019 12:57:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56060 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726643AbfDEQ50 (ORCPT ); Fri, 5 Apr 2019 12:57:26 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5E1E8535C; Fri, 5 Apr 2019 16:57:25 +0000 (UTC) Received: from treble (ovpn-123-87.rdu2.redhat.com [10.10.123.87]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C8CA51A7CA; Fri, 5 Apr 2019 16:57:17 +0000 (UTC) Date: Fri, 5 Apr 2019 11:57:15 -0500 From: Josh Poimboeuf To: Kairui Song Cc: Linux Kernel Mailing List , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , Dave Young Subject: Re: [RFC PATCH] perf/x86: make perf callchain work without CONFIG_FRAME_POINTER Message-ID: <20190405165715.fpgh4ggkmnqdtfwm@treble> References: <20190404172545.20928-1-kasong@redhat.com> <20190405140929.pycfea7drnpb2sug@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 05 Apr 2019 16:57:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 05, 2019 at 11:13:02PM +0800, Kairui Song wrote: > Hi Josh, thanks for the review, I tried again, using latest upstream > kernel commit ea2cec24c8d429ee6f99040e4eb6c7ad627fe777: > # uname -a > Linux localhost.localdomain 5.1.0-rc3+ #29 SMP Fri Apr 5 22:53:05 CST > 2019 x86_64 x86_64 x86_64 GNU/Linux > > Having following config: > > CONFIG_UNWINDER_ORC=y > > # CONFIG_UNWINDER_FRAME_POINTER is not set > and CONFIG_FRAME_POINTER is off too. > > Then record something with perf (also latest upstream version): > ./perf record -g -e kmem:* -c 1 > > Interrupt it, then view the output: > perf script | less > > Then I notice the stacktrace in kernle is incomplete like following. > Did I miss anything? > -------------- > lvmetad 617 [000] 55.600786: kmem:kfree: > call_site=ffffffffb219e269 ptr=(nil) > ffffffffb22b2d1c kfree+0x11c (/lib/modules/5.1.0-rc3+/build/vmlinux) > 7fba7e58fd0f __select+0x5f (/usr/lib64/libc-2.28.so) > > kworker/u2:5-rp 171 [000] 55.628529: > kmem:kmem_cache_alloc: call_site=ffffffffb20e963d > ptr=0xffffa07f39c581e0 bytes_req=80 bytes_alloc=80 > gfp_flags=GFP_ATOMIC > ffffffffb22b0dec kmem_cache_alloc+0x13c > (/lib/modules/5.1.0-rc3+/build/vmlinux) > ------------- > > And for the patch, I debugged the problem, and found how it happend: > The reason is that we use following code for fetching the registers on > a trace point: > ...snip... > #define perf_arch_fetch_caller_regs(regs, __ip) { \ > (regs)->ip = (__ip); \ > (regs)->bp = caller_frame_pointer(); \ > (regs)->cs = __KERNEL_CS; > ...snip... Thanks, I was able to recreate. It only happens when unwinding from a tracepoint. I haven't investigated yet, but perf_arch_fetch_caller_regs() looks highly suspect, since it's doing (regs)->bp = caller_frame_pointer(), even for ORC. My only explanation for how your patch works is that RBP just happens to point to somewhere higher on the stack, causing the unwinder to start at a semi-random location. I suspect the real "fix" is that you're no longer passing the regs to unwind_start(). -- Josh