perf_events: improve x86 event scheduling (v4)
Subsystems (2)
PATCH 1/1 perf_events: improve x86 event scheduling (v4)
This patch improves event scheduling by maximizing the use of PMU registers regardless of the order in which events are created in a group.
The algorithm takes into account the list of counter constraints for each event. It assigns events to counters from the most constrained, i.e., works on only one counter, to the least constrained, i.e., works on any counter.
Intel Fixed counter events and the BTS special event are also handled via this algorithm which is designed to be fairly generic.
The patch also updates the validation of an event to use the scheduling algorithm. This will cause early failure in perf_event_open().
The 2nd version of this patch follows the model used by PPC, by running the scheduling algorithm and the actual assignment separately. Actual assignment takes place in hw_perf_enable() whereas scheduling is implemented in hw_perf_group_sched_in() and x86_pmu_enable().
The 3rd version does:
- correct handling of pmu->enable() error in hw_perf_group_sched_in()
- simplified event scheduling
- constraint storage in x86_schedule_events() (dynamic constraints)
- new put_event_constraints() callback to release a dynamic constraint
This 4th version does:
- remove leftover debug code in x86_perf_event_set_period()
--
include/asm/perf_event.h | 17 - kernel/cpu/perf_event.c | 758 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 558 insertions(+), 217 deletions(-)
arch/x86/include/asm/perf_event.h +15 -2
@@ -19,6 +19,7 @@#define MSR_ARCH_PERFMON_EVENTSEL1 0x187#define ARCH_PERFMON_EVENTSEL0_ENABLE (1 << 22) +#define ARCH_PERFMON_EVENTSEL_ANY (1 << 21)#define ARCH_PERFMON_EVENTSEL_INT (1 << 20)#define ARCH_PERFMON_EVENTSEL_OS (1 << 17)#define ARCH_PERFMON_EVENTSEL_USR (1 << 16)
@@ -26,7 +27,14 @@/* * Includes eventsel and unit mask as well: */ -#define ARCH_PERFMON_EVENT_MASK 0xffff + + +#define INTEL_ARCH_EVTSEL_MASK 0x000000FFULL +#define INTEL_ARCH_UNIT_MASK 0x0000FF00ULL +#define INTEL_ARCH_EDGE_MASK 0x00040000ULL +#define INTEL_ARCH_INV_MASK 0x00800000ULL +#define INTEL_ARCH_CNT_MASK 0xFF000000ULL +#define INTEL_ARCH_EVENT_MASK (INTEL_ARCH_UNIT_MASK|INTEL_ARCH_EVTSEL_MASK)/* * filter mask to validate fixed counter events.
@@ -37,7 +45,12 @@* The other filters are supported by fixed counters. * The any-thread option is supported starting with v3. */ -#define ARCH_PERFMON_EVENT_FILTER_MASK 0xff840000 +#define INTEL_ARCH_FIXED_MASK \ + (INTEL_ARCH_CNT_MASK| \ + INTEL_ARCH_INV_MASK| \ + INTEL_ARCH_EDGE_MASK|\ + INTEL_ARCH_UNIT_MASK|\ + INTEL_ARCH_EVENT_MASK)#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8)
arch/x86/kernel/cpu/perf_event.c +543 -215
943 lines not on this page · raw message