Skip to content

Commit

Permalink
perf: Fix task context PMU for Hetero
Browse files Browse the repository at this point in the history
On HETEROGENEOUS hardware (ARM big.Little, Intel Alderlake etc.) each
CPU might have a different hardware PMU. Since each such PMU is
represented by a different struct pmu, but we only have a single HW
task context.

That means that the task context needs to switch PMU type when it
switches CPUs.

Not doing this means that ctx->pmu calls (pmu_{dis,en}able(),
{start,commit,cancel}_txn() etc.) are called against the wrong PMU and
things will go wobbly.

Fixes: f83d2f9 ("perf/x86/intel: Add Alder Lake Hybrid support")
Reported-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lkml.kernel.org/r/YMsy7BuGT8nBTspT@hirez.programming.kicks-ass.net
  • Loading branch information
Peter Zijlstra committed Jun 23, 2021
1 parent 1d5c788 commit 012669c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3822,9 +3822,16 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
struct task_struct *task)
{
struct perf_cpu_context *cpuctx;
struct pmu *pmu = ctx->pmu;
struct pmu *pmu;

cpuctx = __get_cpu_context(ctx);

/*
* HACK: for HETEROGENEOUS the task context might have switched to a
* different PMU, force (re)set the context,
*/
pmu = ctx->pmu = cpuctx->ctx.pmu;

if (cpuctx->task_ctx == ctx) {
if (cpuctx->sched_cb_usage)
__perf_pmu_sched_task(cpuctx, true);
Expand Down

0 comments on commit 012669c

Please sign in to comment.