public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf, x86: Make cycles:p working on SNB
@ 2012-05-24  3:02 Namhyung Kim
  2012-05-24  7:27 ` Peter Zijlstra
  0 siblings, 1 reply; 16+ messages in thread
From: Namhyung Kim @ 2012-05-24  3:02 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: Namhyung Kim, Arnaldo Carvalho de Melo, Paul Mackerras, LKML

The Intel SDM (Vol.3B 18-55, Table 18-21) says the PEBS
is only work for INST_RETIRED.PREC_DIST (0x01C0) and it's
applied into intel_snb_pebs_event_constraints already.
Thus, current alt_config which has umake set to 0 cannot
work on SNBs and the output will look like below:

 namhyung@sejong:perf$ ./perf stat -e cycles:p noploop 1

 Performance counter stats for 'noploop 1':

   <not supported> cycles

       1.001116732 seconds time elapsed

After applying this patch, the event is counted properly.

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
---
 arch/x86/kernel/cpu/perf_event_intel.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 166546ec6aef..db8948171e22 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1329,6 +1329,12 @@ static int intel_pmu_hw_config(struct perf_event *event)
 		 */
 		u64 alt_config = X86_CONFIG(.event=0xc0, .inv=1, .cmask=16);
 
+		/*
+		 * SNB introduced INST_RETIRED.PREC_DIST for this purpose.
+		 */
+		if (x86_pmu.pebs_constraints == intel_snb_pebs_event_constraints)
+			alt_config = X86_CONFIG(.event=0xc0, .umask=0x01,
+						.inv=1, .cmask=16);
 
 		alt_config |= (event->hw.config & ~X86_RAW_EVENT_MASK);
 		event->hw.config = alt_config;
-- 
1.7.10.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-06-01  7:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-24  3:02 [PATCH] perf, x86: Make cycles:p working on SNB Namhyung Kim
2012-05-24  7:27 ` Peter Zijlstra
2012-05-24  7:41   ` Stephane Eranian
2012-05-24  7:52     ` Peter Zijlstra
2012-05-24  7:57       ` Peter Zijlstra
2012-05-24  8:00         ` Stephane Eranian
2012-05-24  8:07           ` Peter Zijlstra
2012-05-24  8:59             ` Stephane Eranian
2012-05-24  9:01             ` Namhyung Kim
2012-05-24  7:58       ` Stephane Eranian
2012-05-30 12:16         ` Peter Zijlstra
2012-06-01  7:44           ` Stephane Eranian
2012-05-24  8:59     ` Namhyung Kim
2012-05-24  9:06       ` Stephane Eranian
2012-05-24  8:53   ` Namhyung Kim
2012-05-24  8:59     ` Stephane Eranian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox