Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2387279imu; Sat, 10 Nov 2018 13:45:26 -0800 (PST) X-Google-Smtp-Source: AJdET5dMfLQtiiBgqcegbmEct7yJHqns9pgKKCIrFbncp+Kdk5scYoj1n1GymcD2iIa6wpLnvD5g X-Received: by 2002:a63:f652:: with SMTP id u18-v6mr12396536pgj.267.1541886326625; Sat, 10 Nov 2018 13:45:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541886326; cv=none; d=google.com; s=arc-20160816; b=juMyEfKi0olVDYEF4IY05N7ZEMZVVvT0p4iyvZwIEgpQwa3IXoAmho06e3FibXcHwQ BFet7DszUPhGCjTi/oMPjAdrxAtwOk0/oW572jNHe4LbiOI+0DpA8lvyBPQfvG/Fgece GRIhe5bacLZ1Ju22ozCMm29oYBgA9o6UzUBa+AXeYztHy9ApaRIGfg1K+Oim7TRp2IgU e2G2ko9V+Y5bFqcD+rJ3YmXpKevBbn1RUdP8WmKw4/z7Nw7UDFKV5BdmDStEo7Y6bavk kRmDUuOFMHRu/8iSR53dNJ4QIJI8afNZUf/oZRb2mQyiTFwdVsfIKXiAwLl4NL4KsAEb 26qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NQ3XTGqk7TT54dMiJFYwymU6ZgR614PmxrDqJ7DQkdE=; b=aJ1t09SN+95jg0ePpMhEMBD90n1S4nN/PbvilZB8+hfsKzgptvSqfRT3DbG4rQyny4 khydKVlWYluSZ5XyoysDhs4iwM7KVbXg0GO2656Q7m4qay7Zp63aGP+lu4NioFcnzRC9 gMETs9QP5pY24GC3td6cqei5GB7Z1k7fzU8uQJ+7rTlxhJiIhiTxqQyxlq1vHYnkjuG4 R7qAqf/CmjoJ6AHWDZUndW+7acKNHts5RBCEuOXA9YGxk7uHCj/0FrhxnAnqcIL7HgCJ NhZ7qOtI5r8JG0MR7Jwwg2L/9rAkCoebEmNjqmwZY5fdFW6uyfzt6V32qK0hr7TNLLNm ThGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kl4XoSj8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h5-v6si13201077pfg.226.2018.11.10.13.45.11; Sat, 10 Nov 2018 13:45:26 -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=@gmail.com header.s=20161025 header.b=Kl4XoSj8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbeKKH3x (ORCPT + 99 others); Sun, 11 Nov 2018 02:29:53 -0500 Received: from mail-it1-f178.google.com ([209.85.166.178]:56244 "EHLO mail-it1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725778AbeKKH3x (ORCPT ); Sun, 11 Nov 2018 02:29:53 -0500 Received: by mail-it1-f178.google.com with SMTP id b7-v6so7790383itd.5; Sat, 10 Nov 2018 13:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NQ3XTGqk7TT54dMiJFYwymU6ZgR614PmxrDqJ7DQkdE=; b=Kl4XoSj8g3iDxLtbot+KHpwc2W5lvSLHPEQsTzaM3AHpYggVnZnvfiF/plNu+FZ6oh SDrWh2ISu+4+bjQQHlC4PnyZmXScuXVcpmZkqqmHVlDEfCEatlcoR2TjvgLa1+Poi1+G 8LvGyWNzunYm9zhTsMFouYc2pTpS20uF34sDZou0RgWm4Mz/v/pJbesa5aHdpDEPfKO0 Xlx/oxmxH9op0pSfZzSbUmuQhRKBg4CowC7s7z110udLhsk8BOfLRIg7ez0lOPDNqAef CNqDzXtRtQuZyo73OhRmObnCn8Qv3Gk/LaE5rSWzJ4mCPi/stqQU5m0es2vplr/bmls0 RjvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NQ3XTGqk7TT54dMiJFYwymU6ZgR614PmxrDqJ7DQkdE=; b=N5piNB8lOpgeIptLlczUupvH8aIOT0+SiXTz7JYFfB/Lm41XZPPfhHu2ioSQjwY3h4 QHpZYvJbz5jOTuM5CbDjm9L8kzVdDM2uKZAKmny3CcGQ9juJmqUZWsh9BQ6n8atx+OTJ tdRB4MEIQRSLS5Pv7fBNojZoD0nsjC6d+8vSk+GmXP+pcKPkIjZQ6Kzr1bf+P/v2XA99 i8GxJmAl7Dz9TTYRhxEEQov4IGzwlEcN6XwYGOz7ayUnOf5o8XY1oK4l78xKSIOn4OR0 6+KkVhgOHIeFRJqdv18anRfNAipFoq91dnCEfbwTaerk58Kbx5mAYsyFYxA0/LfFQBXR GZOA== X-Gm-Message-State: AGRZ1gL1nkk5Lct7ZgCpi4RqvEXVfxWTTzeXFahFhyrIJBQyuMCM6Vcg GAwQX7UFTeg9yTxMJzn7H/Jr97jvV4uCqBGEc5s= X-Received: by 2002:a24:5e93:: with SMTP id h141-v6mr7125373itb.103.1541886207073; Sat, 10 Nov 2018 13:43:27 -0800 (PST) MIME-Version: 1.0 References: <2335309.gnWok9HYb4@agathebauer> <3227038.olIWmsCzzY@agathebauer> <20181105205119.GC25674@krava> <3799078.YBnU1OB0PF@agathebauer> <20181106001037.GQ6218@tassilo.jf.intel.com> In-Reply-To: <20181106001037.GQ6218@tassilo.jf.intel.com> From: Travis Downs Date: Sat, 10 Nov 2018 16:42:48 -0500 Message-ID: Subject: Re: PEBS level 2/3 breaks dwarf unwinding! [WAS: Re: Broken dwarf unwinding - wrong stack pointer register value?] To: ak@linux.intel.com Cc: milian.wolff@kdab.com, jolsa@redhat.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, namhyung@kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 5, 2018 at 7:11 PM Andi Kleen wrote: > Milian is right. > > There is a execution window from PEBS capturing registers to actually triggering > the PMU, and if there is stack manipulation in that window > the PEBS state might be out of sync with the real stack. This explains some weird results I was always getting especially when functions were small, including failed unwindings when using dwarf unwinder. I guess this problem doesn't occur for LBR unwinding since the LBR records are captured at the same moment in time as the PEBS record, so reflect the correct branch sequence. Of course, LBR doesn't always let you unwind fully, right? > > The right RIP/RSP to use for the stack unwinding is always the data > in the PMI's exception frame on the stack. > > Probably would need to modify perf to report those too in addition > to the PEBS registers. > > Of course it would still mean that the stack unwinding may not exactly > match the sample RIP, but at least it should be consistent. What would this fix mean for perf report when you use cycles:pp and cycles:ppp (or any PEBS based events)? The unwinding should generally work, but the IP at the top of that stack (from the PMI) will generally be different than that recorded by PEBS. The tree view and overhead calculations will be based on the captured stacks, I guess - but when I annotate, will the values I see correspond to the PEBS IPs or the PMI IPs? If someone is using cycles:pp or :ppp they probably care about instruction-level accuracy, so it would be a shame to throw it away.