Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2827596lqp; Mon, 25 Mar 2024 10:16:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfJQ6sZTKH4UPrBkxUhv7QL4puGElo1DXav1FUlnMfTanDzbYAK25kjT4yMWdXis388bWIl6csCjsZyYNj1f2CtvERdGe5xFUB+VQwfA== X-Google-Smtp-Source: AGHT+IHQJM5TNOOXv17V/lXEeu6QVmDi6EIpdQqjwFul6eDVc7ko+vI/aZ0XKXFmFwy+WYHj4LLg X-Received: by 2002:a05:6a21:6d97:b0:1a3:8a93:aa76 with SMTP id wl23-20020a056a216d9700b001a38a93aa76mr8999110pzb.44.1711386966683; Mon, 25 Mar 2024 10:16:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711386966; cv=pass; d=google.com; s=arc-20160816; b=pPDUMMaUHGCyfZ/iuvRnaXI79dsVXS7XnZ/a+/skJQjm0TE4VgNbEoJhyNHjk9rKnB PtmxQgYE85nC3N4uDl8LfyG+Do8XKt0ACrSQ6020RHJADFJz5YxzpSrTcc8CxLMfcuTG Cz8drFKJ5ip6EQ9lrPxM+zvhcOHCbqLbfz/IOzw0HU3+PINmNeo0mHZli8uz31Hipqu+ OEqb0YhBN6sbtP/fAEC4HeSkJg/WoMQ+tYS0C+14PtodRrujjaLwx9nkme0t+lJAS6Bo NEbNsUOTO1zLlFE6JlpRWe40Yfo6wbcKUOXxN8LA9RVCMOT52IB6QgkIpCXszqT1C6bZ 1hjQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=1cBI7Cp1vH/oBUW0wsybTtTvF3/j1JbyDwHKAuM7m2k=; fh=8Vtzy/VB1rbRFa+4ba5MgfvN82IpndldC8wgFMigx4s=; b=WK13cV6gFiZV7mOHVcYoIzGZhiE2FEUNF8hhNZVTerQezUQyHFlJ3Rc8eoSA+1CLfu P4gvs9FhOyiw9/4um49r038Mv5UNOO7SKwyDX3RWDlFFF+TGx73mYR5qnClYpDTDq40b RFKa4zJJmpZVzW3vTKKTkKyGGQXP6Da2X0+S5O5AtTGBSt/nwBo2fLa+NchLcYd0rAGK d97iwmbv446OgA9T8eMQi+YA/nXAtU1EyI7UogbvUkIcHZ0BMmKBqyYfoZ0nCCja3V25 szCcqO59DvuYwaRrsFNV8aaig53k8ztevLVgf8AZ75k7lULmAGzQ3z4h2w95aNV4keLK u7BA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FzNRCvtB; dkim=neutral (no key) header.i=@linutronix.de; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-116835-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p31-20020a056a000a1f00b006e6500001e9si5540637pfh.356.2024.03.25.10.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:16:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116835-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FzNRCvtB; dkim=neutral (no key) header.i=@linutronix.de; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-116835-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 37DDDB63826 for ; Mon, 25 Mar 2024 14:25:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A3D61B883D; Mon, 25 Mar 2024 11:07:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FzNRCvtB"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="d2HjPGZd" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 080966E616; Mon, 25 Mar 2024 10:29:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711362564; cv=none; b=DxIeMFm5qT+d5rKmrXO47YDJcO+q3Rp3pDJX4actvlcaHXjuglqewechCBKEWzkiPqQZDcA4BuIA2H8HMLQ1/RQCNcprIoNqqCiU3oXVx0VjG/dwYQ0kLU/FXZMOWjKfhbOq1aw477neSrLubaL/9tqMnnpnG32/Tnu29UMw6s8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711362564; c=relaxed/simple; bh=mLpBg2nWRyz96DYpNS5I78B+tK+MUUvH4ycRNC28LKY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=dS5dyzXoqUVd6ml6Ot1Oa71BqTHiPoKA2d+mVni1HwJlowMJ44uwGv02gDmq0OOIJiYIhC/XnLDW9RYLubUHgZQ3xHAtaTOfE4Hnl72S3DmYWglcE7as5QbxcwHwq2Ahjg95xdE+lmdXK4PoH6K3hTXWFnoiMWAcpGlIT8uHBgQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FzNRCvtB; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=d2HjPGZd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 25 Mar 2024 10:29:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711362560; 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=1cBI7Cp1vH/oBUW0wsybTtTvF3/j1JbyDwHKAuM7m2k=; b=FzNRCvtB5/4UyroB0IZ9FPYSZLMQK6VPDQ5cHmKjltRqckY6HBtNYw2qMMudIB2i+YnBJK 3tyddrXw0gPRHpGz69H07cWwFhFlam2j9aDapbqp1sAs1T4Kf/+IdlSGuWhnvajCAf+EqB IjxdCeiVf3EzWpEYEtMit35MDkfrX2nlrVqJjYhJgqFioTolp/IpYlqg0/0Gr6U6wCq0fl lJFovWsHETQjAxSAC6Z+ItUMMlKm0pT8TTlwXnjjPynpBOkygafHVwEjxA9NdO1x46vRl/ zH2TSA91QZMEYDQsOya0/Bu8mMkxKPq+c7ZRX0mETa6bh77awp+lptSpeXRcmw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711362560; 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=1cBI7Cp1vH/oBUW0wsybTtTvF3/j1JbyDwHKAuM7m2k=; b=d2HjPGZdi2ONkdmVkIGf8TcGCqJs0zcH6E7pTpdP6O/NNRwx4Vv8+4v1TftcSp5AT7RxLy P5OTtEnstvkiDtAw== From: "tip-bot2 for Sandipan Das" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf/x86/amd/core: Define a proper ref-cycles event for Zen 4 and later Cc: Sandipan Das , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3C089155f19f7c7e65aeb1caa727a882e2ca9b8b04=2E17113?= =?utf-8?q?52180=2Egit=2Esandipan=2Edas=40amd=2Ecom=3E?= References: =?utf-8?q?=3C089155f19f7c7e65aeb1caa727a882e2ca9b8b04=2E171135?= =?utf-8?q?2180=2Egit=2Esandipan=2Edas=40amd=2Ecom=3E?= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171136255986.10875.1380945659061646748.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 563bdbac10e5abe49c332b380fedd8ee7dc72b05 Gitweb: https://git.kernel.org/tip/563bdbac10e5abe49c332b380fedd8ee7dc72b05 Author: Sandipan Das AuthorDate: Mon, 25 Mar 2024 13:17:54 +05:30 Committer: Ingo Molnar CommitterDate: Mon, 25 Mar 2024 11:19:04 +01:00 perf/x86/amd/core: Define a proper ref-cycles event for Zen 4 and later Add the "ref-cycles" event for AMD processors based on Zen 4 and later microarchitectures. The backing event is based on PMCx120 which counts cycles not in halt state in P0 frequency (same as MPERF). Signed-off-by: Sandipan Das Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/089155f19f7c7e65aeb1caa727a882e2ca9b8b04.1711352180.git.sandipan.das@amd.com --- arch/x86/events/amd/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c index af8add6..985ef3b 100644 --- a/arch/x86/events/amd/core.c +++ b/arch/x86/events/amd/core.c @@ -273,8 +273,23 @@ static const u64 amd_zen2_perfmon_event_map[PERF_COUNT_HW_MAX] = [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00a9, }; +static const u64 amd_zen4_perfmon_event_map[PERF_COUNT_HW_MAX] = +{ + [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, + [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, + [PERF_COUNT_HW_CACHE_REFERENCES] = 0xff60, + [PERF_COUNT_HW_CACHE_MISSES] = 0x0964, + [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2, + [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3, + [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00a9, + [PERF_COUNT_HW_REF_CPU_CYCLES] = 0x100000120, +}; + static u64 amd_pmu_event_map(int hw_event) { + if (cpu_feature_enabled(X86_FEATURE_ZEN4) || boot_cpu_data.x86 >= 0x1a) + return amd_zen4_perfmon_event_map[hw_event]; + if (cpu_feature_enabled(X86_FEATURE_ZEN2) || boot_cpu_data.x86 >= 0x19) return amd_zen2_perfmon_event_map[hw_event];