8000 perf: allow for PMU-specific event filtering · bsd-unix/linux@66eb579 · GitHub
[go: up one dir, main page]

Skip to content

Commit 66eb579

Browse files
mrutland-armwildea01
authored andcommitted
perf: allow for PMU-specific event filtering
In certain circumstances it may not be possible to schedule particular events due to constraints other than a lack of hardware counters (e.g. on big.LITTLE systems where CPUs support different events). The core perf event code does not distinguish these cases and pessimistically assumes that any failure to schedule an event means that it is not worth attempting to schedule later events, even if some hardware counters are still unused. When an event a pmu cannot schedule exists in a flexible group list it can unnecessarily prevent event groups following it in the list from being scheduled (until it is rotated to the end of the list). This means some events are scheduled for only a portion of the time they could be, and for short running programs no events may be scheduled if the list is initially sorted in an unfortunate order. This patch adds a new (optional) filter_match function pointer to struct pmu which a pmu driver can use to tell perf core when an event matches pmu-specific scheduling requirements. This plugs into the existing event_filter_match logic, and makes it possible to avoid the scheduling problem described above. When no filter is provided by the PMU, the existing behaviour is retained. Cc: Paul Mackerras <paulus@samba.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Acked-by: Will Deacon <will.deacon@arm.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent b787f68 commit 66eb579

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

include/linux/perf_event.h

+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ struct pmu {
304304
* Free pmu-private AUX data structures
305305
*/
306306
void (*free_aux) (void *aux); /* optional */
307+
308+
/*
309+
* Filter events for PMU-specific reasons.
310+
*/
311+
int (*filter_match) (struct perf_event *event); /* optional */
307312
};
308313

309314
/**

kernel/events/core.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,11 +1506,17 @@ static int __init perf_workqueue_init(void)
15061506

15071507
core_initcall(perf_workqueue_init);
15081508

1509+
static inline int pmu_filter_match(struct perf_event *event)
1510+
{
1511+
struct pmu *pmu = event->pmu;
1512+
return pmu->filter_match ? pmu->filter_match(event) : 1;
1513+
}
1514+
15091515
static inline int
15101516
event_filter_match(struct perf_event *event)
15111517
{
15121518
return (event->cpu == -1 || event->cpu == smp_processor_id())
1513-
&& perf_cgroup_match(event);
1519+
&& perf_cgroup_match(event) && pmu_filter_match(event);
15141520
}
15151521

15161522
static void

0 commit comments

Comments
 (0)
0