perf/core: Pull pmu::sched_task() into perf_event_context_sched_out()
authorKan Liang <kan.liang@linux.intel.com>
Fri, 21 Aug 2020 19:57:53 +0000 (12:57 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 10 Sep 2020 09:19:34 +0000 (11:19 +0200)
commit44fae179ce73a26733d9e2d346da4e1a1cb94647
tree58ae1e7e339127053c3ac96b445c75cff1b470b0
parent556cccad389717d6eb4f5a24b45ff41cad3aaabf
perf/core: Pull pmu::sched_task() into perf_event_context_sched_out()

The pmu::sched_task() is a context switch callback. It passes the
cpuctx->task_ctx as a parameter to the lower code. To find the
cpuctx->task_ctx, the current code iterates a cpuctx list.
The same context will iterated in perf_event_context_sched_out() soon.
Share the cpuctx->task_ctx can avoid the unnecessary iteration of the
cpuctx list.

The pmu::sched_task() is also required for the optimization case for
equivalent contexts.

The task_ctx_sched_out() will eventually disable and reenable the PMU
when schedule out events. Add perf_pmu_disable() and perf_pmu_enable()
around task_ctx_sched_out() don't break anything.

Drop the cpuctx->ctx.lock for the pmu::sched_task(). The lock is for
per-CPU context, which is not necessary for the per-task context
schedule.

No one uses sched_cb_entry, perf_sched_cb_usages, sched_cb_list, and
perf_pmu_sched_task() any more.

Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200821195754.20159-2-kan.liang@linux.intel.com
include/linux/perf_event.h
kernel/events/core.c