[dpdk-dev] [PATCH v1 4/4] lib: limit turbo to particular models of CPU

David Hunt david.hunt at intel.com
Tue Aug 22 18:11:50 CEST 2017


The per-core turbo functionality is only available on specific models
of CPU, so this patch limits it to those models.

Signed-off-by: David Hunt <david.hunt at intel.com>
---
 lib/librte_power/rte_power_acpi_cpufreq.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/lib/librte_power/rte_power_acpi_cpufreq.c b/lib/librte_power/rte_power_acpi_cpufreq.c
index 6695f59..ec8d304 100644
--- a/lib/librte_power/rte_power_acpi_cpufreq.c
+++ b/lib/librte_power/rte_power_acpi_cpufreq.c
@@ -40,6 +40,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <limits.h>
+#include <cpuid.h>
 
 #include <rte_memcpy.h>
 #include <rte_atomic.h>
@@ -554,6 +555,27 @@ rte_power_acpi_cpufreq_freq_min(unsigned lcore_id)
 
 
 static int
+per_core_turbo_supported(void)
+{
+	uint32_t eax, ebx, ecx, edx;
+	int family, model;
+
+	__cpuid(1, eax, ebx, ecx, edx);
+
+	family = (eax >> 8) & 0xf;
+	if (family > 5)
+		model = ((eax >> 4) & 0xf) | ((eax >> 12) & 0xf0);
+	else
+		model = (eax >> 4) & 0xf;
+
+	if (family == 6)
+		if ((model == 63) || (model == 79) || (model == 85))
+			return 1;
+	return 0;
+}
+
+
+static int
 rdmsr(int lcore, int msr, uint64_t *val)
 {
 	char filename[32];
@@ -607,6 +629,8 @@ rte_power_acpi_turbo_status(unsigned int lcore_id)
 	}
 
 #if defined(RTE_ARCH_I686) || defined(RTE_ARCH_X86_64)
+	if (!per_core_turbo_supported())
+		return 0;
 	retval = rdmsr(lcore_id, IA32_PERF_CTL, &val);
 	if (retval)
 		return retval;
@@ -630,6 +654,8 @@ rte_power_acpi_enable_turbo(unsigned int lcore_id)
 	}
 
 #if defined(RTE_ARCH_I686) || defined(RTE_ARCH_X86_64)
+	if (!per_core_turbo_supported())
+		return 0;
 	/*
 	 * The low byte of 1ADh MSR contains max recomended ratio when a small
 	 * number of cores are active. Use this ratio when turbo is enabled.
@@ -663,6 +689,8 @@ rte_power_acpi_disable_turbo(unsigned int lcore_id)
 	}
 
 #if defined(RTE_ARCH_I686) || defined(RTE_ARCH_X86_64)
+	if (!per_core_turbo_supported())
+		return 0;
 	/*
 	 * 0CEh MSR contains max non-turbo ratio in bits 8-15. Use this
 	 * for the freq when turbo is disabled for that core.
-- 
2.7.4



More information about the dev mailing list