From patchwork Tue Aug 22 16:11:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 27725 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id A720F7D62; Tue, 22 Aug 2017 18:12:45 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id A5A787D24 for ; Tue, 22 Aug 2017 18:12:40 +0200 (CEST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2017 09:12:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,412,1498546800"; d="scan'208";a="142675211" Received: from silpixa00397898.ir.intel.com (HELO silpixa00397898.ger.corp.intel.com) ([10.237.223.116]) by fmsmga005.fm.intel.com with ESMTP; 22 Aug 2017 09:12:11 -0700 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com Date: Tue, 22 Aug 2017 17:11:50 +0100 Message-Id: <1503418310-162535-5-git-send-email-david.hunt@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503418310-162535-1-git-send-email-david.hunt@intel.com> References: <1503418310-162535-1-git-send-email-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v1 4/4] lib: limit turbo to particular models of CPU X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 #include #include +#include #include #include @@ -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.