Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1568437 > unrolled thread

[PATCH 0/2] perf/x86/intel/pt: Misc updates

Started byAlexander Shishkin <alexander.shishkin@linux.intel.com>
First post2017-01-27 16:30 +0100
Last post2017-01-27 16:40 +0100
Articles 3 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] perf/x86/intel/pt: Misc updates Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2017-01-27 16:30 +0100
    [PATCH 1/2] perf/x86/intel/pt: Add format strings for PTWRITE and power event tracing Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2017-01-27 16:30 +0100
    [PATCH 2/2] perf/x86/intel/pt: Allow disabling branch tracing Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2017-01-27 16:40 +0100

#1568437 — [PATCH 0/2] perf/x86/intel/pt: Misc updates

FromAlexander Shishkin <alexander.shishkin@linux.intel.com>
Date2017-01-27 16:30 +0100
Subject[PATCH 0/2] perf/x86/intel/pt: Misc updates
Message-ID<t4gDo-5Qo-19@gated-at.bofh.it>
Hi Peter,

Here I have two small updates. Branch tracing can now be disabled
so that we have more bandwidth for other things that PT may log,
such as power events. The latter, along with the PTWRITE, didn't
get their own format strings before, so adding them now.

Alexander Shishkin (2):
  perf/x86/intel/pt: Add format strings for PTWRITE and power event
    tracing
  perf/x86/intel/pt: Allow disabling branch tracing

 arch/x86/events/intel/pt.c | 42 +++++++++++++++++++++++++++++++++++++++++-
 arch/x86/events/intel/pt.h |  1 +
 2 files changed, 42 insertions(+), 1 deletion(-)

-- 
2.11.0

[toc] | [next] | [standalone]


#1568438 — [PATCH 1/2] perf/x86/intel/pt: Add format strings for PTWRITE and power event tracing

