]> git.baikalelectronics.ru Git - kernel.git/commit
perf/core: Pull pmu::sched_task() into perf_event_context_sched_in()
authorKan Liang <kan.liang@linux.intel.com>
Fri, 21 Aug 2020 19:57:52 +0000 (12:57 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 10 Sep 2020 09:19:34 +0000 (11:19 +0200)
commita015287c1639d36cbf8fa277a6e3c6912194af72
treee6d7df64d411224602e0925c3bed2ecefcd58d8b
parentfcc7d7592005c9c180e123409a0450f0c4c93861
perf/core: Pull pmu::sched_task() into perf_event_context_sched_in()

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 was just iterated in perf_event_context_sched_in(),
which is invoked right before the pmu::sched_task().

Reuse the cpuctx->task_ctx from perf_event_context_sched_in() can avoid
the unnecessary iteration of the cpuctx list.

Both pmu::sched_task and perf_event_context_sched_in() have to disable
PMU. Pull the pmu::sched_task into perf_event_context_sched_in() can
also save the overhead from the PMU disable and reenable.

The new and old tasks may have equivalent contexts. The current code
optimize this case by swapping the context, which avoids the scheduling.
For this case, pmu::sched_task() is still required, e.g., restore the
LBR content.

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-1-kan.liang@linux.intel.com
kernel/events/core.c