Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp39552imu; Thu, 8 Nov 2018 04:44:20 -0800 (PST) X-Google-Smtp-Source: AJdET5coWEvQvmaaSfrjAMtWpw5AH8qWWXZWBCNTx2AgACwSRSE5gzlQNUjUDm83rdjh9NrkMEGj X-Received: by 2002:a17:902:1e3:: with SMTP id b90-v6mr1581312plb.117.1541681060407; Thu, 08 Nov 2018 04:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541681060; cv=none; d=google.com; s=arc-20160816; b=dH7RxrnKtDJRbAmU2JvM/m4Wtpm0ldD2SshNQix3fezu/pyWInihI8uBxbJLS4NUHg Q7vh7frwH+fygkWNQdX0LVicp067hrqrRankl8EYIbESbG6zvdDbjdudFUHcc4iKGA4c Rj1oCBMz7alonnqGCtJFIfioJLNhMdiUlU64l2QdnBJOKFjCPXIo0Ssiqp7drXT+/2Ml DB9VBIi0fbxDl8NOWZkhD6hlWuXd33pQRromZS/6FB4f3YsEREPJ7zdcrZxIiorsRfho P4T0e4tGQjRoczst8sGRhiTO2IC2NSQ8LClIo+eDCRHjidATSOjF7pnK4P71vK3e+ZLY my0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :organization:message-id:date:subject:cc:to:from:dkim-signature; bh=URKLhhXryJtfzfaRMk3nwYFsslzrb6ATrlX7iqUpdJY=; b=0lWRHmWXi5wxqvaZtSI1OX8bHHr77cTrHXGazD5oeHC4SIWVCKb3I5dvmcBpqZOwyX 2Ph2YiP+FD6uWFbGqch/CqHOhY4okRlA+TZ8DTwPPXM/Wlru9Z2rmq9aa8w+rj4vBNvM 6MYoUlatxc4CzbOdBXaJ9lTNNnK3uuigZTH7WYiNd5nrST1CmbBTGmcfXLuXa0looCIE Atfa+exv021I3jE59N4f0vbrLfBzYQABY2r6snFrQ6msgIQYo10CzmOWppLot/JmzJ4Q bK9/ha1vAX5gqckNCY544Q+K2A5QyKkpCVfQH30uMs3PB4wz7swvl+1LBwI8oohQxMI1 7mNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kdab.com header.s=dkim header.b=xU9v3aYt; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kdab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4-v6si3412464pgj.417.2018.11.08.04.43.59; Thu, 08 Nov 2018 04:44:20 -0800 (PST) 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; dkim=pass header.i=@kdab.com header.s=dkim header.b=xU9v3aYt; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kdab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726856AbeKHWRR (ORCPT + 99 others); Thu, 8 Nov 2018 17:17:17 -0500 Received: from mail.kdab.com ([176.9.126.58]:62470 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbeKHWRR (ORCPT ); Thu, 8 Nov 2018 17:17:17 -0500 Authentication-Results: mail.kdab.com (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=kdab.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kdab.com; h= content-type:content-type:mime-version:references:in-reply-to :organization:message-id:date:date:subject:subject:from:from; s= dkim; t=1541680914; x=1542544915; bh=URKLhhXryJtfzfaRMk3nwYFsslz rb6ATrlX7iqUpdJY=; b=xU9v3aYtnUB4PsmeHmDHxEFROOYqKRW/ZbT4jbdYvEv uarFos3hkNYwS+V115Df3IkrSgQfGJGHkwNa+4Z9eYeOc+Ad7+Klzq1j4bazuXga 8GYhVSNseFSp4u5DPfq/U5l1SX35yiPKVlPCNHy6cKETO/V89fL8RlhnicnBBZkg = X-Virus-Scanned: amavisd-new at kdab.com From: Milian Wolff To: Milian Wolff Cc: Andi Kleen , Jiri Olsa , linux-kernel@vger.kernel.org, Jiri Olsa , namhyung@kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho Subject: Re: PEBS level 2/3 breaks dwarf unwinding! [WAS: Re: Broken dwarf unwinding - wrong stack pointer register value?] Date: Thu, 08 Nov 2018 13:41:50 +0100 Message-ID: <7105958.qy8IzDpmRc@agathebauer> Organization: KDAB In-Reply-To: <1584560.aXQ729uQp3@agathebauer> References: <2335309.gnWok9HYb4@agathebauer> <20181106202411.GU6218@tassilo.jf.intel.com> <1584560.aXQ729uQp3@agathebauer> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1543118.cLrsxmjIBU"; micalg="sha256"; protocol="application/pkcs7-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --nextPart1543118.cLrsxmjIBU Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Mittwoch, 7. November 2018 23:41:31 CET Milian Wolff wrote: > On Dienstag, 6. November 2018 21:24:11 CET Andi Kleen wrote: > > > Where would I look for the source to change here? So far, I only > > > concentrated on the userspace side of perf in tools/perf. > > > > Kind of similar to > > > > a405bad5ad20 perf/x86: Add Haswell specific transaction flag reporting > > fdfbbd07e91f perf: Add generic transaction flags > > > > Report the original (not overwritten) regs->ip and regs->sp > > Thanks a lot Andi! With your help, I have managed to find the exact issue > for my scenario. Turns out, it really is "just" the instruction pointer > that is wrong. I.e. originally we have IP = 0x7feda32ca68c, but with PEBS > we correct that to IP = 7feda32ca688. The SP register value stays the same > according to my printk output. Using the original IP value, we can unwind > correctly since we point to the correct place in the .eh_frame section. The > PEBS IP points to a different position in the .eh_frame section, which is > "too early". > > That brings up some questions: > > - I noticed `perf record --intr-regs`, but the values recorded in the > perf.data file are always the same. I.e. comparing uregs and iregs, I always > see the same values printed by `perf script`. This smells like a bug to me, > but so far I haven't figured out why this happens... The reason seems to be that perf_event_output only takes one set of registers, which then gets handed down into perf_prepare_sample where it gets sampled. Thus if sample type has both PERF_SAMPLE_REGS_USER and PERF_SAMPLE_REGS_INTR set, then by design both will store the same values for user space samples. Can we change this, such that perf_event_output also takes a second set of registers (iregs) that get sampled for PERF_SAMPLE_REGS_INTR? I'm very new to real kernel development, what kind of ABI/API stability guarantees exist for something like "perf_event_output"? > - Independently, when I add a custom printk manually in `arch/x86/events/ > intel/ds.c` at the end of `setup_pebs_sample_data`, then I'm never seeing > any differences between SP in iregs/pebs/regs. Shouldn't it also be > recorded via PEBS? Or is it just chance that I'm never seeing any > difference in setup_pebs_sample_data between iregs->sp and regs->sp? The reason here seems to be that the registers stored in "pebs" are essentially the same as iregs for the setup for `perf record --call-graph dwarf`. The difference is the availability of `pebs->real_ip` which gets used on my system to fixup the IP. SP stays untouched and is thus only truly valid for the untouched IP (which is discarded currently - see above). > - Generally, how do we want to handle this bug? If `--intr-regs` would > actually record a different IP than stored in uregs in the perf.data file, > then we could use that as a fallback for unwinding, when it fails the first > time. Or should we always unwind from that IP? How do we mark the "actual" > frame/IP then, if that differs? > > Thanks -- Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer KDAB (Deutschland) GmbH, a KDAB Group company Tel: +49-30-521325470 KDAB - The Qt, C++ and OpenGL Experts --nextPart1543118.cLrsxmjIBU Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCCDEIw ggXmMIIDzqADAgECAhBqm+E4O/8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