From: Ravi Bangoria <ravi.bangoria@amd.com>
To: <peterz@infradead.org>
Cc: <ravi.bangoria@amd.com>, <acme@kernel.org>, <irogers@google.com>,
<jolsa@kernel.org>, <namhyung@kernel.org>, <bp@alien8.de>,
<x86@kernel.org>, <linux-perf-users@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <sandipan.das@amd.com>,
<ananth.narayan@amd.com>, <santosh.shukla@amd.com>
Subject: [PATCH] perf/amd: Prevent grouping of IBS events
Date: Tue, 20 Jun 2023 14:46:03 +0530 [thread overview]
Message-ID: <20230620091603.269-1-ravi.bangoria@amd.com> (raw)
IBS PMUs can have only one event active at any point in time. Restrict
grouping of multiple IBS events.
Reported-by: Sandipan Das <sandipan.das@amd.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
---
arch/x86/events/amd/ibs.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 371014802191..74e664266753 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -247,11 +247,33 @@ int forward_event_to_ibs(struct perf_event *event)
return -ENOENT;
}
+/*
+ * Grouping of IBS events is not possible since IBS can have only
+ * one event active at any point in time.
+ */
+static int validate_group(struct perf_event *event)
+{
+ struct perf_event *sibling;
+
+ if (event->group_leader == event)
+ return 0;
+
+ if (event->group_leader->pmu == event->pmu)
+ return -EINVAL;
+
+ for_each_sibling_event(sibling, event->group_leader) {
+ if (sibling->pmu == event->pmu)
+ return -EINVAL;
+ }
+ return 0;
+}
+
static int perf_ibs_init(struct perf_event *event)
{
struct hw_perf_event *hwc = &event->hw;
struct perf_ibs *perf_ibs;
u64 max_cnt, config;
+ int ret;
perf_ibs = get_ibs_pmu(event->attr.type);
if (!perf_ibs)
@@ -265,6 +287,10 @@ static int perf_ibs_init(struct perf_event *event)
if (config & ~perf_ibs->config_mask)
return -EINVAL;
+ ret = validate_group(event);
+ if (ret)
+ return ret;
+
if (hwc->sample_period) {
if (config & perf_ibs->cnt_mask)
/* raw max_cnt may not be set */
--
2.41.0
next reply other threads:[~2023-06-20 9:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 9:16 Ravi Bangoria [this message]
2023-06-20 16:44 ` [PATCH] perf/amd: Prevent grouping of IBS events Ian Rogers
2023-06-21 3:27 ` Ravi Bangoria
2023-06-21 6:23 ` [PATCH] perf evsel amd: Fix IBS error message Ravi Bangoria
2023-06-21 22:33 ` Namhyung Kim
2023-06-22 5:27 ` Ravi Bangoria
2023-06-22 5:38 ` Namhyung Kim
2023-06-21 22:50 ` [PATCH] perf/amd: Prevent grouping of IBS events Namhyung Kim
2023-06-22 3:30 ` Ravi Bangoria
2023-06-22 5:09 ` Ian Rogers
2023-06-22 5:39 ` Ravi Bangoria
2023-06-22 5:44 ` Ian Rogers
2023-06-22 5:49 ` Ravi Bangoria
2023-07-10 8:37 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230620091603.269-1-ravi.bangoria@amd.com \
--to=ravi.bangoria@amd.com \
--cc=acme@kernel.org \
--cc=ananth.narayan@amd.com \
--cc=bp@alien8.de \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=sandipan.das@amd.com \
--cc=santosh.shukla@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).