Skip to content

Commit 0c2822b

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 regression fix from Will Deacon: "Apologies for the _extremely_ late pull request here, but we had a 'perf' (i.e. CPU PMU) regression on the Apple M1 reported on Wednesday [1] which was introduced by bd27568 ("perf: Rewrite core context handling") during the merge window. Mark and I looked into this and noticed an additional problem caused by the same patch, where the 'CHAIN' event (used to combine two adjacent 32-bit counters into a single 64-bit counter) was not being filtered correctly. Mark posted a series on Thursday [2] which addresses both of these regressions and I queued it the same day. The changes are small, self-contained and have been confirmed to fix the original regression. Summary: - Fix 'perf' regression for non-standard CPU PMU hardware (i.e. Apple M1)" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: perf: reject CHAIN events at creation time arm_pmu: fix event CPU filtering
2 parents 0e9fd58 + 853e2da commit 0c2822b

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

arch/arm64/kernel/perf_event.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,12 +1023,6 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event,
10231023
return 0;
10241024
}
10251025

1026-
static bool armv8pmu_filter(struct pmu *pmu, int cpu)
1027-
{
1028-
struct arm_pmu *armpmu = to_arm_pmu(pmu);
1029-
return !cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus);
1030-
}
1031-
10321026
static void armv8pmu_reset(void *info)
10331027
{
10341028
struct arm_pmu *cpu_pmu = (struct arm_pmu *)info;
@@ -1069,6 +1063,14 @@ static int __armv8_pmuv3_map_event(struct perf_event *event,
10691063
&armv8_pmuv3_perf_cache_map,
10701064
ARMV8_PMU_EVTYPE_EVENT);
10711065

1066+
/*
1067+
* CHAIN events only work when paired with an adjacent counter, and it
1068+
* never makes sense for a user to open one in isolation, as they'll be
1069+
* rotated arbitrarily.
1070+
*/
1071+
if (hw_event_id == ARMV8_PMUV3_PERFCTR_CHAIN)
1072+
return -EINVAL;
1073+
10721074
if (armv8pmu_event_is_64bit(event))
10731075
event->hw.flags |= ARMPMU_EVT_64BIT;
10741076

@@ -1258,7 +1260,6 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name,
12581260
cpu_pmu->stop = armv8pmu_stop;
12591261
cpu_pmu->reset = armv8pmu_reset;
12601262
cpu_pmu->set_event_filter = armv8pmu_set_event_filter;
1261-
cpu_pmu->filter = armv8pmu_filter;
12621263

12631264
cpu_pmu->pmu.event_idx = armv8pmu_user_event_idx;
12641265

drivers/perf/arm_pmu.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,7 @@ static void armpmu_disable(struct pmu *pmu)
550550
static bool armpmu_filter(struct pmu *pmu, int cpu)
551551
{
552552
struct arm_pmu *armpmu = to_arm_pmu(pmu);
553-
bool ret;
554-
555-
ret = cpumask_test_cpu(cpu, &armpmu->supported_cpus);
556-
if (ret && armpmu->filter)
557-
return armpmu->filter(pmu, cpu);
558-
559-
return ret;
553+
return !cpumask_test_cpu(cpu, &armpmu->supported_cpus);
560554
}
561555

562556
static ssize_t cpus_show(struct device *dev,

include/linux/perf/arm_pmu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ struct arm_pmu {
100100
void (*stop)(struct arm_pmu *);
101101
void (*reset)(void *);
102102
int (*map_event)(struct perf_event *event);
103-
bool (*filter)(struct pmu *pmu, int cpu);
104103
int num_events;
105104
bool secure_access; /* 32-bit ARM only */
106105
#define ARMV8_PMUV3_MAX_COMMON_EVENTS 0x40

0 commit comments

Comments
 (0)