linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/amd: Prevent grouping of IBS events
@ 2023-06-20  9:16 Ravi Bangoria
  2023-06-20 16:44 ` Ian Rogers
  2023-07-10  8:37 ` [tip: perf/core] " tip-bot2 for Ravi Bangoria
  0 siblings, 2 replies; 14+ messages in thread
From: Ravi Bangoria @ 2023-06-20  9:16 UTC (permalink / raw)
  To: peterz
  Cc: ravi.bangoria, acme, irogers, jolsa, namhyung, bp, x86,
	linux-perf-users, linux-kernel, sandipan.das, ananth.narayan,
	santosh.shukla

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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-07-10  8:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20  9:16 [PATCH] perf/amd: Prevent grouping of IBS events Ravi Bangoria
2023-06-20 16:44 ` 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

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).