Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp236338iob; Mon, 2 May 2022 18:05:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw31Pu3Jp0yREbvYGIv9oKsgnX21BvZi4hj8HEqNIYtEJdyoK+NXgKM0jy9H/75LwxBtQ6R X-Received: by 2002:a17:90b:314c:b0:1dc:767d:a7d9 with SMTP id ip12-20020a17090b314c00b001dc767da7d9mr2053514pjb.99.1651539928436; Mon, 02 May 2022 18:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651539928; cv=none; d=google.com; s=arc-20160816; b=MIb5+HlvPfaKI6LCt1wUp3Uwh+ZEpkd3VHo8+xS+aPy06laOKv6NwfAvGDStEHZHEc dCW4Kb3DV2H8B2UpLZcoUX+YRBPY6uLre+T8oDOYTBUhBsgbdpJI59D8qUzKWhjymsFm tchPksB43dk9YXRoKC68OKXu8xBPpf6h1Z81beFZrl42xXw2+JCZWNeYVgqoebNzQbFS os1LFs/fspHkn5JAdI6F168fzq87gYacP/ulteeqwU6wv6TbtGHyW5fCXA+IHUaeGNFd u45PwSThEN8+GT117W6bCvE64AGYbVcaEpzPm2DdRqovI2TvCIReKiRKj9/uiD3FGZLq aung== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=mbp17fyLwlEyz2BeXAlp1mUHkc9KspsBlTpY+NSuEQc=; b=VD87ACea5oXfOHtIdRwi1evpg83EdA9mLgKC4GiqFCHuvdM7IbIaFo/oTAm939Ad2P HZumJVVcBdd0/DtnvUEjkK/06BH9lXYyfLrMPvxmRzqLDiFqfKp1P0hm9AOg6x04npVp j2IXvmgblsXLkWH2Bk/0qcO54jQ0cdPB76xr32ZZYL8ZkQWsDnzzIXFS09PrUjhs9OV0 1BbH6JxPH0sStCsVhzEEIaucmhhROehC/QeMjd89qU2230CIkPgNOjXgHvaSsKfZZvsr 06gSmOAEMIvr72jfQDLexp3zex8/5y1bHsHSPAa3V38JFuJiCwMi9MKrTz8dwNEWIzOn w9lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kzsTcxCu; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id me13-20020a17090b17cd00b001d9aee225e1si931162pjb.169.2022.05.02.18.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:05:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kzsTcxCu; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78065579B1; Mon, 2 May 2022 17:48:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380715AbiD2UcL (ORCPT + 99 others); Fri, 29 Apr 2022 16:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232546AbiD2UcJ (ORCPT ); Fri, 29 Apr 2022 16:32:09 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9760CAFADA; Fri, 29 Apr 2022 13:28:50 -0700 (PDT) Date: Fri, 29 Apr 2022 20:28:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651264129; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mbp17fyLwlEyz2BeXAlp1mUHkc9KspsBlTpY+NSuEQc=; b=kzsTcxCuv2rWHVevdeL9XJ079k0LuXRDgDKg24dQOF++XUVH0H7pZvngSeiXnKxFP7a/mK viG2Wd0VYkMXDsTdkjhlchtWAJoJX/idq0SIn2w3hF2galPae/hh6QsN/rJikDvJD1kB2S /fhhOCbwzDw3tbN4b8sjikskvXwRU27R2ja00IzbCb3qgDdhsJ1NUr8PiNMtP7CeygzTTS M8zH3kdJ0FAvbQlLZ+LJ/x8MwHLsBvgVBrysqeG64HXTiof84iNKZ/USIoaaOWFHwdwRC9 AdFdW6DE9hJmb323z9vdhAMut79qKs/2SH7cHaT8QbMEw9K+qgnQty6rZOKSaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651264129; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mbp17fyLwlEyz2BeXAlp1mUHkc9KspsBlTpY+NSuEQc=; b=aRCgbWZ9tZwgj2/LAlBDKOUUvO+M6xtqLm8A33Ryo5ZPB5dyk0FvcB18UoNlv0FoZX4+qQ xQ5JILHyRGSdRrBw== From: "tip-bot2 for Ravi Bangoria" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/amd/ibs: Use interrupt regs ip for stack unwinding Cc: Dmitry Monakhov , Peter Zijlstra , Ravi Bangoria , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220429051441.14251-1-ravi.bangoria@amd.com> References: <20220429051441.14251-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Message-ID: <165126412736.4207.15087781273067031127.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 1989455e0196f59741d81601284a6058acfaf225 Gitweb: https://git.kernel.org/tip/1989455e0196f59741d81601284a6058acfaf225 Author: Ravi Bangoria AuthorDate: Fri, 29 Apr 2022 10:44:41 +05:30 Committer: Peter Zijlstra CommitterDate: Fri, 29 Apr 2022 11:06:28 +02:00 perf/amd/ibs: Use interrupt regs ip for stack unwinding IbsOpRip is recorded when IBS interrupt is triggered. But there is a skid from the time IBS interrupt gets triggered to the time the interrupt is presented to the core. Meanwhile processor would have moved ahead and thus IbsOpRip will be inconsistent with rsp and rbp recorded as part of the interrupt regs. This causes issues while unwinding stack using the ORC unwinder as it needs consistent rip, rsp and rbp. Fix this by using rip from interrupt regs instead of IbsOpRip for stack unwinding. Fixes: ee9f8fce99640 ("x86/unwind: Add the ORC unwinder") Reported-by: Dmitry Monakhov Suggested-by: Peter Zijlstra Signed-off-by: Ravi Bangoria Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220429051441.14251-1-ravi.bangoria@amd.com --- arch/x86/events/amd/ibs.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 9739019..11e8b49 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -304,6 +304,16 @@ static int perf_ibs_init(struct perf_event *event) hwc->config_base = perf_ibs->msr; hwc->config = config; + /* + * rip recorded by IbsOpRip will not be consistent with rsp and rbp + * recorded as part of interrupt regs. Thus we need to use rip from + * interrupt regs while unwinding call stack. Setting _EARLY flag + * makes sure we unwind call-stack before perf sample rip is set to + * IbsOpRip. + */ + if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) + event->attr.sample_type |= __PERF_SAMPLE_CALLCHAIN_EARLY; + return 0; } @@ -687,6 +697,14 @@ fail: data.raw = &raw; } + /* + * rip recorded by IbsOpRip will not be consistent with rsp and rbp + * recorded as part of interrupt regs. Thus we need to use rip from + * interrupt regs while unwinding call stack. + */ + if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) + data.callchain = perf_callchain(event, iregs); + throttle = perf_event_overflow(event, &data, ®s); out: if (throttle) {