Skip to content

perf: Fix the ctx->pmu for a hybrid system

[email protected] lkml 1 version Applied

Status from this message: The following commit has been merged into the perf/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 5 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/4perf: Update the ctx->pmu for a hybrid systeminclude/linux/perf_event.h kernel/events/core.c+35 -10 replies
2/4perf/x86: Fix the x86_pmu_start WARNING on a hybrid systemarch/x86/events/core.c arch/x86/events/intel/core.c arch/x86/events/perf_event.h+9 -170 replies
3/4perf: Check the supported CPU of an eventkernel/events/core.c+11 -10 replies
4/4perf/x86: Remove filter_match callbackarch/x86/events/core.c arch/x86/events/intel/core.c arch/x86/events/perf_event.h+0 -190 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by.

PatchKan Liang
SeriesT-b
1/4
2/4
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/4] perf: Fix the ctx->pmu for a hybrid system

From: Kan Liang <[email protected]>

The patchset is to fix the below WARNING triggered on an ADL machine when a user enables per-task monitoring with all available perf_hw_context PMUs.

WARNING: CPU: 8 PID: 37107 at arch/x86/events/core.c:1505
x86_pmu_start+0x77/0x90
Call Trace:
x86_pmu_enable+0x111/0x2f0
event_sched_in+0x167/0x230
merge_sched_in+0x1a7/0x3d0
visit_groups_merge.constprop.0.isra.0+0x16f/0x450
? x86_pmu_del+0x42/0x190
ctx_sched_in+0xb8/0x170
perf_event_sched_in+0x61/0x90
__perf_event_task_sched_in+0x20b/0x2a0
finish_task_switch.isra.0+0x16a/0x290
__schedule+0x2fd/0x970
? free_inode_nonrcu+0x18/0x20
schedule+0x4f/0xc0
do_wait+0x176/0x2f0
kernel_wait4+0xaf/0x150

Here is the line of the WARNING.

        if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)))

To fix the issue, the generic perf codes have to understand the supported CPU mask of a specific hybrid PMU. So it can update the ctx->pmu accordingly, when a task is scheduled on a CPU which has a different type of PMU from the previous CPU. The supported_cpus has to be moved to the struct pmu.

Besides, the moving can bring another improvement. All hybrid architectures including x86 and arm check whether an event is schedulable on the current CPU via the filter_match callback. Since the supported_cpus is moved to struct pmu, the check can be done in the generic code. The filter_match callback may be avoided. The patchset only implements the improvement for x86. Arm may implement a similar improvement later separately.

Kan Liang (4):
perf: Update the ctx->pmu for a hybrid system perf/x86: Fix the x86_pmu_start WARNING on a hybrid system
perf: Check the supported CPU of an event perf/x86: Remove filter_match callback

 arch/x86/events/core.c       | 22 ++++------------------
 arch/x86/events/intel/core.c | 19 ++++---------------
 arch/x86/events/perf_event.h |  2 --
 include/linux/perf_event.h   |  7 +++++++
 kernel/events/core.c         | 39 ++++++++++++++++++++++++++++++++++++++-
 5 files changed, 53 insertions(+), 36 deletions(-)
Signature · 1 line
2.7.4