Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp73207ybj; Wed, 6 May 2020 11:51:52 -0700 (PDT) X-Google-Smtp-Source: APiQypKxhJRoT0L9w7G3ezwCaj/oWI4RzwrY9fbCuQJemvFlwPtY0aiHZxluDdveTePmxgmJfJJR X-Received: by 2002:a17:906:779a:: with SMTP id s26mr4538003ejm.164.1588791112148; Wed, 06 May 2020 11:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588791112; cv=none; d=google.com; s=arc-20160816; b=oFi3Zds/Etd2RBcb26bsvWD9UPgVj0NfaUJfo75FOX5jO0EZSbSb1oYrS/983w2xjw MOi2RNHu/P/08uhrrGoVoH4iQKUcxNMwhcRMANl/Q6EZKq6AJmVVuH+wyDxu6EDq63lR V1D6NcDOccGkZVkWUpO3mFcsgVw2UJXUXdOmWBjI+Aon1Wbxjt+vcemehdwHGmQVmyqo hZu1+5AJm1B/qNn+R1uGW1NmAJV37/nAM3I1L4Cr+2np9KPRFod6n1JPQ2C73vIhV+bY MaoOelGaF/DPjRPjGSDzSXbcUjvhIC8LH7/rtkW0QmhMocVlIhox/QiWn88lZ1GI40F8 Tjsg== 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=PoS2IrOuB3k8Gs9GTISOGT+amC7ulD3eOthouormdxY=; b=Rwwgw5spak7anJFHEZGfuOcPdqESAAnYJO4ce0p0J26y6IqJ8CqUCOtYsMY6zmJufp 2HGjFeCrxNScmSVXxZOObnIK+TYTRjWx8WrPHbPq745vN6SLhVgtWNEBBNcHbGMBUoJf IT+xLYMrpgs+85R83WjS5Qc8R4oF17eFwHEVAlQeGJPMqhJFMvdseux2sNZaIv0sVcMR UgaPC3PkMktQWNsmOnfC1kcW0Tt8PGXVymeLSk9BziMIb7VS4KdKsJOaPRNMXRUOKoqI Od7b1FICmeagu17dcHsxFNxY3QYJ7xIT7YCfCGthbd7f+28CziEm3OKHwa0SK4mAgMA+ vzzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=K27S1ANC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si1692934edt.563.2020.05.06.11.51.29; Wed, 06 May 2020 11:51:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=K27S1ANC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730452AbgEFStJ (ORCPT + 99 others); Wed, 6 May 2020 14:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730112AbgEFStI (ORCPT ); Wed, 6 May 2020 14:49:08 -0400 Received: from mail-vk1-xa42.google.com (mail-vk1-xa42.google.com [IPv6:2607:f8b0:4864:20::a42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8ABCC061A0F for ; Wed, 6 May 2020 11:49:08 -0700 (PDT) Received: by mail-vk1-xa42.google.com with SMTP id j1so955520vkc.2 for ; Wed, 06 May 2020 11:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PoS2IrOuB3k8Gs9GTISOGT+amC7ulD3eOthouormdxY=; b=K27S1ANCL0hISWI03vyvhke0iacWwTBF7yU/P582dsLj3daLFJ2SdMdfsFXBM294Ft 1w5QHE6tmAhpi7Z6BXb7NcZk0ycafNLuXx2wl3a8tCd5PlHhRcHX3zgOBff0AtBi91TS tCU0/Y6CnphoZclJXqr9jCiMDj9S0ZrAbHKPlqrWDlhTGD5A6PrFkqmbA7hrlzHsopVa utrMTck18XaaSK39Gq8HyFkumjumw0E66UirxHQtYh/82SXwFEF4Iw53lSM4AOdd46Cn cMzpKs1mqiAfnpFPs9pzfdjjq+tgrEavwY+gcE1WLzmS1hsAiXWz+xxkA61nkdE9tJhC T9mA== 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=PoS2IrOuB3k8Gs9GTISOGT+amC7ulD3eOthouormdxY=; b=gA/92BkIkE2lFn1l6J021QBJFgHcBhAu8wC2jovz9DleOOvGXc2MSy6shpUqZ9tv0Z T0fqHxBeROLw8WGsLLjVYo4QfGwFEufTXXCD5ihpXtONMLondNOuoSbgtRuBEW7rB2NI EULRBrilXYc6rN58aqLoSAjzq4jOUkJzGfX6rbmbikg0qmBanuLmcrI4gP61S8r+jY+N E0nNahM36l3CnyVNfTrSTpy5klXyD9yjfb5Pyq0uaHdfqmSO3MHMb8jg/S8RBBwyQlcb OeU5r0A3ANFQzuobZZW0HrINykLgbab6DbBL9/uv0YlHaFlnjtMBGcchg0+77FFQQ83G /HAQ== X-Gm-Message-State: AGi0Pubg4ztBNo74DqYSmqkT+sXHpZQU9EyAXE8MCMfSCaC2pT1MgLcZ OHGXoRcrKorvEaKK5ONLlyqnkDrM5SMA2keTnF+TYaF4 X-Received: by 2002:a1f:16d5:: with SMTP id 204mr8348641vkw.20.1588790947678; Wed, 06 May 2020 11:49:07 -0700 (PDT) MIME-Version: 1.0 References: <20200506113714.GA5281@hirez.programming.kicks-ass.net> In-Reply-To: <20200506113714.GA5281@hirez.programming.kicks-ass.net> From: Stephane Eranian Date: Wed, 6 May 2020 11:48:56 -0700 Message-ID: Subject: Re: callchain ABI change with commit 6cbc304f2f360 To: Peter Zijlstra Cc: LKML , Vince Weaver , jpoimboe@redhat.com, "Liang, Kan" , Andi Kleen 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 Wed, May 6, 2020 at 4:37 AM Peter Zijlstra wrote: > > On Tue, May 05, 2020 at 08:37:40PM -0700, Stephane Eranian wrote: > > Hi, > > > > I have received reports from users who have noticed a change of > > behaviour caused by > > commit: > > > > 6cbc304f2f360 ("perf/x86/intel: Fix unwind errors from PEBS entries (mk-II)") > > > > When using PEBS sampling on Intel processors. > > > > Doing simple profiling with: > > $ perf record -g -e cycles:pp ... > > > > Before: > > > > 1 1595951041120856 0x7f77f8 [0xe8]: PERF_RECORD_SAMPLE(IP, 0x4002): > > 795385/690513: 0x558aa66a9607 period: 10000019 addr: 0 > > ... FP chain: nr:22 > > ..... 0: fffffffffffffe00 > > ..... 1: 0000558aa66a9607 > > ..... 2: 0000558aa66a8751 > > ..... 3: 0000558a984a3d4f > > > > Entry 1: matches sampled IP 0x558aa66a9607. > > > > After: > > > > 3 487420973381085 0x2f797c0 [0x90]: PERF_RECORD_SAMPLE(IP, 0x4002): > > 349591/146458: 0x559dcd2ef889 period: 10000019 addr: 0 > > ... FP chain: nr:11 > > ..... 0: fffffffffffffe00 > > ..... 1: 0000559dcd2ef88b > > ..... 2: 0000559dcd19787d > > ..... 3: 0000559dcd1cf1be > > > > entry 1 does not match sampled IP anymore. > > > > Before the patch the kernel was stashing the sampled IP from PEBS into > > the callchain. After the patch it is stashing the interrupted IP, thus > > with the skid. > > > > I am trying to understand whether this is an intentional change or not > > for the IP. > > > > It seems that stashing the interrupted IP would be more consistent across all > > sampling modes, i.e., with and without PEBS. Entry 1: would always be > > the interrupted IP. > > The changelog talks about ORC unwinder being more happy this the > > interrupted machine > > state, but not about the ABI expectation here. > > Could you clarify? > > Intentional; fundamentally, we cannot unwind a stack that no longer > exists. > Ok, thanks for clarifying this. > The PEBS record comes in after the fact, the stack at the time of record > is irretrievably gone. The only (and best) thing we can do is provide > the unwind at the interrupt. > The PEBS record is always at an IP BEFORE or EQUAL to the interrupted IP. The stack at PEBS may be gone in case the PEBS sample was captured at the epilogue of the function where sp/rbp are modified. > Adding a previous IP on top of a later unwind gives a completely > insane/broken call-stacks. I agree that using the interrupted IP is the most reliable thing to do. You can get the callstack at the PEBS sample with LBR callstack on Icelake because PEBS can record LBR. I am hoping this works with the existing code.