Skip to content

Commit 95f3be7

Browse files
kliang2Ingo Molnar
authored andcommitted
perf/x86/intel/uncore: Add enable_box for client MSR uncore
There are bug reports about miscounting uncore counters on some client machines like Sandybridge, Broadwell and Skylake. It is very likely to be observed on idle systems. This issue is caused by a hardware issue. PERF_GLOBAL_CTL could be cleared after Package C7, and nothing will be count. The related errata (HSD 158) could be found in: www.intel.com/content/dam/www/public/us/en/documents/specification-updates/4th-gen-core-family-desktop-specification-update.pdf This patch tries to work around this issue by re-enabling PERF_GLOBAL_CTL in ->enable_box(). The workaround does not cover all cases. It helps for new events after returning from C7. But it cannot prevent C7, it will still miscount if a counter is already active. There is no drawback in leaving it enabled, so it does not need disable_box() here. Signed-off-by: Kan Liang <kan.liang@intel.com> Cc: <stable@vger.kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Link: http://lkml.kernel.org/r/1470925874-59943-1-git-send-email-kan.liang@intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 10e9e7b commit 95f3be7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/x86/events/intel/uncore_snb.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ static void snb_uncore_msr_init_box(struct intel_uncore_box *box)
100100
}
101101
}
102102

103+
static void snb_uncore_msr_enable_box(struct intel_uncore_box *box)
104+
{
105+
wrmsrl(SNB_UNC_PERF_GLOBAL_CTL,
106+
SNB_UNC_GLOBAL_CTL_EN | SNB_UNC_GLOBAL_CTL_CORE_ALL);
107+
}
108+
103109
static void snb_uncore_msr_exit_box(struct intel_uncore_box *box)
104110
{
105111
if (box->pmu->pmu_idx == 0)
@@ -127,6 +133,7 @@ static struct attribute_group snb_uncore_format_group = {
127133

128134
static struct intel_uncore_ops snb_uncore_msr_ops = {
129135
.init_box = snb_uncore_msr_init_box,
136+
.enable_box = snb_uncore_msr_enable_box,
130137
.exit_box = snb_uncore_msr_exit_box,
131138
.disable_event = snb_uncore_msr_disable_event,
132139
.enable_event = snb_uncore_msr_enable_event,
@@ -192,6 +199,12 @@ static void skl_uncore_msr_init_box(struct intel_uncore_box *box)
192199
}
193200
}
194201

202+
static void skl_uncore_msr_enable_box(struct intel_uncore_box *box)
203+
{
204+
wrmsrl(SKL_UNC_PERF_GLOBAL_CTL,
205+
SNB_UNC_GLOBAL_CTL_EN | SKL_UNC_GLOBAL_CTL_CORE_ALL);
206+
}
207+
195208
static void skl_uncore_msr_exit_box(struct intel_uncore_box *box)
196209
{
197210
if (box->pmu->pmu_idx == 0)
@@ -200,6 +213,7 @@ static void skl_uncore_msr_exit_box(struct intel_uncore_box *box)
200213

201214
static struct intel_uncore_ops skl_uncore_msr_ops = {
202215
.init_box = skl_uncore_msr_init_box,
216+
.enable_box = skl_uncore_msr_enable_box,
203217
.exit_box = skl_uncore_msr_exit_box,
204218
.disable_event = snb_uncore_msr_disable_event,
205219
.enable_event = snb_uncore_msr_enable_event,

0 commit comments

Comments
 (0)