powerpc/perf: Fix the power9 event alternatives array to have correct sort order
PATCH v2 1/2 powerpc/perf: Fix the power9 event alternatives array to have correct sort order
When scheduling a group of events, there are constraint checks done to make sure all events can go in a group. Example, one of the criteria is that events in a group cannot use same PMC. But platform specific PMU supports alternative event for some of the event codes. During perf_event_open, if any event group doesn't match constraint check criteria, further lookup is done to find alternative event.
By current design, the array of alternatives events in PMU code is expected to be sorted by column 0. This is because in find_alternative() function, the return criteria is based on event code comparison. ie "event < ev_alt[i][0])". This optimisation is there since find_alternative() can get called multiple times. In power9 PMU code, the alternative event array is not sorted list and hence there is breakage in finding alternative event.
To work with existing logic, fix the alternative event array to be sorted by column 0 for power9-pmu.c
---
Changelog:
Added Fixes tag and reworded commit message.
Added Reviewed-by from Maddy.
arch/powerpc/perf/power9-pmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/perf/power9-pmu.c +4 -4
@@ -133,11 +133,11 @@ int p9_dd22_bl_ev[] = {/* Table of alternatives, sorted by column 0 */ static const unsigned int power9_event_alternatives[][MAX_ALT ] = { - {PM_INST_DISP ,PM_INST_DISP_ALT }, - {PM_RUN_CYC_ALT ,PM_RUN_CYC }, - {PM_RUN_INST_CMPL_ALT ,PM_RUN_INST_CMPL }, - {PM_LD_MISS_L1 ,PM_LD_MISS_L1_ALT }, {PM_BR_2PATH ,PM_BR_2PATH_ALT }, + {PM_INST_DISP ,PM_INST_DISP_ALT }, + {PM_RUN_CYC_ALT ,PM_RUN_CYC }, + {PM_LD_MISS_L1 ,PM_LD_MISS_L1_ALT }, + {PM_RUN_INST_CMPL_ALT ,PM_RUN_INST_CMPL }, };static int power9_get_alternatives (u64 event,unsigned int flags,u64 alt[])
Signature · 1 line
2.35.1
PATCH v2 2/2 powerpc/perf: Fix the power10 event alternatives array to have correct sort order
When scheduling a group of events, there are constraint checks done to make sure all events can go in a group. Example, one of the criteria is that events in a group cannot use same PMC. But platform specific PMU supports alternative event for some of the event codes. During perf_event_open, if any event group doesn't match constraint check criteria, further lookup is done to find alternative event.
By current design, the array of alternatives events in PMU code is expected to be sorted by column 0. This is because in find_alternative() function, the return criteria is based on event code comparison. ie "event < ev_alt[i][0])". This optimisation is there since find_alternative() can get called multiple times. In power10 PMU code, the alternative event array is not sorted list and hence there is breakage in finding alternative event.
To work with existing logic, fix the alternative event array to be sorted by column 0 for power10-pmu.c
---
Changelog:
Added Fixes tag and reworded commit message
Added Reviewed-by from Maddy
arch/powerpc/perf/power10-pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/perf/power10-pmu.c +1 -1
@@ -91,8 +91,8 @@ extern u64 PERF_REG_EXTENDED_MASK;/* Table of alternatives, sorted by column 0 */ static const unsigned int power10_event_alternatives[][MAX_ALT ] = { - {PM_CYC_ALT ,PM_CYC }, {PM_INST_CMPL_ALT ,PM_INST_CMPL }, + {PM_CYC_ALT ,PM_CYC }, };static int power10_get_alternatives (u64 event,unsigned int flags,u64 alt[])
Signature · 1 line
2.35.1