perf, x86: Add new cache events table for Haswell
Subsystems (2)
PATCH 1/3 perf, x86: Add new cache events table for Haswell
From: Andi Kleen <[email protected]>
Haswell offcore events are quite different from Sandy Bridge. Add a new table to handle Haswell properly.
Note that the offcore bits listed in the SDM are not quite correct (this is currently being fixed). An uptodate list of bits is in the patch.
The basic setup is similar to Sandy Bridge. The prefetch columns have been removed, as prefetch counting is not very reliable on Haswell. One L1 event that is not in the event list anymore has been also removed.
- data reads do not include code reads (comparable to earlier Sandy Bridge tables)
- data counts include speculative execution (except L1 write, dtlb, bpu)
- remote node access includes both remote memory, remote cache, remote mmio.
- prefetches are not included in the counts for consistency (different from Sandy Bridge, which includes prefetches in the remote node)
The events with additional caveats have references to the specification update.
v2: Change name of variable.
v3: Based on older Broadwell patch, but now just for Haswell.
Various fixes with events being more similar to the older Sandy Bridge tables.
--- arch/x86/kernel/cpu/perf_event_intel.c | 197 ++++++++++++++++++++++++++++++++- 1 file changed, 195 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/perf_event_intel.c +195 -2
@@ -415,6 +415,199 @@ static __initconst const u64 snb_hw_cache_event_ids }; +/* +* Notes on the events: +* - data reads do not include code reads (comparable to earlier tables) +* - data counts include speculative execution (except L1 write, dtlb, bpu) +* - remote node access includes both remote memory, remote cache, remote mmio. +* - prefetches are not included in the counts. +* The events with additional caveats have references to the specification update. +*/ + +#define HSW_DEMAND_DATA_RD BIT(0) +#define HSW_DEMAND_RFO BIT(1) +#define HSW_PF_L2_RFO BIT(5) +#define HSW_PF_L3_RFO BIT(8) +#define HSW_ALL_RFO (HSW_DEMAND_RFO| \ + HSW_PF_L2_RFO|HSW_PF_L3_RFO) +#define HSW_ANY_RESPONSE BIT(16) +#define HSW_SUPPLIER_NONE BIT(17) +#define HSW_L3_MISS_LOCAL BIT(22) +#define HSW_L3_MISS_REMOTE_HOP0 BIT(27) +#define HSW_L3_MISS_REMOTE_HOP1 BIT(28) +#define HSW_L3_MISS_REMOTE_HOP2P BIT(29) +#define HSW_L3_MISS (HSW_L3_MISS_LOCAL| \ + HSW_L3_MISS_REMOTE_HOP0|HSW_L3_MISS_REMOTE_HOP1| \ + HSW_L3_MISS_REMOTE_HOP2P) +#define HSW_SNOOP_NONE BIT(31) +#define HSW_SNOOP_NOT_NEEDED BIT(32) +#define HSW_SNOOP_MISS BIT(33) +#define HSW_SNOOP_HIT_NO_FWD BIT(34) +#define HSW_SNOOP_HIT_WITH_FWD BIT(35) +#define HSW_SNOOP_HITM BIT(36) +#define HSW_SNOOP_NON_DRAM BIT(37) +#define HSW_ANY_SNOOP (HSW_SNOOP_NONE| \ + HSW_SNOOP_NOT_NEEDED|HSW_SNOOP_MISS| \ + HSW_SNOOP_HIT_NO_FWD|HSW_SNOOP_HIT_WITH_FWD| \ + HSW_SNOOP_HITM|HSW_SNOOP_NON_DRAM) + +static __initconst const u64 hsw_hw_cache_event_ids + [PERF_COUNT_HW_CACHE_MAX ] + [PERF_COUNT_HW_CACHE_OP_MAX ] + [PERF_COUNT_HW_CACHE_RESULT_MAX ] = +{ + [C (L1D ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x81d0 ,/* MEM_UOPS_RETIRED.ALL_LOADS, HSM30 */ + [C (RESULT_MISS ) ] =0x151 ,/* L1D.REPLACEMENT */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0x82d0 ,/* MEM_UOPS_RETIRED.ALL_STORES, HSM30 */ + [C (RESULT_MISS ) ] =0x0 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x0 , + }, + }, + [C (L1I ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x280 ,/* ICACHE.MISSES */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x0 , + }, + }, + [C (LL ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x1b7 ,/* OFFCORE_RESPONSE */ + [C (RESULT_MISS ) ] =0x1b7 ,/* OFFCORE_RESPONSE */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0x1b7 ,/* OFFCORE_RESPONSE */ + [C (RESULT_MISS ) ] =0x1b7 ,/* OFFCORE_RESPONSE */ + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x0 , + }, + }, + [C (DTLB ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x81d0 ,/* MEM_UOPS_RETIRED.ALL_LOADS, HSM30 */ + [C (RESULT_MISS ) ] =0x108 ,/* DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0x82d0 ,/* MEM_UOPS_RETIRED.ALL_STORES, HSM30 */ + [C (RESULT_MISS ) ] =0x149 ,/* DTLB_STORE_MISSES.MISS_CAUSES_A_WALK */ + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x0 , + }, + }, + [C (ITLB ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x6085 ,/* ITLB_MISSES.STLB_HIT */ + [C (RESULT_MISS ) ] =0x185 ,/* ITLB_MISSES.MISS_CAUSES_A_WALK */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + }, + [C (BPU ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0xc4 ,/* BR_INST_RETIRED.ALL_BRANCHES */ + [C (RESULT_MISS ) ] =0xc5 ,/* BR_MISP_RETIRED.ALL_BRANCHES */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + }, + [C (NODE ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x1b7 ,/* OFFCORE_RESPONSE */ + [C (RESULT_MISS ) ] =0x1b7 ,/* OFFCORE_RESPONSE */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0x1b7 ,/* OFFCORE_RESPONSE */ + [C (RESULT_MISS ) ] =0x1b7 ,/* OFFCORE_RESPONSE */ + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x0 , + }, + }, +}; + +static __initconst const u64 hsw_hw_cache_extra_regs + [PERF_COUNT_HW_CACHE_MAX ] + [PERF_COUNT_HW_CACHE_OP_MAX ] + [PERF_COUNT_HW_CACHE_RESULT_MAX ] = +{ + [C (LL ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =HSW_DEMAND_DATA_RD | +HSW_ANY_RESPONSE |HSW_ANY_SNOOP | +HSW_SUPPLIER_NONE , + [C (RESULT_MISS ) ] =HSW_DEMAND_DATA_RD | +HSW_L3_MISS |HSW_ANY_SNOOP | +HSW_SUPPLIER_NONE , + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =HSW_DEMAND_RFO | +HSW_ANY_RESPONSE |HSW_ANY_SNOOP | +HSW_SUPPLIER_NONE , + [C (RESULT_MISS ) ] =HSW_DEMAND_RFO |HSW_L3_MISS | +HSW_ANY_SNOOP |HSW_SUPPLIER_NONE , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x0 , + }, + }, + [C (NODE ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =HSW_DEMAND_DATA_RD | +HSW_L3_MISS_LOCAL |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP , + [C (RESULT_MISS ) ] =HSW_DEMAND_DATA_RD | +HSW_L3_MISS_REMOTE_HOP0 |HSW_L3_MISS_REMOTE_HOP1 | +HSW_L3_MISS_REMOTE_HOP2P |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP , + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =HSW_DEMAND_RFO | +HSW_L3_MISS_LOCAL |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP , + [C (RESULT_MISS ) ] =HSW_DEMAND_RFO | +HSW_L3_MISS_REMOTE_HOP0 |HSW_L3_MISS_REMOTE_HOP1 | +HSW_L3_MISS_REMOTE_HOP2P |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x0 , + }, + }, +}; +static __initconst const u64 westmere_hw_cache_event_ids [PERF_COUNT_HW_CACHE_MAX ] [PERF_COUNT_HW_CACHE_OP_MAX ]
@@ -2546,8 +2739,8 @@ __init int intel_pmu_init(void)case 69 :/* 22nm Haswell ULT */ case 70 :/* 22nm Haswell + GT3e (Intel Iris Pro graphics) */ x86_pmu.late_ack = true; -memcpy (hw_cache_event_ids, snb_hw_cache_event_ids,sizeof (hw_cache_event_ids)); -memcpy (hw_cache_extra_regs, snb_hw_cache_extra_regs,sizeof (hw_cache_extra_regs)); +memcpy (hw_cache_event_ids, hsw_hw_cache_event_ids,sizeof (hw_cache_event_ids)); +memcpy (hw_cache_extra_regs, hsw_hw_cache_extra_regs,sizeof (hw_cache_extra_regs));intel_pmu_lbr_init_snb ();
Signature · 1 line
1.9.3
PATCH 2/3 perf, x86: Add Broadwell core support
From: Andi Kleen <[email protected]>
Add Broadwell support for Broadwell to perf.
The basic support is very similar to Haswell. We use the new cache event list added for Haswell earlier. The only differences are a few bits related to remote nodes. To avoid an extra, mostly identical, table these are patched up in the initialization code.
The constraint list has one new event that needs to be handled over Haswell.
Includes code and testing from Kan Liang.
v2: Remove unnamed model numbers.
v3: Rename cache event list to hsw_*. Change names.
v4: Use symbolic names for cache events. Improve comments and description.
Fix sparse warnings (Fengguang Wu)
Add Xeon D model number.
Remove cache event table (in separate patch)
Patch up remote node differences (Kan Liang)
--- arch/x86/kernel/cpu/perf_event_intel.c | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
arch/x86/kernel/cpu/perf_event_intel.c +48 -0
@@ -220,6 +220,15 @@ static struct event_constraint intel_hsw_event_constraints[] = { EVENT_CONSTRAINT_END }; +struct event_constraint intel_bdw_event_constraints[] = { +FIXED_EVENT_CONSTRAINT (0x00c0 ,0 ),/* INST_RETIRED.ANY */ +FIXED_EVENT_CONSTRAINT (0x003c ,1 ),/* CPU_CLK_UNHALTED.CORE */ +FIXED_EVENT_CONSTRAINT (0x0300 ,2 ),/* CPU_CLK_UNHALTED.REF */ +INTEL_UEVENT_CONSTRAINT (0x148 ,0x4 ),/* L1D_PEND_MISS.PENDING */ +INTEL_EVENT_CONSTRAINT (0xa3 ,0x4 ),/* CYCLE_ACTIVITY.* */ +EVENT_CONSTRAINT_END +}; +static u64 intel_pmu_event_map (int hw_event) {return intel_perfmon_event_map[hw_event];
@@ -433,12 +442,16 @@ static __initconst const u64 snb_hw_cache_event_ids#define HSW_ANY_RESPONSE BIT(16)#define HSW_SUPPLIER_NONE BIT(17)#define HSW_L3_MISS_LOCAL BIT(22) +#define BDW_L3_MISS_LOCAL BIT(26)#define HSW_L3_MISS_REMOTE_HOP0 BIT(27)#define HSW_L3_MISS_REMOTE_HOP1 BIT(28)#define HSW_L3_MISS_REMOTE_HOP2P BIT(29)#define HSW_L3_MISS (HSW_L3_MISS_LOCAL| \ HSW_L3_MISS_REMOTE_HOP0|HSW_L3_MISS_REMOTE_HOP1| \ HSW_L3_MISS_REMOTE_HOP2P) +#define BDW_L3_MISS (BDW_L3_MISS_LOCAL| \ + HSW_L3_MISS_REMOTE_HOP0|HSW_L3_MISS_REMOTE_HOP1| \ + HSW_L3_MISS_REMOTE_HOP2P)#define HSW_SNOOP_NONE BIT(31)#define HSW_SNOOP_NOT_NEEDED BIT(32)#define HSW_SNOOP_MISS BIT(33)
@@ -2759,6 +2772,41 @@ __init int intel_pmu_init(void)pr_cont ("Haswell events, " );break ; +case 61 :/* 14nm Broadwell Core-M */ +case 86 :/* 14nm Broadwell Xeon D */ + x86_pmu.late_ack = true; +memcpy (hw_cache_event_ids, hsw_hw_cache_event_ids,sizeof (hw_cache_event_ids)); +memcpy (hw_cache_extra_regs, hsw_hw_cache_extra_regs,sizeof (hw_cache_extra_regs)); + +/* L3_MISS_LOCAL_DRAM is BIT(26) in Broadwell */ + hw_cache_extra_regs[C (LL )][C (OP_READ )][C (RESULT_MISS )] =HSW_DEMAND_DATA_RD | +BDW_L3_MISS |HSW_ANY_SNOOP | +HSW_SUPPLIER_NONE ; + hw_cache_extra_regs[C (LL )][C (OP_WRITE )][C (RESULT_MISS )] =HSW_ALL_RFO |BDW_L3_MISS | +HSW_ANY_SNOOP |HSW_SUPPLIER_NONE ; + hw_cache_extra_regs[C (NODE )][C (OP_READ )][C (RESULT_ACCESS )] =HSW_DEMAND_DATA_RD | +BDW_L3_MISS_LOCAL |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP ; + hw_cache_extra_regs[C (NODE )][C (OP_WRITE )][C (RESULT_ACCESS )] =HSW_DEMAND_RFO | +BDW_L3_MISS_LOCAL |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP ; + +intel_pmu_lbr_init_snb (); + + x86_pmu.event_constraints = intel_bdw_event_constraints; + x86_pmu.pebs_constraints = intel_hsw_pebs_event_constraints; + x86_pmu.extra_regs = intel_snbep_extra_regs; + x86_pmu.pebs_aliases = intel_pebs_aliases_snb; +/* all extra regs are per-cpu when HT is on */ + x86_pmu.er_flags |=ERF_HAS_RSP_1 ; + x86_pmu.er_flags |=ERF_NO_HT_SHARING ; + + x86_pmu.hw_config = hsw_hw_config; + x86_pmu.get_event_constraints = hsw_get_event_constraints; + x86_pmu.cpu_events = hsw_events_attrs; +pr_cont ("Broadwell events, " ); +break ; +default :switch (x86_pmu.version) {case 1 :
Signature · 1 line
1.9.3
PATCH 3/3 perf, x86: Add INST_RETIRED.ALL workarounds
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
On Broadwell INST_RETIRED.ALL cannot be used with any period that doesn't have the lowest 6 bits cleared. And the period should not be smaller than 128.
Add a new callback to enforce this, and set it for Broadwell.
This is erratum BDM57 and BDM11.
How does this handle the case when an app requests a specific period with some of the bottom bits set
The apps thinks it is sampling at X occurences per sample, when it is in fact at X - 63 (worst case).
Short answer:
Any useful instruction sampling period needs to be 4-6 orders of magnitude larger than 128, as an PMI every 128 instructions would instantly overwhelm the system and be throttled. So the +-64 error from this is really small compared to the period, much smaller than normal system jitter.
Long answer:
<write up by Peter:>
IFF we guarantee perf_event_attr::sample_period >= 128.
Suppose we start out with sample_period=192; then we'll set period_left to 192, we'll end up with left = 128 (we truncate the lower bits). We get an interrupt, find that period_left = 64 (>0 so we return 0 and don't get an overflow handler), up that to 128. Then we trigger again, at n=256. Then we find period_left = -64 (<=0 so we return 1 and do get an overflow). We increment with sample_period so we get left = 128. We fire again, at n=384, period_left = 0 (<=0 so we return 1 and get an overflow). And on and on.
So while the individual interrupts are 'wrong' we get then with interval=256,128 in exactly the right ratio to average out at 192. And this works for everything >=128.
So the num_samples*fixed_period thing is still entirely correct +- 127, which is good enough I'd say, as you already have that error anyhow.
So no need to 'fix' the tools, al we need to do is refuse to create INST_RETIRED:ALL events with sample_period < 128.
v2: Use correct event name in description. Use EVENT() macro.
v3: Use INTEL_ARCH_EVENT_MASK. Error out for events with too small period.
v4: Expand description.
--- arch/x86/kernel/cpu/perf_event.c | 9 +++++++++ arch/x86/kernel/cpu/perf_event.h | 1 + arch/x86/kernel/cpu/perf_event_intel.c | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+)
arch/x86/kernel/cpu/perf_event.c +9 -0
@@ -445,6 +445,12 @@ int x86_pmu_hw_config(struct perf_event *event)if (event->attr.type ==PERF_TYPE_RAW ) event->hw.config |= event->attr.config &X86_RAW_EVENT_MASK ; +if (event->attr.sample_period && x86_pmu.limit_period) { +if (x86_pmu.limit_period (event, event->attr.sample_period) > + event->attr.sample_period) +return -EINVAL ; + } +return x86_setup_perfctr (event); }
@@ -982,6 +988,9 @@ int x86_perf_event_set_period(struct perf_event *event)if (left > x86_pmu.max_period) left = x86_pmu.max_period; +if (x86_pmu.limit_period) + left = x86_pmu.limit_period (event, left); +per_cpu (pmc_prev_left[idx],smp_processor_id ()) = left;/*
arch/x86/kernel/cpu/perf_event.h +1 -0
@@ -449,6 +449,7 @@ struct x86_pmu {struct x86_pmu_quirk *quirks;int perfctr_second_write;bool late_ack; +unsigned (*limit_period)(struct perf_event *event,unsigned l);/* * sysfs attrs
arch/x86/kernel/cpu/perf_event_intel.c +19 -0
@@ -2111,6 +2111,24 @@ hsw_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)return c; } +/* +* Broadwell: +* The INST_RETIRED.ALL period always needs to have lowest +* 6bits cleared (BDM57). It shall not use a period smaller +* than 100 (BDM11). We combine the two to enforce +* a min-period of 128. +*/ +static unsigned bdw_limit_period (struct perf_event *event,unsigned left) +{ +if ((event->hw.config &INTEL_ARCH_EVENT_MASK ) == + X86_CONFIG(.event=0xc0, .umask=0x01)) { +if (left <128 ) + left =128 ; + left &= ~0x3fu ; + } +return left; +} +PMU_FORMAT_ATTR (event,"config:0-7" );PMU_FORMAT_ATTR (umask,"config:8-15" );PMU_FORMAT_ATTR (edge,"config:18" );
@@ -2804,6 +2822,7 @@ __init int intel_pmu_init(void) x86_pmu.hw_config = hsw_hw_config; x86_pmu.get_event_constraints = hsw_get_event_constraints; x86_pmu.cpu_events = hsw_events_attrs; + x86_pmu.limit_period = bdw_limit_period;pr_cont ("Broadwell events, " );break ;
Signature · 1 line
1.9.3
Peter Zijlstra
maintainerarch/x86/kernel/cpu/perf_event_intel.c static __initconst const u64 snb_hw_cache_event_ids · line 425
Quoted 13 lines · Andi Kleen
+++
b/arch/x86/kernel/cpu/perf_event_intel.carch/x86/kernel/cpu/perf_event_intel.c +8
-0@@ -415,6 +415,199 @@ static __initconst const u64 snb_hw_cache_event_ids }; +/* +* Notes on the events: +* - data reads do not include code reads (comparable to earlier tables) +* - data counts include speculative execution (except L1 write, dtlb, bpu) +* - remote node access includes both remote memory, remote cache, remote mmio. +* - prefetches are not included in the counts. +* The events with additional caveats have references to the specification update. +*/
It would be good to have the prefetch note from the changelog in a comment here or at the extra_regs table; i.e. prefetches are not included because they're 'broken'.
Quoted 17 lines
arch/x86/kernel/cpu/perf_event_intel.c +17
-0+ +#define HSW_DEMAND_DATA_RD BIT(0) +#define HSW_DEMAND_RFO BIT(1) +#define HSW_PF_L2_RFO BIT(5) +#define HSW_PF_L3_RFO BIT(8) +#define HSW_ALL_RFO (HSW_DEMAND_RFO| \ + HSW_PF_L2_RFO|HSW_PF_L3_RFO) +#define HSW_ANY_RESPONSE BIT(16) +#define HSW_SUPPLIER_NONE BIT(17) +#define HSW_L3_MISS_LOCAL BIT(22) +#define HSW_L3_MISS_REMOTE_HOP0 BIT(27) +#define HSW_L3_MISS_REMOTE_HOP1 BIT(28) +#define HSW_L3_MISS_REMOTE_HOP2P BIT(29) +#define HSW_L3_MISS (HSW_L3_MISS_LOCAL| \ + HSW_L3_MISS_REMOTE_HOP0|HSW_L3_MISS_REMOTE_HOP1| \ + HSW_L3_MISS_REMOTE_HOP2P) +#define HSW_SNOOP_NONE BIT(31)
arch/x86/kernel/cpu/perf_event_intel.c static __initconst const u64 snb_hw_cache_event_ids · line 452
Quoted 10 lines
arch/x86/kernel/cpu/perf_event_intel.c +10
-0+#define HSW_SNOOP_NOT_NEEDED BIT(32) +#define HSW_SNOOP_MISS BIT(33) +#define HSW_SNOOP_HIT_NO_FWD BIT(34) +#define HSW_SNOOP_HIT_WITH_FWD BIT(35) +#define HSW_SNOOP_HITM BIT(36) +#define HSW_SNOOP_NON_DRAM BIT(37) +#define HSW_ANY_SNOOP (HSW_SNOOP_NONE| \ + HSW_SNOOP_NOT_NEEDED|HSW_SNOOP_MISS| \ + HSW_SNOOP_HIT_NO_FWD|HSW_SNOOP_HIT_WITH_FWD| \ + HSW_SNOOP_HITM|HSW_SNOOP_NON_DRAM)
Just in case someone is crazy enough to run a 32bit kernel on HSW, this needs to be BIT_ULL() -- also for compile testing, gcc tends to complain about things like (1UL << 32) for ILP32 targets.
Quoted 41 lines
arch/x86/kernel/cpu/perf_event_intel.c +41
-0+static __initconst const u64 hsw_hw_cache_extra_regs + [PERF_COUNT_HW_CACHE_MAX ] + [PERF_COUNT_HW_CACHE_OP_MAX ] + [PERF_COUNT_HW_CACHE_RESULT_MAX ] = +{ + [C (LL ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =HSW_DEMAND_DATA_RD | +HSW_ANY_RESPONSE |HSW_ANY_SNOOP | +HSW_SUPPLIER_NONE , + [C (RESULT_MISS ) ] =HSW_DEMAND_DATA_RD | +HSW_L3_MISS |HSW_ANY_SNOOP | +HSW_SUPPLIER_NONE , + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =HSW_DEMAND_RFO | +HSW_ANY_RESPONSE |HSW_ANY_SNOOP | +HSW_SUPPLIER_NONE , + [C (RESULT_MISS ) ] =HSW_DEMAND_RFO |HSW_L3_MISS | +HSW_ANY_SNOOP |HSW_SUPPLIER_NONE , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0x0 , + [C (RESULT_MISS ) ] =0x0 , + }, + }, + [C (NODE ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =HSW_DEMAND_DATA_RD | +HSW_L3_MISS_LOCAL |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP , + [C (RESULT_MISS ) ] =HSW_DEMAND_DATA_RD | +HSW_L3_MISS_REMOTE_HOP0 |HSW_L3_MISS_REMOTE_HOP1 | +HSW_L3_MISS_REMOTE_HOP2P |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP , + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =HSW_DEMAND_RFO | +HSW_L3_MISS_LOCAL |HSW_SUPPLIER_NONE | +HSW_ANY_SNOOP , + [ C(RESULT_MISS) ] = HSW_DEMAND_RFO|
arch/x86/kernel/cpu/perf_event_intel.c static __initconst const u64 snb_hw_cache_event_ids · line 609
Quoted 10 lines
arch/x86/kernel/cpu/perf_event_intel.c +10
-0+HSW_L3_MISS_REMOTE_HOP0 |HSW_L3_MISS_REMOTE_HOP1 | +HSW_L3_MISS_REMOTE_HOP2P |HSW_SUPPLIER_NONE | + HSW_ANY_SNOOP, + }, + [ C(OP_PREFETCH) ] = { + [ C(RESULT_ACCESS) ] = 0x0, + [ C(RESULT_MISS) ] = 0x0, + }, + }, +};
Now the other tables create little helpers like:
#define HSW_DMND_READ (HSW_DMND_DATA_RD)
#define HSW_DMND_WRITE (HSW_DMND_RFO)
#define HSW_L3_ACCESS (HSW_ANY_RESPONSE)
#define HSW_L3_MISS (HSW_L3_MISS)
And compose the tables values using those:
HSW_DMND_READ|HSW_L3_ACCESS
Please do so here too.
Now; when comparing these value to the SNB for example I note that you include ANY_SNOOP and SUPPLIER_NONE in L3_ACCESS, SNB and other do not, please explain.
Quoted 3 lines
Just in case someone is crazy enough to run a 32bit kernel on HSW, this needs to be
BIT_ULL()-- also for compile testing, gcc tends to complain about things like (1UL << 32) for ILP32 targets.
Ok.
Quoted 5 lines
Now the other tables create little helpers like:
#define
HSW_DMND_READ(HSW_DMND_DATA_RD)
#defineHSW_DMND_WRITE(HSW_DMND_RFO)
Quoted 8 lines
#define
HSW_L3_ACCESS(HSW_ANY_RESPONSE)
#defineHSW_L3_MISS(HSW_L3_MISS)And compose the tables values using those:
HSW_DMND_READ|HSW_L3_ACCESS
Please do so here too.
I'm trying to stay with the official documented bit names. No such bit names exist. If we make up our own names nobody else can read it anymore.
Quoted 4 lines
Now; when comparing these value to the SNB for example I note that you include
ANY_SNOOPandSUPPLIER_NONEinL3_ACCESS, SNB and other do not, please explain.
You're supposed to set a snoop and supplier qualifier. AFAIK SNB should set them too. It may work without them due to some quirk.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only
Peter Zijlstra
maintainerQuoted 8 lines · Andi Kleen
Quoted 8 lines
Now the other tables create little helpers like:
#define
HSW_DMND_READ(HSW_DMND_DATA_RD)
#defineHSW_DMND_WRITE(HSW_DMND_RFO)#define
HSW_L3_ACCESS(HSW_ANY_RESPONSE)
#defineHSW_L3_MISS(HSW_L3_MISS)
Quoted 8 lines
Quoted 5 lines
And compose the tables values using those:
HSW_DMND_READ|HSW_L3_ACCESS
Please do so here too.
I'm trying to stay with the official documented bit names. No such bit names exist. If we make up our own names nobody else can read it anymore.
Well, its a simple matter of looking up the bit definitions; we define those helpers in terms of the official names after all.
By having the 4 helpers {r,w}x{access,miss} you avoid some repetition and decrease the room for mistakes.
Quoted 7 lines
Quoted 3 lines
Now; when comparing these value to the SNB for example I note that you include
ANY_SNOOPandSUPPLIER_NONEinL3_ACCESS, SNB and other do not, please explain.You're supposed to set a snoop and supplier qualifier. AFAIK SNB should set them too. It may work without them due to some quirk.
OK, then we should fix the others. Thanks.