perf: implement AMD IBS (v2)
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest7 patches 19 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | perf: introduce raw_type attribute to specify the type of a raw samplearch/ arch/ arch/ +6 more | +30 | 19 replies | |
| 2/7 | perf, x86: introduce bit range for special pmu eventsarch/ arch/ arch/ +1 more | +12 | 0 replies | |
| 3/7 | perf, x86: modify some code to allow the introduction of ibs eventsarch/ | +9 | 0 replies | |
| 4/7 | perf, x86: implement IBS feature detectionarch/ arch/ | +7 | 0 replies | |
| 5/7 | perf, x86: setup NMI handler for IBSarch/ arch/ | +90 | 0 replies | |
| 6/7 | perf, x86: implement AMD IBS event configurationarch/ arch/ arch/ | +207 | 0 replies | |
| 7/7 | perf, x86: implement the ibs interrupt handlerarch/ arch/ | +72 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/7] perf: implement AMD IBS (v2)
This is an updated version of my patch set that introduces AMD IBS for perf.
Changes made:
* rebased to latest tip/perf/core
* dropped the approach using a model_spec flag
* introduced an attribute to specify a raw hardware event type
* renamed *_SIZE macros to *_REG_COUNT
* introduced AMD_IBS_EVENT_CONSTRAINT() macro
* ease ibs initialization code
* made code cpu hotplug capable (using hotplug hooks)
* introduced ibs_map[] to better describe an ibs event which eases interfaces of ibs functions
* implemented support for setup using sample_period parameter
* fixed irq statistic counter
* adjust raw sample size to end the buffer at a 64 bit boundary
See also the diff below.
-Robert
arch/arm/kernel/perf_event.c +5 -0
@@ -388,6 +388,11 @@ __hw_perf_event_init(struct perf_event *event) }else if (PERF_TYPE_HW_CACHE == event->attr.type) { mapping =armpmu_map_cache_event (event->attr.config); }else if (PERF_TYPE_RAW == event->attr.type) { +if (event->attr.raw_type) { +pr_debug ("invalid raw type %x\n" , + event->attr.raw_type); +return -EINVAL ; + } mapping = armpmu->raw_event (event->attr.config); }else {pr_debug ("event type %x not supported\n" , event->attr.type);
arch/powerpc/kernel/perf_event.c +2 -3
@@ -1036,6 +1036,8 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)return ERR_PTR (err);break ;case PERF_TYPE_RAW : +if (event->attr.raw_type) +return ERR_PTR (-EINVAL ); ev = event->attr.config;break ;default :
@@ -1044,9 +1046,6 @@ const struct pmu *hw_perf_event_init(struct perf_event *event) event->hw.config_base = ev; event->hw.idx =0 ; -if (attr->model_spec) -return ERR_PTR (-EOPNOTSUPP ); -/* * If we are not running on a hypervisor, force the * exclude_hv bit to 0 so that we don't care what
arch/powerpc/kernel/perf_event_fsl_emb.c +2 -0
@@ -452,6 +452,8 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)break ;case PERF_TYPE_RAW : +if (event->attr.raw_type) +return ERR_PTR (-EINVAL ); ev = event->attr.config;break ;
arch/sh/kernel/perf_event.c +2 -3
@@ -109,9 +109,6 @@ static int __hw_perf_event_init(struct perf_event *event)if (!sh_pmu_initialized ())return -ENODEV ; -if (attr->model_spec) -return -EOPNOTSUPP ; -/* * All of the on-chip counters are "limited", in that they have * no interrupts, and are therefore unable to do sampling without
@@ -145,6 +142,8 @@ static int __hw_perf_event_init(struct perf_event *event)switch (attr->type) {case PERF_TYPE_RAW : +if (attr->raw_type) +return -EINVAL ; config = attr->config & sh_pmu->raw_event_mask;break ;case PERF_TYPE_HW_CACHE :
arch/sparc/kernel/perf_event.c +0 -3
@@ -1047,9 +1047,6 @@ static int __hw_perf_event_init(struct perf_event *event) }else return -EOPNOTSUPP ; -if (attr->model_spec) -return -EOPNOTSUPP ; -/* We save the enable bits in the config_base. */ hwc->config_base = sparc_pmu->irq_bit;if (!attr->exclude_user)
arch/x86/include/asm/msr-index.h +3 -3
@@ -113,7 +113,7 @@#define MSR_AMD64_IBSFETCHCTL 0xc0011030#define MSR_AMD64_IBSFETCHLINAD 0xc0011031#define MSR_AMD64_IBSFETCHPHYSAD 0xc0011032 -#define MSR_AMD64_IBSFETCH_SIZE 3 +#define MSR_AMD64_IBSFETCH_REG_COUNT 3#define MSR_AMD64_IBSOPCTL 0xc0011033#define MSR_AMD64_IBSOPRIP 0xc0011034#define MSR_AMD64_IBSOPDATA 0xc0011035
@@ -121,9 +121,9 @@#define MSR_AMD64_IBSOPDATA3 0xc0011037#define MSR_AMD64_IBSDCLINAD 0xc0011038#define MSR_AMD64_IBSDCPHYSAD 0xc0011039 -#define MSR_AMD64_IBSOP_SIZE 7 +#define MSR_AMD64_IBSOP_REG_COUNT 7#define MSR_AMD64_IBSCTL 0xc001103a -#define MSR_AMD64_IBS_SIZE_MAX MSR_AMD64_IBSOP_SIZE +#define MSR_AMD64_IBS_REG_COUNT_MAX MSR_AMD64_IBSOP_REG_COUNT/* Fam 10h MSRs */ #define MSR_FAM10H_MMIO_CONF_BASE 0xc0010058
arch/x86/include/asm/perf_event.h +4 -3
@@ -44,14 +44,15 @@#define AMD64_RAW_EVENT_MASK \ (X86_RAW_EVENT_MASK | \ AMD64_EVENTSEL_EVENT) +#define AMD64_NUM_COUNTERS 4 -#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c +#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8) -#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX 0 +#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX 0#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT \ (1 << (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX)) -#define ARCH_PERFMON_BRANCH_MISSES_RETIRED 6 +#define ARCH_PERFMON_BRANCH_MISSES_RETIRED 6/* * Intel "Architectural Performance Monitoring" CPUID
arch/x86/kernel/cpu/perf_event.c +16 -30
103 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_amd.c +129 -90
335 lines not on this page · raw message
arch/x86/kernel/cpu/perf_event_intel.c +3 -0
@@ -770,6 +770,9 @@ static int intel_pmu_hw_config(struct perf_event *event)if (event->attr.type !=PERF_TYPE_RAW )return 0 ; +if (event->attr.raw_type) +return -EINVAL ; +if (!(event->attr.config &ARCH_PERFMON_EVENTSEL_ANY ))return 0 ;
arch/x86/kernel/cpu/perf_event_p4.c +5 -0
@@ -437,6 +437,11 @@ static int p4_hw_config(struct perf_event *event) event->hw.config =p4_set_ht_bit (event->hw.config);if (event->attr.type ==PERF_TYPE_RAW ) { +/* only raw perfctr config supported */ +if (event->attr.raw_type) { + rc = -EINVAL ; + goto out; + }/* user data may have out-of-bound event index */ evnt =p4_config_unpack_event (event->attr.config);
include/linux/perf_event.h +5 -3
@@ -214,16 +214,18 @@ struct perf_event_attr {* See also PERF_RECORD_MISC_EXACT_IP */ precise_ip :2 ,/* skid constraint */ - model_spec : 1, /* model specific hw event */ - __reserved_1 : 46; + __reserved_1 : 47;union {__u32 wakeup_events;/* wakeup every n events */ __u32 wakeup_watermark;/* bytes before wakeup */ }; -__u32 bp_type; +union { +__u32 bp_type; +__u32 raw_type; + };__u64 bp_addr;__u64 bp_len; };