Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2392454lqp; Sun, 24 Mar 2024 17:26:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVy8UNlElwTwRvzFbH/lZdDFbx0yuRToqTWfNCgXBfytWILima3hpNhqJuAnTWSpVJQZ8J6n7s2Jy5aqgJodZkLPs5WTT82j7eQL7Y0EQ== X-Google-Smtp-Source: AGHT+IH2rWpiP7KZmaI4zgqzncJ5rrER7/jvK1W8lEGpjRTf9/dcvoaZZ6a6RrlQhPLJUBkqho+D X-Received: by 2002:a17:907:9958:b0:a46:7794:2c00 with SMTP id kl24-20020a170907995800b00a4677942c00mr3780301ejc.40.1711326406660; Sun, 24 Mar 2024 17:26:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711326406; cv=pass; d=google.com; s=arc-20160816; b=D+HlzgCosJyhE4KzNqtVrU54g4VIPekFLTb4Jc0ULZOs6z34DgxVj3IC05HrED7dFR McqLh0cgDiTuyjP6MrE6GJwVQb8GCR9rWWO2cYEXcLTqC6efT/DgqAKAOUC0LM4LR3Mo TwyW5KABbgFwcFa2X2MM9n6FLOW59pByaL54ZsYu+Vr2pIhHj7E3UNc6T3kPuVRNKucP qz4gf1oojo7cge8tffB3JZv+jKua9kULxTXED9b651thQhOw9ZfxHb3bBvbKYttRqN7q XigHYTSEb/whINKVOPNkmiCdTdt1sYJCrKX5KHFLAuikQvUYn5JvcK0GQlDP8NPNamdm 0wsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JvVtjljU3h+BYsiZrJfH4ilBS9SJ7IPbW/7uDnd0hRs=; fh=3B+4+PC1bK3DQoRejt1ggWNkkCYu6FazE8e0yuSy3i4=; b=XENd5x7ADeK82Nr8a5TrwP2mgFEhGXbmXkIEdmbtqxQffB0R7grprtYO04MLZqLufi K7zBzN53pX9hOdsMS1Tcp1mW4ieY/pnOY//Rtr09sZay5g5RVE2Udwi4OlNYUac5JQU1 AcTAYsTtZYofLNOPsC6LogT5gDCxBlGW7jsFmihltWzw2F1L5OLBZimDA9WCMo2sSvXf 3gXB2Ixn9N3cDvo7Q9GaYi0NUV9ygBT7y+OTHWsPP2pvLmIKoH/LCpYj5SEmor4zRmrp gaahjcOMGTrZUa44d4HQv/ORxNBsJRFyI5HmLc8AlPwR5/DJyBrQ4BBeZAw5RPzMyWPl P3pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BpP4OYIq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113397-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113397-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a1-20020a1709066d4100b00a4679ce18f0si2060944ejt.747.2024.03.24.17.26.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:26:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113397-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BpP4OYIq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113397-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113397-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3CD7A1F29484 for ; Mon, 25 Mar 2024 00:26:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 412FE1A37B7; Sun, 24 Mar 2024 22:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BpP4OYIq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2CF2A1A379B; Sun, 24 Mar 2024 22:43:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320199; cv=none; b=iKjbJEfcWPaLnY1CWg2EtT2D3w35A88zR7V3G8bxW40JRW2gf4A0nzkTS5z8WiwYTbxtml9/tXI4LEskB00SoCeVIXyUZLrnWR/P5MNhvaUsdKQzj2RObiLVwgbF7Zx+LdYWmxKnVfpuAeCkv3lD9Llic8MuhBMJAsyU33Dgxng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320199; c=relaxed/simple; bh=dgPcNLZuZaYRNBaj2vBUMExAJm+g8A7+HV9u2F7EcWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kELG/l41UjYjHqcuvUMykeKV52+eid5NhFyivnQ1WTmHrXW0IiEW9fSvPAOhLxuHSfAYWER4tjkmeB7mAMBmS2Atprfji4wyaJNC4pNWlI9iPwYDYTQ9d7K1nk2bv5NB8zT2uG9rdnBOtIYssDnoHYZ4xiz8sfacHRySNt1ScHk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BpP4OYIq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 091A9C43399; Sun, 24 Mar 2024 22:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320199; bh=dgPcNLZuZaYRNBaj2vBUMExAJm+g8A7+HV9u2F7EcWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BpP4OYIqmXpuzOzgpZ/UdhrLtpRzDB4mF89pmnBwrLGxgPeyjd5NrgOiTwUNG5KfR lYrx5GAjtwaTopjeL2pnnfx06SnPmN47V7q/5e7r4kHsUcmAkX73TPEGKwQOJAYaJ+ F3UzehG8lhUDGy1rLi9Nr4cAdwmlcB2jpS1etkbtYQRJZ3xuN5zCckfO403cbdPqeW qYxNIlMTODvpaMLHKW8uVlrFZYopslqWkbxSwxfxWnmwATDGrx4bVrHzYhZuR0kylh au72vAXFwwGxxiodlGikogps5M8DQX46wpNEXem902bSk0tLJt12U2pWAv2KzS8Wrh IQ6lsrRt2Z0bg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sandipan Das , Ian Rogers , ananth.narayan@amd.com, ravi.bangoria@amd.com, eranian@google.com, Namhyung Kim , Sasha Levin Subject: [PATCH 6.8 506/715] perf vendor events amd: Fix Zen 4 cache latency events Date: Sun, 24 Mar 2024 18:31:25 -0400 Message-ID: <20240324223455.1342824-507-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Sandipan Das [ Upstream commit 498d3486376befe4e82b5334d44bbc86b1982ee4 ] L3PMCx0AC and L3PMCx0AD, used in l3_xi_sampled_latency* events, have a quirk that requires them to be programmed with SliceId set to 0x3. Without this, the events do not count at all and affects dependent metrics such as l3_read_miss_latency. If ThreadMask is not specified, the amd-uncore driver internally sets ThreadMask to 0x3, EnAllCores to 0x1 and EnAllSlices to 0x1 but does not set SliceId. Since SliceId must also be set to 0x3 in this case, specify all the other fields explicitly. E.g. $ sudo perf stat -e l3_xi_sampled_latency.all,l3_xi_sampled_latency_requests.all -a sleep 1 Before: Performance counter stats for 'system wide': 0 l3_xi_sampled_latency.all 0 l3_xi_sampled_latency_requests.all 1.005155399 seconds time elapsed After: Performance counter stats for 'system wide': 921,446 l3_xi_sampled_latency.all 54,210 l3_xi_sampled_latency_requests.all 1.005664472 seconds time elapsed Fixes: 5b2ca349c313 ("perf vendor events amd: Add Zen 4 uncore events") Signed-off-by: Sandipan Das Reviewed-by: Ian Rogers Cc: ananth.narayan@amd.com Cc: ravi.bangoria@amd.com Cc: eranian@google.com Signed-off-by: Namhyung Kim Link: https://lore.kernel.org/r/20240301084431.646221-1-sandipan.das@amd.com Signed-off-by: Sasha Levin --- .../pmu-events/arch/x86/amdzen4/cache.json | 56 +++++++++++++++++++ tools/perf/pmu-events/jevents.py | 4 ++ 2 files changed, 60 insertions(+) diff --git a/tools/perf/pmu-events/arch/x86/amdzen4/cache.json b/tools/perf/pmu-events/arch/x86/amdzen4/cache.json index ecbe9660b2b31..e6d710cf3ce29 100644 --- a/tools/perf/pmu-events/arch/x86/amdzen4/cache.json +++ b/tools/perf/pmu-events/arch/x86/amdzen4/cache.json @@ -676,6 +676,10 @@ "EventCode": "0xac", "BriefDescription": "Average sampled latency when data is sourced from DRAM in the same NUMA node.", "UMask": "0x01", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -683,6 +687,10 @@ "EventCode": "0xac", "BriefDescription": "Average sampled latency when data is sourced from DRAM in a different NUMA node.", "UMask": "0x02", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -690,6 +698,10 @@ "EventCode": "0xac", "BriefDescription": "Average sampled latency when data is sourced from another CCX's cache when the address was in the same NUMA node.", "UMask": "0x04", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -697,6 +709,10 @@ "EventCode": "0xac", "BriefDescription": "Average sampled latency when data is sourced from another CCX's cache when the address was in a different NUMA node.", "UMask": "0x08", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -704,6 +720,10 @@ "EventCode": "0xac", "BriefDescription": "Average sampled latency when data is sourced from extension memory (CXL) in the same NUMA node.", "UMask": "0x10", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -711,6 +731,10 @@ "EventCode": "0xac", "BriefDescription": "Average sampled latency when data is sourced from extension memory (CXL) in a different NUMA node.", "UMask": "0x20", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -718,6 +742,10 @@ "EventCode": "0xac", "BriefDescription": "Average sampled latency from all data sources.", "UMask": "0x3f", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -725,6 +753,10 @@ "EventCode": "0xad", "BriefDescription": "L3 cache fill requests sourced from DRAM in the same NUMA node.", "UMask": "0x01", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -732,6 +764,10 @@ "EventCode": "0xad", "BriefDescription": "L3 cache fill requests sourced from DRAM in a different NUMA node.", "UMask": "0x02", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -739,6 +775,10 @@ "EventCode": "0xad", "BriefDescription": "L3 cache fill requests sourced from another CCX's cache when the address was in the same NUMA node.", "UMask": "0x04", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -746,6 +786,10 @@ "EventCode": "0xad", "BriefDescription": "L3 cache fill requests sourced from another CCX's cache when the address was in a different NUMA node.", "UMask": "0x08", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -753,6 +797,10 @@ "EventCode": "0xad", "BriefDescription": "L3 cache fill requests sourced from extension memory (CXL) in the same NUMA node.", "UMask": "0x10", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -760,6 +808,10 @@ "EventCode": "0xad", "BriefDescription": "L3 cache fill requests sourced from extension memory (CXL) in a different NUMA node.", "UMask": "0x20", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" }, { @@ -767,6 +819,10 @@ "EventCode": "0xad", "BriefDescription": "L3 cache fill requests sourced from all data sources.", "UMask": "0x3f", + "EnAllCores": "0x1", + "EnAllSlices": "0x1", + "SliceId": "0x3", + "ThreadMask": "0x3", "Unit": "L3PMC" } ] diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 53ab050c8fa43..ce846f29c08d6 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -356,6 +356,10 @@ class JsonEvent: ('UMask', 'umask='), ('NodeType', 'type='), ('RdWrMask', 'rdwrmask='), + ('EnAllCores', 'enallcores='), + ('EnAllSlices', 'enallslices='), + ('SliceId', 'sliceid='), + ('ThreadMask', 'threadmask='), ] for key, value in event_fields: if key in jd and jd[key] != '0': -- 2.43.0