From 10e30e21dbe47702c1580ee315de6bd79fe8bcdf Mon Sep 17 00:00:00 2001
From: Luming Yu <luming.yu@intel.com>
Date: Fri, 29 Sep 2017 22:00:44 +0800
Subject: [PATCH v1 3/9] early pt: boot option to enable early pt

boot option "early_pt" to enable early pt 

Signed-off-by: Luming Yu <luming.yu@intel.com>
---
 arch/x86/events/intel/early_pt.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/events/intel/early_pt.c b/arch/x86/events/intel/early_pt.c
index 67513ed..16ed03c 100644
--- a/arch/x86/events/intel/early_pt.c
+++ b/arch/x86/events/intel/early_pt.c
@@ -42,6 +42,8 @@
 static int	early_pt_buffer_order = 9;
 static bool	single_range = true;
 
+static bool early_pt_enabled = false;
+
 static DEFINE_PER_CPU(bool, early_pt_running);
 static DEFINE_PER_CPU(u64, pt_offset);
 static DEFINE_PER_CPU(u64, pt_buffer_cpu);
@@ -201,6 +203,8 @@ static int early_pt_init(void)
 {
 	int err;
 
+	if (!early_pt_enabled)
+		return 0;
 	err = early_pt_cpuid_caps();
 	if (err < 0) {
 		pr_info("early_pt_init: no feature available\n");
@@ -214,6 +218,8 @@ static int late_pt_init(void)
 	int err;
 	unsigned int i;
 
+	if (!early_pt_enabled)
+		return 0;
 	for_each_online_cpu(i) {
 		if (!per_cpu(early_pt_running, i)) {
 			pr_err("late_pt_init: failed, early pt not running\n");
@@ -335,3 +341,10 @@ static struct miscdevice early_pt_miscdev = {
 	&early_pt_fops
 };
 
+static int __init early_pt_enable(char *str)
+{
+	early_pt_enabled = true;
+	return 0;
+}
+early_param("early_pt", early_pt_enable);
+
-- 
2.7.5

