powerpc/perf: Optimize find_alternatives_list() using binary search
authorKuan-Wei Chiu <visitorckw@gmail.com>
Fri, 13 Oct 2023 17:57:14 +0000 (01:57 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 19 Oct 2023 12:18:59 +0000 (23:18 +1100)
commite08c43e6c3eb5d805b61d981f1e8286ee0dc6d1a
treefd1b030343cc7855fe548b1162727136b6ab4c7b
parentd45c4b48dafb5820e5cc267ff9a6d7784d13a43c
powerpc/perf: Optimize find_alternatives_list() using binary search

This patch improves the performance of event alternative lookup by
replacing the previous linear search with a more efficient binary
search. This change reduces the time complexity for the search process
from O(n) to O(log(n)). A pre-sorted table of event values and their
corresponding indices has been introduced to expedite the search
process.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
[mpe: Call the array "presort*ed*_event_table", minor formatting]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231013175714.2142775-1-visitorckw@gmail.com
arch/powerpc/perf/power6-pmu.c