FromAlexander Shishkin <alexander.shishkin@linux.intel.com>
Date2017-01-27 16:30 +0100
Subject[PATCH 1/2] perf/x86/intel/pt: Add format strings for PTWRITE and power event tracing
Message-ID<t4gDo-5Qo-23@gated-at.bofh.it>
In reply to#1568437
Commit 8ee83b2ab3 ("perf/x86/intel/pt: Add support for PTWRITE and power
event tracing") forgot to add format strings to the PT driver. So one
could enable these features by setting corresponding bits in the event
config, but not by their mnemonic names.

This patch adds the format strings.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 8ee83b2ab3 ("perf/x86/intel/pt: Add support for PTWRITE...")
---
 arch/x86/events/intel/pt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 54dd585771..ece5fb06db 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -99,18 +99,24 @@ static struct attribute_group pt_cap_group = {
 };
 
 PMU_FORMAT_ATTR(cyc,		"config:1"	);
+PMU_FORMAT_ATTR(pwr_evt,	"config:4"	);
+PMU_FORMAT_ATTR(fup_on_ptw,	"config:5"	);
 PMU_FORMAT_ATTR(mtc,		"config:9"	);
 PMU_FORMAT_ATTR(tsc,		"config:10"	);
 PMU_FORMAT_ATTR(noretcomp,	"config:11"	);
+PMU_FORMAT_ATTR(ptw,		"config:12"	);
 PMU_FORMAT_ATTR(mtc_period,	"config:14-17"	);
 PMU_FORMAT_ATTR(cyc_thresh,	"config:19-22"	);
 PMU_FORMAT_ATTR(psb_period,	"config:24-27"	);
 
 static struct attribute *pt_formats_attr[] = {
 	&format_attr_cyc.attr,
+	&format_attr_pwr_evt.attr,
+	&format_attr_fup_on_ptw.attr,
 	&format_attr_mtc.attr,
 	&format_attr_tsc.attr,
 	&format_attr_noretcomp.attr,
+	&format_attr_ptw.attr,
 	&format_attr_mtc_period.attr,
 	&format_attr_cyc_thresh.attr,
 	&format_attr_psb_period.attr,
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1568449 — [PATCH 2/2] perf/x86/intel/pt: Allow disabling branch tracing

FromAlexander Shishkin <alexander.shishkin@linux.intel.com>
Date2017-01-27 16:40 +0100
Subject[PATCH 2/2] perf/x86/intel/pt: Allow disabling branch tracing
Message-ID<t4gN5-5TS-37@gated-at.bofh.it>
In reply to#1568437
Now that Intel PT supports more types of trace content than just branch
tracing, it may be useful to allow the user to disable branch tracing
when it is not needed.

The special case is BDW, where not setting BranchEn is not supported.

This patch adds 'no_branch' event format string to PT events, which
will disable setting BranchEn bit in the hardware trace configuration.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 arch/x86/events/intel/pt.c | 36 +++++++++++++++++++++++++++++++++++-
 arch/x86/events/intel/pt.h |  1 +
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index ece5fb06db..57478c2d0f 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -28,6 +28,7 @@
 #include <asm/insn.h>
 #include <asm/io.h>
 #include <asm/intel_pt.h>
+#include <asm/intel-family.h>
 
 #include "../perf_event.h"
 #include "pt.h"
@@ -105,6 +106,7 @@ PMU_FORMAT_ATTR(mtc,		"config:9"	);
 PMU_FORMAT_ATTR(tsc,		"config:10"	);
 PMU_FORMAT_ATTR(noretcomp,	"config:11"	);
 PMU_FORMAT_ATTR(ptw,		"config:12"	);
+PMU_FORMAT_ATTR(no_branch,	"config:13"	);
 PMU_FORMAT_ATTR(mtc_period,	"config:14-17"	);
 PMU_FORMAT_ATTR(cyc_thresh,	"config:19-22"	);
 PMU_FORMAT_ATTR(psb_period,	"config:24-27"	);
@@ -117,6 +119,7 @@ static struct attribute *pt_formats_attr[] = {
 	&format_attr_tsc.attr,
 	&format_attr_noretcomp.attr,
 	&format_attr_ptw.attr,
+	&format_attr_no_branch.attr,
 	&format_attr_mtc_period.attr,
 	&format_attr_cyc_thresh.attr,
 	&format_attr_psb_period.attr,
@@ -197,6 +200,19 @@ static int __init pt_pmu_hw_init(void)
 		pt_pmu.tsc_art_den = eax;
 	}
 
+	/* model-specific quirks */
+	switch (boot_cpu_data.x86_model) {
+	case INTEL_FAM6_BROADWELL_CORE:
+	case INTEL_FAM6_BROADWELL_XEON_D:
+	case INTEL_FAM6_BROADWELL_GT3E:
+	case INTEL_FAM6_BROADWELL_X:
+		/* not setting BRANCH_EN will #GP, erratum BDM106 */
+		pt_pmu.branch_en_always_on = true;
+		break;
+	default:
+		break;
+	}
+
 	if (boot_cpu_has(X86_FEATURE_VMX)) {
 		/*
 		 * Intel SDM, 36.5 "Tracing post-VMXON" says that
@@ -265,6 +281,7 @@ static int __init pt_pmu_hw_init(void)
 
 #define PT_CONFIG_MASK (RTIT_CTL_TSC_EN		| \
 			RTIT_CTL_DISRETC	| \
+			RTIT_CTL_BRANCH_EN	| \
 			RTIT_CTL_CYC_PSB	| \
 			RTIT_CTL_MTC		| \
 			RTIT_CTL_PWR_EVT_EN	| \
@@ -332,6 +349,10 @@ static bool pt_event_valid(struct perf_event *event)
 			return false;
 	}
 
+	/* trying to unset BRANCH_EN where it is not supported */
+	if (config & RTIT_CTL_BRANCH_EN && pt_pmu.branch_en_always_on)
+		return false;
+
 	return true;
 }
 
@@ -419,7 +440,20 @@ static void pt_config(struct perf_event *event)
 	}
 
 	reg = pt_config_filters(event);
-	reg |= RTIT_CTL_TOPA | RTIT_CTL_BRANCH_EN | RTIT_CTL_TRACEEN;
+	reg |= RTIT_CTL_TOPA | RTIT_CTL_TRACEEN;
+
+	/*
+	 * Previously, we had BRANCH_EN on by default, but now that PT has
+	 * grown features outside of branch tracing, it is useful to allow
+	 * the user to disable it. So, to keep compatibility, setting
+	 * BRANCH_EN bit in the event config (no_branch=1) will have the
+	 * reverse effect and *not* set BRANCH_EN in the hardware
+	 * configuration.
+	 */
+	if (!(event->attr.config & RTIT_CTL_BRANCH_EN))
+		reg |= RTIT_CTL_BRANCH_EN;
+	else
+		event->attr.config &= ~RTIT_CTL_BRANCH_EN;
 
 	if (!event->attr.exclude_kernel)
 		reg |= RTIT_CTL_OS;
diff --git a/arch/x86/events/intel/pt.h b/arch/x86/events/intel/pt.h
index 53473c21b5..93a3633e4c 100644
--- a/arch/x86/events/intel/pt.h
+++ b/arch/x86/events/intel/pt.h
@@ -110,6 +110,7 @@ struct pt_pmu {
 	struct pmu		pmu;
 	u32			caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES];
 	bool			vmx;
+	bool			branch_en_always_on;
 	unsigned long		max_nonturbo_ratio;
 	unsigned int		tsc_art_num;
 	unsigned int		tsc_art_den;
-- 
2.11.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web