Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2413014imd; Fri, 2 Nov 2018 10:57:44 -0700 (PDT) X-Google-Smtp-Source: AJdET5fPJ5fJ0Z6UyxavO/GhX+XKrGf4Oo3YJebeJU6N18ewAVbqEpowj15yWJmaoWWcu7O4N86B X-Received: by 2002:a63:ef0b:: with SMTP id u11-v6mr11814153pgh.283.1541181463990; Fri, 02 Nov 2018 10:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541181463; cv=none; d=google.com; s=arc-20160816; b=tLSDfDu2dtD+2NcoJPVrjsyHhkh4AeihKf5o7toIs2+GL8yRIscs3MHFEdosRNwY94 sb5D7PDC3KZDoa+Xs+i9l51KOhdb/FllUNx+FU0cLFcSPkCVttipp2AHfsXrnbl4gpZG 3uB94qhsZcXiskMIerKahMSS3PkId9qnk9a0zt5b5yQSCkzCLvS+l7R8T+1MkqoYf35F I/Jm+n82hMNfq2gSuPUxnIClwK3GLYmRz7+vguV2zZ6vBZFrLzOOMCuXK3wNC7CljH+i YajQnxrZjDMab3/exkSYZONNseXJhQLpyyvzsygP3ZLj0mHFuvlFCBJnsVUAB+ITSiXw 1viw== 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=maCZu9m34SqEu0lNUhWrLQOrVq8h7J5GuOge4bJac4c=; b=FsnZ5pV+SGHAbszIgS/KBzVWl1GUkyTu1sQNIT78nnEGl+KXnitdK6fVPbCaVYRymS TghS1NrZfGvWvvmIWXlYPUKEMk11rK1lqRig2uZ0mf64y37QPURcZ/568fyldvPFFUIb UfCzNHM8GTWT6Y3Rmv8vtnVDTOaIUwT4VsTByPeZaojNYD9hlK7Ja2QaLGbA4nmxgjJD KSQLEjgH4QHugcU4Z3VLfm9hmNlSUSRNlGT1vN4Ttwo2bukKizr4mpsZUesvTd0Eag51 nerrlk9KUit7be3D8RO0ue2jLmHTBen+jtMHmt0Brf4lQmnOCfcwDW0ZcY6lLcuu4l6j P2PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kdab.com header.s=dkim header.b=cf0C4+uH; 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 t129-v6si4507326pfb.16.2018.11.02.10.57.28; Fri, 02 Nov 2018 10:57:43 -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; dkim=pass header.i=@kdab.com header.s=dkim header.b=cf0C4+uH; 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 S1728102AbeKCDE7 (ORCPT + 99 others); Fri, 2 Nov 2018 23:04:59 -0400 Received: from mail.kdab.com ([176.9.126.58]:16093 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbeKCDE7 (ORCPT ); Fri, 2 Nov 2018 23:04:59 -0400 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=1541181415; x=1542045416; bh=maCZu9m34SqEu0lNUhWrLQOrVq8 h7J5GuOge4bJac4c=; b=cf0C4+uHQvORKZH1dcuSPp+lqNe7b98HTH0XhWeBlUa dMckcJcW/EP9sw4RVYIktGnSXjEt4Zw1iR4/hFuu2flHzCMrjkSNOu0PG0ZflS/A kpb3HLfDNx3L7aXDvioSqbbGM+dl0TIFhfTFyaL+7jYpGYolrhUiqsmy3ectVzfA = X-Virus-Scanned: amavisd-new at kdab.com From: Milian Wolff To: Jiri Olsa Cc: Andi Kleen , 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: Fri, 02 Nov 2018 18:56:50 +0100 Message-ID: <3227038.olIWmsCzzY@agathebauer> Organization: KDAB In-Reply-To: <20181102112635.GD5458@krava> References: <2335309.gnWok9HYb4@agathebauer> <13521319.OzbRBoFVZM@agathebauer> <20181102112635.GD5458@krava> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart11011248.QEtXxAIldR"; 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 --nextPart11011248.QEtXxAIldR Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Freitag, 2. November 2018 12:26:35 CET Jiri Olsa wrote: > On Thu, Nov 01, 2018 at 11:08:18PM +0100, Milian Wolff wrote: > > On Dienstag, 30. Oktober 2018 23:34:35 CET Milian Wolff wrote: > > > On Mittwoch, 24. Oktober 2018 16:48:18 CET Andi Kleen wrote: > > > > > Can someone at least confirm whether unwinding from a function > > > > > prologue > > > > > via > > > > > .eh_frame (but without .debug_frame) should actually be possible? > > > > > > > > Yes it should be possible. Asynchronous unwind tables should work > > > > from any instruction. > > > > > > > > > We can find `7f91345bdaf8+1 = 7f91345bdaf9" at offset 16 (search for "f9 > > > da > > > 5b 34 91 7f"). Using that address makes unwinding work for this sample. > > > What could be the reason for this shift? > > > > I believe I have found the culprit: PEBS seems to be at fault here - i.e. > > the RIP/RSP and the ustack dump of the sample simply don't fit together. > > > > Check this out: > > > > ``` > > $ for i in $(seq 10); do perf record -q -e "cycles:" --call-graph dwarf > > ./cpp- inlining > /dev/null; perf script | pcre2grep -c -M > > "hypot_finite.*\n.*\ [unknown\]"; done > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > > > $ for i in $(seq 10); do perf record -q -e "cycles:p" --call-graph dwarf > > ./ > > cpp-inlining > /dev/null; perf script | pcre2grep -c -M > > "hypot_finite.*\n.*\ [unknown\]"; done > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > 0 > > > > $ for i in $(seq 10); do perf record -q -e "cycles:pp" --call-graph dwarf > > ./ cpp-inlining > /dev/null; perf script | pcre2grep -c -M > > "hypot_finite.*\n.*\ [unknown\]"; done > > 37 > > 39 > > 35 > > 28 > > 40 > > 39 > > 29 > > 37 > > 31 > > 26 > > > > $ for i in $(seq 10); do perf record -q -e "cycles:ppp" --call-graph dwarf > > ./ cpp-inlining > /dev/null; perf script | pcre2grep -c -M > > "hypot_finite.*\n.*\ [unknown\]"; done > > 79 > > 70 > > 76 > > 77 > > 70 > > 90 > > 64 > > 78 > > 86 > > 74 > > ``` > > > > Note how precise levels 0 and 1 do not produce any samples where unwinding > > fails. But precise level 2 produces some, and precise level 3 increases > > the > > amount (by ca. ~2x). > > > > I can reproduce this pattern on two separate Intel CPUs and kernel > > versions > > currently: > > > > Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz with 4.18.16-arch1-1-ARCH > > Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz with 4.14.78-1-lts > > > > Could someone else try this? What about AMD and IBS - is it also affected? > > What about newer/different Intel CPUs? > > I tried on intel and can't actualy see that.. how do the failed samples > look like? like is there the stack dump attached, what's in the regs? > > could you please paste the 'perf report -D' output for some of the > failed samples? See here for one case: https://paste.kde.org/prryvdilq What Intel CPU did you use? What microcode version? Which kernel version? Generally, isn't what I'm seeing actually a neccessary evil of the ustack based unwinding in perf? I mean, the general procedure is as follows if I'm not mistaken: - PMU triggers interrupt and PEBS stores RIP etc. - code continous to execute, possibly changing the stack - PMU interrupt is handled, and a perf sample is generated - register values are used from "past" status stored in PEBS - but ustack dump is based on the "current" status From this latter discrepancy, it must directly follow that *sometimes* the ustack dump represents a state that cannot be unwound from, no? Cheers -- 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 --nextPart11011248.QEtXxAIldR Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCCDEIw ggXmMIIDzqADAgECAhBqm+E4O/8ra58B1dm4p1JWMA0GCSqGSIb3DQEBDAUAMIGFMQswCQYDVQQG EwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYD VQQKExFDT01PRE8gQ0EgTGltaXRlZDErMCkGA1UEAxMiQ09NT0RPIFJTQSBDZXJ0aWZpY2F0aW9u IEF1dGhvcml0eTAeFw0xMzAxMTAwMDAwMDBaFw0yODAxMDkyMzU5NTlaMIGXMQswCQYDVQQGEwJH QjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQK ExFDT01PRE8gQ0EgTGltaXRlZDE9MDsGA1UEAxM0Q09NT0RPIFJTQSBDbGllbnQgQXV0aGVudGlj YXRpb24gYW5kIFNlY3VyZSBFbWFpbCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB AL6znlesKHZ1QBbHOAOY08YYdiFQ8yV5C0y1oNF9Olg+nKcxLqf2NHbZhGra0D00SOTq9bus3/mx gUsg/Wh/eXQ0pnp8tZ8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