From: "Yan, Zheng" <[email protected]>

So far only CPU pmu uses context switch callback and it is the
first registered pmu. So we can avoid iterating the whole pmu list.

Signed-off-by: Yan, Zheng <[email protected]>
---
 kernel/events/core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index fc97ed6..c281265 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2373,6 +2373,10 @@ static void perf_pmu_sched_task(struct task_struct *prev,
                perf_pmu_enable(pmu);
 
                perf_ctx_unlock(cpuctx, cpuctx->task_ctx);
+
+               /* so far only CPU pmu uses context switch callback */
+               if (++count >= __get_cpu_var(perf_sched_cb_usages))
+                       break;
        }
 
        rcu_read_unlock();
@@ -6492,7 +6496,7 @@ got_cpu_context:
        if (!pmu->event_idx)
                pmu->event_idx = perf_event_idx_default;
 
-       list_add_rcu(&pmu->entry, &pmus);
+       list_add_tail_rcu(&pmu->entry, &pmus);
        ret = 0;
 unlock:
        mutex_unlock(&pmus_lock);
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to