Skip to content

Commit 4b3d06d

Browse files
Andi Kleengregkh
authored andcommitted
perf/x86/intel: Fix PEBS data source interpretation on Nehalem/Westmere
commit e17dc65328057c00db7e1bfea249c8771a78b30b upstream. Jiri reported some time ago that some entries in the PEBS data source table in perf do not agree with the SDM. We investigated and the bits changed for Sandy Bridge, but the SDM was not updated. perf already implements the bits correctly for Sandy Bridge and later. This patch patches it up for Nehalem and Westmere. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: jolsa@kernel.org Link: http://lkml.kernel.org/r/1456871124-15985-1-git-send-email-andi@firstfloor.org Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a54af12 commit 4b3d06d

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

arch/x86/kernel/cpu/perf_event.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,8 @@ void intel_pmu_lbr_init_hsw(void);
908908

909909
void intel_pmu_lbr_init_skl(void);
910910

911+
void intel_pmu_pebs_data_source_nhm(void);
912+
911913
int intel_pmu_setup_lbr_filter(struct perf_event *event);
912914

913915
void intel_pt_interrupt(void);

arch/x86/kernel/cpu/perf_event_intel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,6 +3336,7 @@ __init int intel_pmu_init(void)
33363336
intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =
33373337
X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1);
33383338

3339+
intel_pmu_pebs_data_source_nhm();
33393340
x86_add_quirk(intel_nehalem_quirk);
33403341

33413342
pr_cont("Nehalem events, ");
@@ -3398,6 +3399,7 @@ __init int intel_pmu_init(void)
33983399
intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] =
33993400
X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1);
34003401

3402+
intel_pmu_pebs_data_source_nhm();
34013403
pr_cont("Westmere events, ");
34023404
break;
34033405

arch/x86/kernel/cpu/perf_event_intel_ds.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ union intel_x86_pebs_dse {
5151
#define OP_LH (P(OP, LOAD) | P(LVL, HIT))
5252
#define SNOOP_NONE_MISS (P(SNOOP, NONE) | P(SNOOP, MISS))
5353

54-
static const u64 pebs_data_source[] = {
54+
/* Version for Sandy Bridge and later */
55+
static u64 pebs_data_source[] = {
5556
P(OP, LOAD) | P(LVL, MISS) | P(LVL, L3) | P(SNOOP, NA),/* 0x00:ukn L3 */
5657
OP_LH | P(LVL, L1) | P(SNOOP, NONE), /* 0x01: L1 local */
5758
OP_LH | P(LVL, LFB) | P(SNOOP, NONE), /* 0x02: LFB hit */
@@ -70,6 +71,14 @@ static const u64 pebs_data_source[] = {
7071
OP_LH | P(LVL, UNC) | P(SNOOP, NONE), /* 0x0f: uncached */
7172
};
7273

74+
/* Patch up minor differences in the bits */
75+
void __init intel_pmu_pebs_data_source_nhm(void)
76+
{
77+
pebs_data_source[0x05] = OP_LH | P(LVL, L3) | P(SNOOP, HIT);
78+
pebs_data_source[0x06] = OP_LH | P(LVL, L3) | P(SNOOP, HITM);
79+
pebs_data_source[0x07] = OP_LH | P(LVL, L3) | P(SNOOP, HITM);
80+
}
81+
7382
static u64 precise_store_data(u64 status)
7483
{
7584
union intel_x86_pebs_dse dse;

0 commit comments

Comments
 (0)