Skip to content

Commit 232b82d

Browse files
athira-rajeevacmel
authored andcommitted
perf test: Update event group check for support of uncore event
The event group test checks group creation for combinations of hw, sw and uncore PMU events. Some of the uncore pmus may require additional permission to access the counters. For example, in case of hv_24x7, partition need to have permissions to access hv_24x7 pmu counters. If not, event_open will fail. Hence add a sanity check to see if event_open succeeds before proceeding with the test. Fixes: 9d9b22b ("perf test: Add event group test for events in multiple PMUs") Signed-off-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com> Acked-by: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Disha Goel <disgoel@linux.ibm.com> Cc: Ian Rogers <irogers@google.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: linuxppc-dev@lists.ozlabs.org Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nageswara R Sastry <rnsastry@linux.ibm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Link: https://lore.kernel.org/r/20221207165815.774-1-atrajeev@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent b9a49f8 commit 232b82d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tools/perf/tests/event_groups.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int event_open(int type, unsigned long config, int group_fd)
5151
static int setup_uncore_event(void)
5252
{
5353
struct perf_pmu *pmu;
54-
int i;
54+
int i, fd;
5555

5656
if (list_empty(&pmus))
5757
perf_pmu__scan(NULL);
@@ -62,6 +62,18 @@ static int setup_uncore_event(void)
6262
pr_debug("Using %s for uncore pmu event\n", pmu->name);
6363
types[2] = pmu->type;
6464
configs[2] = uncore_pmus[i].config;
65+
/*
66+
* Check if the chosen uncore pmu event can be
67+
* used in the test. For example, incase of accessing
68+
* hv_24x7 pmu counters, partition should have
69+
* additional permissions. If not, event open will
70+
* fail. So check if the event open succeeds
71+
* before proceeding.
72+
*/
73+
fd = event_open(types[2], configs[2], -1);
74+
if (fd < 0)
75+
return -1;
76+
close(fd);
6577
return 0;
6678
}
6779
}

0 commit comments

Comments
 (0)