Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2804337lqp; Mon, 25 Mar 2024 09:37:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXuvLJGnR5OX9KETf11MX/dPB2TV+tfF+sSzFOkkz5yz3VjeTZRG5Zta8RcasDZJnMeVGb5dfYMM3WspYIIO2Oofgmpo6CqDgKsgrZszw== X-Google-Smtp-Source: AGHT+IGPz+sdGHU+p+dPf2LR7wToVGRmvEs2jt2A8ZNRGGnTt3U7LtR2KyLIK/FSGUnND6XCF0zc X-Received: by 2002:a05:622a:5286:b0:431:3d52:2fe0 with SMTP id dr6-20020a05622a528600b004313d522fe0mr8683032qtb.56.1711384647805; Mon, 25 Mar 2024 09:37:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711384647; cv=pass; d=google.com; s=arc-20160816; b=E4shVmQ0ccSo4EslurEQL6MkTdX/pD9vdACYVJIMrjqm2GIQxrtVspOU5W8b5uMVhw C9lDtiTQ/1i6ve+54oUcIwrDKbNY/49oi6vhSQAJ0aWuLTQ9U/Q72pbiYEXPNphFkp5P Bw7RK7zNxSClGmBA37dA8umtmPfYcFIT7/ueoItzkmtHXmnZCwmsRH9zAZHGsp3QTIxG 6pJ4PHKMSMbuOBsHOTCs9sVYJg25f//Zhk0p3TbrwzuMPtBWNTcmj6UgOxAnfVk1PSg1 cPue3tpxjfziRmLwOxoaXgigleG7N08WaM3w9LaZHjR0tArt+0/8deW/TKp2SA3NqDkg T59A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=+8YEj37U1dlb1vZbCBV1T/aHB6t0dDPgqa1lum+Wmfs=; fh=ZSUDQmldueHzgUzp+PP7ZERj0O24EU+/ol7Bict9zZY=; b=aQi/OgFrbnkYEJhYEnbXZeH4JqS0kvyj2twAQjGSJVFTu73ULb/zqvnJJiWJewJj/F 0M46zgNm+vwHuRI0WNh+/dL+npXp6M0Q7H98zS2s7ooKpCdBKyb/W5hqZerLQCXAyOBr 1oCKcRaJZQn66daeFXW+zGNMvNDcwYwsu5+/Qx8Rg7+JaTeQX3yzYOAnkRJuqd3wqF18 YU8UJ++rgVvJLkL6CqQlcQDhD5lWFlMURHe/KEYCjFsXzEsrQ5SYnJ9iB5Q1D7zcQ928 TJolA/gvsshTotocc/YucEv/Hwnr0GHITpwVacJvS2nctTt+2JvxXstL+SAem63Fq+yK Sgdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gQ4C3N0h; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-117264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r4-20020ac85c84000000b00430caff98e2si5592852qta.242.2024.03.25.09.37.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 09:37:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gQ4C3N0h; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-117264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2041D1C60313 for ; Mon, 25 Mar 2024 16:32:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 017FA1649A5; Mon, 25 Mar 2024 14:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gQ4C3N0h" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A84E84047 for ; Mon, 25 Mar 2024 14:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711377279; cv=none; b=j0YmdyrMrx9QKzHZvf2gyJf6pLZHkXgPYuXaopYo0RIm4bfQzLcn5fkrNP6pBojEyU6xFiZnSih/Qfb2QQl75HjhIwTiK7D6s9Aj2oFgGgxvX7rMhRZ3YAYjE3WZBEOGNQ8kTdyhIyWVRYsos3ux1hFccz7IfloZmHlvJO061r4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711377279; c=relaxed/simple; bh=FSU8nxuLRZyEBR/sJUxs+lckFjB8qs8rRlLhFigJQpw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FjOBG0TGZ9Nr1mOhjsLEq4SOt7nOxUzUlw2jv2e2gshFNnfDU6LTybw5MJNO1dL6f7GYDHJxtHInCGz4WCI6bA6QNlmDixBPZmiVDk5fFpCx4/VbFLOKaBED667UY+AB/OpRlUV9Zm7wouPABO6JkQRHyoPBybeHXvrT1BSHYeE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=gQ4C3N0h; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1e058b9e479so232505ad.0 for ; Mon, 25 Mar 2024 07:34:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711377277; x=1711982077; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+8YEj37U1dlb1vZbCBV1T/aHB6t0dDPgqa1lum+Wmfs=; b=gQ4C3N0hzzoyTpZ6jmCL2FRwBVDyi/d2ksDO88M1MMOvjLg5L9mVLhnHlrZBwVRAUR Nxe6m7a8l59KFny6qqqfwTY0hSLD7f2SeY0nvzVl5vTfeltrgroW0KtqI2jDmkBhQwef XMij6colOFOzjScm3aeZORc/LdYnRXTirULC8DO7K5hMnxhvU/kZVENgtv9XMZ9dBuKU ibwPEKghuLALJTr9/bJL+i1nW92LQS/STp4P3v8EmPgiSfE7TMXMs1ziEtHHuB16Yp4g YkwRzoXYtA00VhhOlhA/UHQZzynqVln/3XY4wlfetBb/yjk5I9FumZ5TDTUfzs4tsKck 3HIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711377277; x=1711982077; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+8YEj37U1dlb1vZbCBV1T/aHB6t0dDPgqa1lum+Wmfs=; b=SZWCn9rj5fWMegodq1dkKaRSIeOSLLLBEPNLAfA+zE14+kiDwVD3LgnfNQ/BbHqkdQ Ealiqb91nprXbwqHZXmcMpGcz9MXX5cZSqiLOFDly1lIg9o3c82OGjFDrmA6t6wwC+YP FqyFqHJn1pilP8cnltGwi4gvJpWZyA0grOofSbhhoddUBPYyc3Apzj5y/w25kNso1xLM FRFDN1Wa07SE8TT30YOeT81MGFGkkJZvkCeupqXYV2HnPfdQ1o6KZDYphX2V6d1R41sh ih34KIFbUm0UWtOVa4su552Bfb8nxwO8RkYSPN049RaXwCCcD3TJ6tY6LBgkx/ye3PY1 3aHg== X-Forwarded-Encrypted: i=1; AJvYcCVx7uVFs6Gc5YK4J4IFmYpHQ8G29RUXzxG1z+5PRUgrV6HDUGur9CqUVADVHOeCE0m26uh4IZ0uYriiW5qw0397fzbtasJQ//JVY79A X-Gm-Message-State: AOJu0YzNZYJi8tm8FiEgXgcLPPZN7Qvkcpq+rto3AOOWynH5bLTNKpTW gwJQch42iKreZOt/vlYDe2xzBLL/POCUwvWaCQPjpwDxYyChT7EWFpvYXs342ce2OZMBlH17Ly7 iQiHx9AIfd4Sun9XCSgSwBlv6JprHzl2CCkZF X-Received: by 2002:a17:903:2284:b0:1e0:bc64:a37e with SMTP id b4-20020a170903228400b001e0bc64a37emr162922plh.21.1711377276556; Mon, 25 Mar 2024 07:34:36 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <03d7fc8fa2a28f9be732116009025bdec1b3ec97.1711352180.git.sandipan.das@amd.com> In-Reply-To: <03d7fc8fa2a28f9be732116009025bdec1b3ec97.1711352180.git.sandipan.das@amd.com> From: Ian Rogers Date: Mon, 25 Mar 2024 07:34:23 -0700 Message-ID: Subject: Re: [PATCH 1/2] perf/x86/amd/core: Update stalled-cycles-* events for Zen 2 and later To: Sandipan Das Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, peterz@infradead.org, mingo@kernel.org, acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, adrian.hunter@intel.com, tglx@linutronix.de, bp@alien8.de, eranian@google.com, ravi.bangoria@amd.com, ananth.narayan@amd.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 25, 2024 at 12:48=E2=80=AFAM Sandipan Das wrote: > > AMD processors based on Zen 2 and later microarchitectures do not > support PMCx087 (instruction pipe stalls) which is used as the backing > event for "stalled-cycles-frontend" and "stalled-cycles-backend". Use > PMCx0A9 (cycles where micro-op queue is empty) instead to count frontend > stalls and remove the entry for backend stalls since there is no direct > replacement. > > Signed-off-by: Sandipan Das This looks good to me. Should there be a Fixes tag for the sake of backport= s? Reviewed-by: Ian Rogers Thanks, Ian > --- > arch/x86/events/amd/core.c | 20 +++++++++++++++++--- > 1 file changed, 17 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c > index aec16e581f5b..afe4a809f2ed 100644 > --- a/arch/x86/events/amd/core.c > +++ b/arch/x86/events/amd/core.c > @@ -250,7 +250,7 @@ static const u64 amd_perfmon_event_map[PERF_COUNT_HW_= MAX] =3D > /* > * AMD Performance Monitor Family 17h and later: > */ > -static const u64 amd_f17h_perfmon_event_map[PERF_COUNT_HW_MAX] =3D > +static const u64 amd_zen1_perfmon_event_map[PERF_COUNT_HW_MAX] =3D > { > [PERF_COUNT_HW_CPU_CYCLES] =3D 0x0076, > [PERF_COUNT_HW_INSTRUCTIONS] =3D 0x00c0, > @@ -262,10 +262,24 @@ static const u64 amd_f17h_perfmon_event_map[PERF_CO= UNT_HW_MAX] =3D > [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =3D 0x0187, > }; > > +static const u64 amd_zen2_perfmon_event_map[PERF_COUNT_HW_MAX] =3D > +{ > + [PERF_COUNT_HW_CPU_CYCLES] =3D 0x0076, > + [PERF_COUNT_HW_INSTRUCTIONS] =3D 0x00c0, > + [PERF_COUNT_HW_CACHE_REFERENCES] =3D 0xff60, > + [PERF_COUNT_HW_CACHE_MISSES] =3D 0x0964, > + [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] =3D 0x00c2, > + [PERF_COUNT_HW_BRANCH_MISSES] =3D 0x00c3, > + [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] =3D 0x00a9, > +}; > + > static u64 amd_pmu_event_map(int hw_event) > { > - if (boot_cpu_data.x86 >=3D 0x17) > - return amd_f17h_perfmon_event_map[hw_event]; > + if (cpu_feature_enabled(X86_FEATURE_ZEN2) || boot_cpu_data.x86 >= =3D 0x19) > + return amd_zen2_perfmon_event_map[hw_event]; > + > + if (cpu_feature_enabled(X86_FEATURE_ZEN1)) > + return amd_zen1_perfmon_event_map[hw_event]; > > return amd_perfmon_event_map[hw_event]; > } > -- > 2.34.1 >