perf/x86/intel/pt: Add a capability and config bit for disabling TNTs
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Wed, 26 Jan 2022 10:48:15 +0000 (12:48 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 15 Feb 2022 16:47:11 +0000 (17:47 +0100)
As of Intel SDM (https://www.intel.com/sdm) version 076, there is a new
Intel PT feature called TNT-Disable which is enabled config bit 55.

TNT-Disable disables Taken-Not-Taken packets to reduce the tracing
overhead, but with the result that exact control flow information is
lost.

Add a capability and config bit for TNT-Disable.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20220126104815.2807416-3-adrian.hunter@intel.com
arch/x86/events/intel/pt.c
arch/x86/include/asm/intel_pt.h
arch/x86/include/asm/msr-index.h

index f339c88d17f91fd290dae611274289e4096a5e3f..aa66c0c7b18bc855ee77c8e81285ca132c53bfaa 100644 (file)
@@ -60,6 +60,7 @@ static struct pt_cap_desc {
        PT_CAP(ptwrite,                 0, CPUID_EBX, BIT(4)),
        PT_CAP(power_event_trace,       0, CPUID_EBX, BIT(5)),
        PT_CAP(event_trace,             0, CPUID_EBX, BIT(7)),
+       PT_CAP(tnt_disable,             0, CPUID_EBX, BIT(8)),
        PT_CAP(topa_output,             0, CPUID_ECX, BIT(0)),
        PT_CAP(topa_multiple_entries,   0, CPUID_ECX, BIT(1)),
        PT_CAP(single_range_output,     0, CPUID_ECX, BIT(2)),
@@ -112,6 +113,7 @@ PMU_FORMAT_ATTR(noretcomp,  "config:11"     );
 PMU_FORMAT_ATTR(ptw,           "config:12"     );
 PMU_FORMAT_ATTR(branch,                "config:13"     );
 PMU_FORMAT_ATTR(event,         "config:31"     );
+PMU_FORMAT_ATTR(notnt,         "config:55"     );
 PMU_FORMAT_ATTR(mtc_period,    "config:14-17"  );
 PMU_FORMAT_ATTR(cyc_thresh,    "config:19-22"  );
 PMU_FORMAT_ATTR(psb_period,    "config:24-27"  );
@@ -121,6 +123,7 @@ static struct attribute *pt_formats_attr[] = {
        &format_attr_cyc.attr,
        &format_attr_pwr_evt.attr,
        &format_attr_event.attr,
+       &format_attr_notnt.attr,
        &format_attr_fup_on_ptw.attr,
        &format_attr_mtc.attr,
        &format_attr_tsc.attr,
@@ -302,6 +305,7 @@ fail:
                        RTIT_CTL_MTC            | \
                        RTIT_CTL_PWR_EVT_EN     | \
                        RTIT_CTL_EVENT_EN       | \
+                       RTIT_CTL_NOTNT          | \
                        RTIT_CTL_FUP_ON_PTW     | \
                        RTIT_CTL_PTW_EN)
 
@@ -360,6 +364,10 @@ static bool pt_event_valid(struct perf_event *event)
            !intel_pt_validate_hw_cap(PT_CAP_event_trace))
                return false;
 
+       if (config & RTIT_CTL_NOTNT &&
+           !intel_pt_validate_hw_cap(PT_CAP_tnt_disable))
+               return false;
+
        if (config & RTIT_CTL_PTW) {
                if (!intel_pt_validate_hw_cap(PT_CAP_ptwrite))
                        return false;
index d1ef9cb5884748f73cec583ba1b895192f124315..c796e9bc98b6cb528d24ebb4664ce8c53226f82a 100644 (file)
@@ -14,6 +14,7 @@ enum pt_capabilities {
        PT_CAP_ptwrite,
        PT_CAP_power_event_trace,
        PT_CAP_event_trace,
+       PT_CAP_tnt_disable,
        PT_CAP_topa_output,
        PT_CAP_topa_multiple_entries,
        PT_CAP_single_range_output,
index 79b392d893e31cfcc3bdac676ad66dbeaf12b609..efd34cfa17200ca6aa29cf95bcf2aa5f9f43e069 100644 (file)
 #define RTIT_CTL_PTW_EN                        BIT(12)
 #define RTIT_CTL_BRANCH_EN             BIT(13)
 #define RTIT_CTL_EVENT_EN              BIT(31)
+#define RTIT_CTL_NOTNT                 BIT_ULL(55)
 #define RTIT_CTL_MTC_RANGE_OFFSET      14
 #define RTIT_CTL_MTC_RANGE             (0x0full << RTIT_CTL_MTC_RANGE_OFFSET)
 #define RTIT_CTL_CYC_THRESH_OFFSET     19