Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf test: Update event_groups test to use instructions

In some of the powerpc platforms, event group testcase fails as below:

# perf test -v 'Event groups'
69: Event groups :
--- start ---
test child forked, pid 9765
Using CPUID 0x00820200
Using hv_24x7 for uncore pmu event
0x0 0x0, 0x0 0x0, 0x0 0x0: Fail
0x0 0x0, 0x0 0x0, 0x1 0x3: Pass

The testcase creates various combinations of hw, sw and uncore
PMU events and verify group creation succeeds or fails as expected.
This tests one of the limitation in perf where it doesn't allow
creating a group of events from different hw PMUs.

The testcase starts a leader event and opens two sibling events.
The combination the fails is three hardware events in a group.
"0x0 0x0, 0x0 0x0, 0x0 0x0: Fail"

Type zero and config zero which translates to PERF_TYPE_HARDWARE
and PERF_COUNT_HW_CPU_CYCLE. There is event constraint in powerpc
that events using same counter cannot be programmed in a group.
Here there is one alternative event for cycles, hence one leader
and only one sibling event can go in as a group.

if all three events (leader and two sibling events), are hardware
events, use instructions as one of the sibling event. Since
PERF_COUNT_HW_INSTRUCTIONS is a generic hardware event and present
in all architectures, use this as third event.

Reported-by: Tejas Manhas <Tejas.Manhas1@ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Link: https://lore.kernel.org/r/20250110094620.94976-1-atrajeev@linux.vnet.ibm.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Athira Rajeev and committed by
Namhyung Kim
91b7747d 62892e77

+26 -5
+26 -5
tools/perf/tests/event_groups.c
··· 10 10 #include "header.h" 11 11 #include "../perf-sys.h" 12 12 13 - /* hw: cycles, sw: context-switch, uncore: [arch dependent] */ 13 + /* hw: cycles,instructions sw: context-switch, uncore: [arch dependent] */ 14 14 static int types[] = {0, 1, -1}; 15 15 static unsigned long configs[] = {0, 3, 0}; 16 + static unsigned long configs_hw[] = {1}; 16 17 17 18 #define NR_UNCORE_PMUS 5 18 19 ··· 94 93 return erroneous ? 0 : -1; 95 94 } 96 95 97 - sibling_fd2 = event_open(types[k], configs[k], group_fd); 96 + /* 97 + * if all three events (leader and two sibling events) 98 + * are hardware events, use instructions as one of the 99 + * sibling event. There is event constraint in powerpc that 100 + * events using same counter cannot be programmed in a group. 101 + * Since PERF_COUNT_HW_INSTRUCTIONS is a generic hardware 102 + * event and present in all platforms, lets use that. 103 + */ 104 + if (!i && !j && !k) 105 + sibling_fd2 = event_open(types[k], configs_hw[k], group_fd); 106 + else 107 + sibling_fd2 = event_open(types[k], configs[k], group_fd); 98 108 if (sibling_fd2 == -1) { 99 109 close(sibling_fd1); 100 110 close(group_fd); ··· 136 124 if (r) 137 125 ret = TEST_FAIL; 138 126 139 - pr_debug("0x%x 0x%lx, 0x%x 0x%lx, 0x%x 0x%lx: %s\n", 140 - types[i], configs[i], types[j], configs[j], 141 - types[k], configs[k], r ? "Fail" : "Pass"); 127 + /* 128 + * For all three events as HW events, second sibling 129 + * event is picked from configs_hw. So print accordingly 130 + */ 131 + if (!i && !j && !k) 132 + pr_debug("0x%x 0x%lx, 0x%x 0x%lx, 0x%x 0x%lx: %s\n", 133 + types[i], configs[i], types[j], configs[j], 134 + types[k], configs_hw[k], r ? "Fail" : "Pass"); 135 + else 136 + pr_debug("0x%x 0x%lx, 0x%x 0x%lx, 0x%x 0x%lx: %s\n", 137 + types[i], configs[i], types[j], configs[j], 138 + types[k], configs[k], r ? "Fail" : "Pass"); 142 139 } 143 140 } 144 141 }