Commit 228020b4 authored by Peter Zijlstra's avatar Peter Zijlstra

perf: Re-instate the linear PMU search

Full revert of commit 9551fbb6 ("perf/core: Remove pmu linear
searching code").

Some architectures (notably arm/arm64) still relied on the linear
search in order to find the PMU that consumes
PERF_TYPE_{HARDWARE,HW_CACHE,RAW}.

This will need a more thorought audit and cleanup.
Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
Reported-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20230605101401.GL38236@hirez.programming.kicks-ass.net
parent 10d95a31
...@@ -11630,27 +11630,38 @@ static struct pmu *perf_init_event(struct perf_event *event) ...@@ -11630,27 +11630,38 @@ static struct pmu *perf_init_event(struct perf_event *event)
} }
again: again:
ret = -ENOENT;
rcu_read_lock(); rcu_read_lock();
pmu = idr_find(&pmu_idr, type); pmu = idr_find(&pmu_idr, type);
rcu_read_unlock(); rcu_read_unlock();
if (!pmu) if (pmu) {
goto fail; if (event->attr.type != type && type != PERF_TYPE_RAW &&
!(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE))
goto fail;
if (event->attr.type != type && type != PERF_TYPE_RAW && ret = perf_try_init_event(pmu, event);
!(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)) if (ret == -ENOENT && event->attr.type != type && !extended_type) {
goto fail; type = event->attr.type;
goto again;
}
ret = perf_try_init_event(pmu, event); if (ret)
if (ret == -ENOENT && event->attr.type != type && !extended_type) { pmu = ERR_PTR(ret);
type = event->attr.type;
goto again; goto unlock;
} }
fail: list_for_each_entry_rcu(pmu, &pmus, entry, lockdep_is_held(&pmus_srcu)) {
if (ret) ret = perf_try_init_event(pmu, event);
pmu = ERR_PTR(ret); if (!ret)
goto unlock;
if (ret != -ENOENT) {
pmu = ERR_PTR(ret);
goto unlock;
}
}
fail:
pmu = ERR_PTR(-ENOENT);
unlock: unlock:
srcu_read_unlock(&pmus_srcu, idx); srcu_read_unlock(&pmus_srcu, idx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment