]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf/core: Remove pmu linear searching code
authorRavi Bangoria <ravi.bangoria@amd.com>
Thu, 4 May 2023 11:00:02 +0000 (16:30 +0530)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 8 May 2023 08:58:31 +0000 (10:58 +0200)
Searching for the right pmu by iterating over all pmus is no longer
required since all pmus now *must* be present in the 'pmu_idr' list.
So, remove linear searching code.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20230504110003.2548-4-ravi.bangoria@amd.com
kernel/events/core.c

index c01bbe93e291af31fd6a0b675a86b83ec9f30663..231b187c1a3fc03a24af63c8a3bff93083482b1e 100644 (file)
@@ -11630,38 +11630,27 @@ static struct pmu *perf_init_event(struct perf_event *event)
        }
 
 again:
+       ret = -ENOENT;
        rcu_read_lock();
        pmu = idr_find(&pmu_idr, type);
        rcu_read_unlock();
-       if (pmu) {
-               if (event->attr.type != type && type != PERF_TYPE_RAW &&
-                   !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE))
-                       goto fail;
-
-               ret = perf_try_init_event(pmu, event);
-               if (ret == -ENOENT && event->attr.type != type && !extended_type) {
-                       type = event->attr.type;
-                       goto again;
-               }
+       if (!pmu)
+               goto fail;
 
-               if (ret)
-                       pmu = ERR_PTR(ret);
+       if (event->attr.type != type && type != PERF_TYPE_RAW &&
+           !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE))
+               goto fail;
 
-               goto unlock;
+       ret = perf_try_init_event(pmu, event);
+       if (ret == -ENOENT && event->attr.type != type && !extended_type) {
+               type = event->attr.type;
+               goto again;
        }
 
-       list_for_each_entry_rcu(pmu, &pmus, entry, lockdep_is_held(&pmus_srcu)) {
-               ret = perf_try_init_event(pmu, event);
-               if (!ret)
-                       goto unlock;
-
-               if (ret != -ENOENT) {
-                       pmu = ERR_PTR(ret);
-                       goto unlock;
-               }
-       }
 fail:
-       pmu = ERR_PTR(-ENOENT);
+       if (ret)
+               pmu = ERR_PTR(ret);
+
 unlock:
        srcu_read_unlock(&pmus_srcu, idx);