Skip to content

Commit 3efbb45

Browse files
committed
Merge: perf test: Update event_groups test to use instructions
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6831 JIRA: https://issues.redhat.com/browse/RHEL-80165 Signed-off-by: Michael Petlan <[email protected]> Approved-by: ashelat <[email protected]> Approved-by: Čestmír Kalina <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Jan Stancek <[email protected]>
2 parents 7d09e9a + b63a254 commit 3efbb45

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

tools/perf/tests/event_groups.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
#include "header.h"
1111
#include "../perf-sys.h"
1212

13-
/* hw: cycles, sw: context-switch, uncore: [arch dependent] */
13+
/* hw: cycles,instructions sw: context-switch, uncore: [arch dependent] */
1414
static int types[] = {0, 1, -1};
1515
static unsigned long configs[] = {0, 3, 0};
16+
static unsigned long configs_hw[] = {1};
1617

1718
#define NR_UNCORE_PMUS 5
1819

@@ -93,7 +94,18 @@ static int run_test(int i, int j, int k)
9394
return erroneous ? 0 : -1;
9495
}
9596

96-
sibling_fd2 = event_open(types[k], configs[k], group_fd);
97+
/*
98+
* if all three events (leader and two sibling events)
99+
* are hardware events, use instructions as one of the
100+
* sibling event. There is event constraint in powerpc that
101+
* events using same counter cannot be programmed in a group.
102+
* Since PERF_COUNT_HW_INSTRUCTIONS is a generic hardware
103+
* event and present in all platforms, lets use that.
104+
*/
105+
if (!i && !j && !k)
106+
sibling_fd2 = event_open(types[k], configs_hw[k], group_fd);
107+
else
108+
sibling_fd2 = event_open(types[k], configs[k], group_fd);
97109
if (sibling_fd2 == -1) {
98110
close(sibling_fd1);
99111
close(group_fd);
@@ -124,9 +136,18 @@ static int test__event_groups(struct test_suite *text __maybe_unused, int subtes
124136
if (r)
125137
ret = TEST_FAIL;
126138

127-
pr_debug("0x%x 0x%lx, 0x%x 0x%lx, 0x%x 0x%lx: %s\n",
128-
types[i], configs[i], types[j], configs[j],
129-
types[k], configs[k], r ? "Fail" : "Pass");
139+
/*
140+
* For all three events as HW events, second sibling
141+
* event is picked from configs_hw. So print accordingly
142+
*/
143+
if (!i && !j && !k)
144+
pr_debug("0x%x 0x%lx, 0x%x 0x%lx, 0x%x 0x%lx: %s\n",
145+
types[i], configs[i], types[j], configs[j],
146+
types[k], configs_hw[k], r ? "Fail" : "Pass");
147+
else
148+
pr_debug("0x%x 0x%lx, 0x%x 0x%lx, 0x%x 0x%lx: %s\n",
149+
types[i], configs[i], types[j], configs[j],
150+
types[k], configs[k], r ? "Fail" : "Pass");
130151
}
131152
}
132153
}

0 commit comments

Comments
 (0)