Re: [PATCH v7 0/3] perf/core: sched_task() dispatch and branch entry fixes

From: wuyifan

Date: Thu Sep 03 2026 - 22:46:19 EST


Hi Puranjay,

On 8/10/2026 9:35 PM, Puranjay Mohan wrote:
These three fixes were found while adding BRBE support for
bpf_get_branch_snapshot() on arm64 and were carried in that series until
v6 [1]. They do not depend on it, so they go on their own; the version
number continues from that series to avoid two numbering schemes for the
same patches.
perf record -C <cpu> -b [<command>] triggers a NULL pointer dereference
in armv8pmu_sched_task().

Commit fa9d27773873 ("perf: arm_pmu: Kill last use of per-CPU cpu_armpmu
pointer") changed armv8pmu_sched_task() from reading the per-CPU
cpu_armpmu variable to dereferencing pmu_ctx->pmu via
to_arm_pmu(pmu_ctx->pmu). Meanwhile, commit bd2756811766 ("perf:
Rewrite core context handling") made __perf_pmu_sched_task() pass
cpc->task_epc to pmu->sched_task(). cpc->task_epc is only non-NULL
while a task context is scheduled in; CPU-bound events do not schedule a
task context, so cpc->task_epc stays NULL. The NULL argument is dereferenced
and crashes.

With the patches applied, perf record -C <cpu> -b no longer crashes,
and system-wide perf record -b -e <event> -a alongside a task-bound event
on a different CPU runs without any WARN_ON.

Tested-by: Yifan Wu <wuyifan50@xxxxxxxxxx>