Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/28651/?format=api
http://patches.dpdk.org/api/patches/28651/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1505299459-24135-2-git-send-email-david.hunt@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1505299459-24135-2-git-send-email-david.hunt@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1505299459-24135-2-git-send-email-david.hunt@intel.com", "date": "2017-09-13T10:44:16", "name": "[dpdk-dev,v2,1/4] lib/librte_power: add turbo boost API", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "f279529a4ce86f4892f2b524f864e7492794204e", "submitter": { "id": 342, "url": "http://patches.dpdk.org/api/people/342/?format=api", "name": "Hunt, David", "email": "david.hunt@intel.com" }, "delegate": { "id": 319, "url": "http://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1505299459-24135-2-git-send-email-david.hunt@intel.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/28651/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/28651/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6BB99199B5;\n\tWed, 13 Sep 2017 12:47:37 +0200 (CEST)", "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 57FF97CBD\n\tfor <dev@dpdk.org>; Wed, 13 Sep 2017 12:47:33 +0200 (CEST)", "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t13 Sep 2017 03:47:32 -0700", "from silpixa00397898.ir.intel.com ([10.237.223.116])\n\tby fmsmga004.fm.intel.com with ESMTP; 13 Sep 2017 03:47:31 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.42,387,1500966000\"; d=\"scan'208\";a=\"311165200\"", "From": "David Hunt <david.hunt@intel.com>", "To": "dev@dpdk.org", "Cc": "David Hunt <david.hunt@intel.com>", "Date": "Wed, 13 Sep 2017 11:44:16 +0100", "Message-Id": "<1505299459-24135-2-git-send-email-david.hunt@intel.com>", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1505299459-24135-1-git-send-email-david.hunt@intel.com>", "References": "<1503418310-162535-2-git-send-email-david.hunt@intel.com>\n\t<1505299459-24135-1-git-send-email-david.hunt@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 1/4] lib/librte_power: add turbo boost API", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Adds a new set of APIs to allow per-core turbo\nenable-disable.\n\nSigned-off-by: David Hunt <david.hunt@intel.com>\n---\n lib/librte_power/channel_commands.h | 2 +\n lib/librte_power/rte_power.c | 9 +++\n lib/librte_power/rte_power.h | 41 +++++++++++\n lib/librte_power/rte_power_acpi_cpufreq.c | 111 +++++++++++++++++++++++++++++-\n lib/librte_power/rte_power_acpi_cpufreq.h | 40 +++++++++++\n lib/librte_power/rte_power_kvm_vm.c | 19 +++++\n lib/librte_power/rte_power_kvm_vm.h | 35 +++++++++-\n 7 files changed, 255 insertions(+), 2 deletions(-)", "diff": "diff --git a/lib/librte_power/channel_commands.h b/lib/librte_power/channel_commands.h\nindex 383897b..484085b 100644\n--- a/lib/librte_power/channel_commands.h\n+++ b/lib/librte_power/channel_commands.h\n@@ -52,6 +52,8 @@ extern \"C\" {\n #define CPU_POWER_SCALE_DOWN 2\n #define CPU_POWER_SCALE_MAX 3\n #define CPU_POWER_SCALE_MIN 4\n+#define CPU_POWER_ENABLE_TURBO 5\n+#define CPU_POWER_DISABLE_TURBO 6\n \n struct channel_packet {\n \tuint64_t resource_id; /**< core_num, device */\ndiff --git a/lib/librte_power/rte_power.c b/lib/librte_power/rte_power.c\nindex 998ed1c..b327a86 100644\n--- a/lib/librte_power/rte_power.c\n+++ b/lib/librte_power/rte_power.c\n@@ -50,6 +50,9 @@ rte_power_freq_change_t rte_power_freq_up = NULL;\n rte_power_freq_change_t rte_power_freq_down = NULL;\n rte_power_freq_change_t rte_power_freq_max = NULL;\n rte_power_freq_change_t rte_power_freq_min = NULL;\n+rte_power_freq_change_t rte_power_turbo_status;\n+rte_power_freq_change_t rte_power_freq_enable_turbo;\n+rte_power_freq_change_t rte_power_freq_disable_turbo;\n \n int\n rte_power_set_env(enum power_management_env env)\n@@ -65,6 +68,9 @@ rte_power_set_env(enum power_management_env env)\n \t\trte_power_freq_down = rte_power_acpi_cpufreq_freq_down;\n \t\trte_power_freq_min = rte_power_acpi_cpufreq_freq_min;\n \t\trte_power_freq_max = rte_power_acpi_cpufreq_freq_max;\n+\t\trte_power_turbo_status = rte_power_acpi_turbo_status;\n+\t\trte_power_freq_enable_turbo = rte_power_acpi_enable_turbo;\n+\t\trte_power_freq_disable_turbo = rte_power_acpi_disable_turbo;\n \t} else if (env == PM_ENV_KVM_VM) {\n \t\trte_power_freqs = rte_power_kvm_vm_freqs;\n \t\trte_power_get_freq = rte_power_kvm_vm_get_freq;\n@@ -73,6 +79,9 @@ rte_power_set_env(enum power_management_env env)\n \t\trte_power_freq_down = rte_power_kvm_vm_freq_down;\n \t\trte_power_freq_min = rte_power_kvm_vm_freq_min;\n \t\trte_power_freq_max = rte_power_kvm_vm_freq_max;\n+\t\trte_power_turbo_status = rte_power_kvm_vm_turbo_status;\n+\t\trte_power_freq_enable_turbo = rte_power_kvm_vm_enable_turbo;\n+\t\trte_power_freq_disable_turbo = rte_power_kvm_vm_disable_turbo;\n \t} else {\n \t\tRTE_LOG(ERR, POWER, \"Invalid Power Management Environment(%d) set\\n\",\n \t\t\t\tenv);\ndiff --git a/lib/librte_power/rte_power.h b/lib/librte_power/rte_power.h\nindex 67e0ec0..b17b7a5 100644\n--- a/lib/librte_power/rte_power.h\n+++ b/lib/librte_power/rte_power.h\n@@ -236,6 +236,47 @@ extern rte_power_freq_change_t rte_power_freq_max;\n */\n extern rte_power_freq_change_t rte_power_freq_min;\n \n+/**\n+ * Query the Turbo Boost status of a specific lcore.\n+ * Review each environments specific documentation for usage..\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * - 1 Turbo Boost is enabled for this lcore.\n+ * - 0 Turbo Boost is disabled for this lcore.\n+ * - Negative on error.\n+ */\n+extern rte_power_freq_change_t rte_power_turbo_status;\n+\n+/**\n+ * Enable Turbo Boost for this lcore.\n+ * Review each environments specific documentation for usage..\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * - 0 on success.\n+ * - Negative on error.\n+ */\n+extern rte_power_freq_change_t rte_power_freq_enable_turbo;\n+\n+/**\n+ * Disable Turbo Boost for this lcore.\n+ * Review each environments specific documentation for usage..\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * - 0 on success.\n+ * - Negative on error.\n+ */\n+extern rte_power_freq_change_t rte_power_freq_disable_turbo;\n+\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_power/rte_power_acpi_cpufreq.c b/lib/librte_power/rte_power_acpi_cpufreq.c\nindex a56c9b5..01ac5ac 100644\n--- a/lib/librte_power/rte_power_acpi_cpufreq.c\n+++ b/lib/librte_power/rte_power_acpi_cpufreq.c\n@@ -87,6 +87,14 @@\n #define POWER_SYSFILE_SETSPEED \\\n \t\t\"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_setspeed\"\n \n+/*\n+ * MSR related\n+ */\n+#define PLATFORM_INFO 0x0CE\n+#define TURBO_RATIO_LIMIT 0x1AD\n+#define IA32_PERF_CTL 0x199\n+#define CORE_TURBO_DISABLE_BIT ((uint64_t)1<<32)\n+\n enum power_state {\n \tPOWER_IDLE = 0,\n \tPOWER_ONGOING,\n@@ -105,6 +113,8 @@ struct rte_power_info {\n \tchar governor_ori[32]; /**< Original governor name */\n \tuint32_t curr_idx; /**< Freq index in freqs array */\n \tvolatile uint32_t state; /**< Power in use state */\n+\tuint16_t turbo_available; /**< Turbo Boost available */\n+\tuint16_t turbo_enable; /**< Turbo Boost enable/disable */\n } __rte_cache_aligned;\n \n static struct rte_power_info lcore_power_info[RTE_MAX_LCORE];\n@@ -244,6 +254,18 @@ power_get_available_freqs(struct rte_power_info *pi)\n \t\t\t\tPOWER_CONVERT_TO_DECIMAL);\n \t}\n \n+\tif ((pi->freqs[0]-1000) == pi->freqs[1]) {\n+\t\tpi->turbo_available = 1;\n+\t\tpi->turbo_enable = 1;\n+\t\tPOWER_DEBUG_TRACE(\"Lcore %u Can do Turbo Boost\\n\",\n+\t\t\t\tpi->lcore_id);\n+\t} else {\n+\t\tpi->turbo_available = 0;\n+\t\tpi->turbo_enable = 0;\n+\t\tPOWER_DEBUG_TRACE(\"Turbo Boost not available on Lcore %u\\n\",\n+\t\t\t\tpi->lcore_id);\n+\t}\n+\n \tret = 0;\n \tPOWER_DEBUG_TRACE(\"%d frequencie(s) of lcore %u are available\\n\",\n \t\t\tcount, pi->lcore_id);\n@@ -525,7 +547,17 @@ rte_power_acpi_cpufreq_freq_max(unsigned lcore_id)\n \t}\n \n \t/* Frequencies in the array are from high to low. */\n-\treturn set_freq_internal(&lcore_power_info[lcore_id], 0);\n+\tif (lcore_power_info[lcore_id].turbo_available) {\n+\t\tif (lcore_power_info[lcore_id].turbo_enable)\n+\t\t\t/* Set to Turbo */\n+\t\t\treturn set_freq_internal(\n+\t\t\t\t\t&lcore_power_info[lcore_id], 0);\n+\t\telse\n+\t\t\t/* Set to max non-turbo */\n+\t\t\treturn set_freq_internal(\n+\t\t\t\t\t&lcore_power_info[lcore_id], 1);\n+\t} else\n+\t\treturn set_freq_internal(&lcore_power_info[lcore_id], 0);\n }\n \n int\n@@ -543,3 +575,80 @@ rte_power_acpi_cpufreq_freq_min(unsigned lcore_id)\n \t/* Frequencies in the array are from high to low. */\n \treturn set_freq_internal(pi, pi->nb_freqs - 1);\n }\n+\n+\n+int\n+rte_power_acpi_turbo_status(unsigned int lcore_id)\n+{\n+\tstruct rte_power_info *pi;\n+\n+\tif (lcore_id >= RTE_MAX_LCORE) {\n+\t\tRTE_LOG(ERR, POWER, \"Invalid lcore ID\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tpi = &lcore_power_info[lcore_id];\n+\n+\treturn pi->turbo_enable;\n+}\n+\n+\n+int\n+rte_power_acpi_enable_turbo(unsigned int lcore_id)\n+{\n+\tstruct rte_power_info *pi;\n+\n+\tif (lcore_id >= RTE_MAX_LCORE) {\n+\t\tRTE_LOG(ERR, POWER, \"Invalid lcore ID\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tpi = &lcore_power_info[lcore_id];\n+\n+\tif (pi->turbo_available)\n+\t\tpi->turbo_enable = 1;\n+\telse {\n+\t\tpi->turbo_enable = 0;\n+\t\tRTE_LOG(ERR, POWER,\n+\t\t\t\"Failed to enable turbo on lcore %u\\n\",\n+\t\t\tlcore_id);\n+\t\t\treturn -1;\n+\t}\n+\n+\t/* Max may have changed, so call to max function */\n+\tif (rte_power_acpi_cpufreq_freq_max(lcore_id) < 0) {\n+\t\tRTE_LOG(ERR, POWER,\n+\t\t\t\"Failed to set frequency of lcore %u to max\\n\",\n+\t\t\tlcore_id);\n+\t\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+rte_power_acpi_disable_turbo(unsigned int lcore_id)\n+{\n+\tstruct rte_power_info *pi;\n+\n+\tif (lcore_id >= RTE_MAX_LCORE) {\n+\t\tRTE_LOG(ERR, POWER, \"Invalid lcore ID\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tpi = &lcore_power_info[lcore_id];\n+\n+\t pi->turbo_enable = 0;\n+\n+\tif ((pi->turbo_available) && (pi->curr_idx <= 1)) {\n+\t\t/* Try to set freq to max by default coming out of turbo */\n+\t\tif (rte_power_acpi_cpufreq_freq_max(lcore_id) < 0) {\n+\t\t\tRTE_LOG(ERR, POWER,\n+\t\t\t\t\"Failed to set frequency of lcore %u to max\\n\",\n+\t\t\t\tlcore_id);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\ndiff --git a/lib/librte_power/rte_power_acpi_cpufreq.h b/lib/librte_power/rte_power_acpi_cpufreq.h\nindex 68578e9..eee0ca0 100644\n--- a/lib/librte_power/rte_power_acpi_cpufreq.h\n+++ b/lib/librte_power/rte_power_acpi_cpufreq.h\n@@ -185,6 +185,46 @@ int rte_power_acpi_cpufreq_freq_max(unsigned lcore_id);\n */\n int rte_power_acpi_cpufreq_freq_min(unsigned lcore_id);\n \n+/**\n+ * Get the turbo status of a specific lcore.\n+ * It should be protected outside of this function for threadsafe.\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * - 1 Turbo Boost is enabled on this lcore.\n+ * - 0 Turbo Boost is disabled on this lcore.\n+ * - Negative on error.\n+ */\n+int rte_power_acpi_turbo_status(unsigned int lcore_id);\n+\n+/**\n+ * Enable Turbo Boost on a specific lcore.\n+ * It should be protected outside of this function for threadsafe.\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * - 0 Turbo Boost is enabled successfully on this lcore.\n+ * - Negative on error.\n+ */\n+int rte_power_acpi_enable_turbo(unsigned int lcore_id);\n+\n+/**\n+ * Disable Turbo Boost on a specific lcore.\n+ * It should be protected outside of this function for threadsafe.\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * - 0 Turbo Boost disabled successfully on this lcore.\n+ * - Negative on error.\n+ */\n+int rte_power_acpi_disable_turbo(unsigned int lcore_id);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_power/rte_power_kvm_vm.c b/lib/librte_power/rte_power_kvm_vm.c\nindex a1badf3..9906062 100644\n--- a/lib/librte_power/rte_power_kvm_vm.c\n+++ b/lib/librte_power/rte_power_kvm_vm.c\n@@ -134,3 +134,22 @@ rte_power_kvm_vm_freq_min(unsigned lcore_id)\n {\n \treturn send_msg(lcore_id, CPU_POWER_SCALE_MIN);\n }\n+\n+int\n+rte_power_kvm_vm_turbo_status(__attribute__((unused)) unsigned int lcore_id)\n+{\n+\tRTE_LOG(ERR, POWER, \"rte_power_turbo_status is not implemented for Virtual Machine Power Management\\n\");\n+\treturn -ENOTSUP;\n+}\n+\n+int\n+rte_power_kvm_vm_enable_turbo(unsigned int lcore_id)\n+{\n+\treturn send_msg(lcore_id, CPU_POWER_ENABLE_TURBO);\n+}\n+\n+int\n+rte_power_kvm_vm_disable_turbo(unsigned int lcore_id)\n+{\n+\treturn send_msg(lcore_id, CPU_POWER_DISABLE_TURBO);\n+}\ndiff --git a/lib/librte_power/rte_power_kvm_vm.h b/lib/librte_power/rte_power_kvm_vm.h\nindex dcbc878..9af41d6 100644\n--- a/lib/librte_power/rte_power_kvm_vm.h\n+++ b/lib/librte_power/rte_power_kvm_vm.h\n@@ -172,8 +172,41 @@ int rte_power_kvm_vm_freq_max(unsigned lcore_id);\n */\n int rte_power_kvm_vm_freq_min(unsigned lcore_id);\n \n+/**\n+ * It should be protected outside of this function for threadsafe.\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * -ENOTSUP\n+ */\n+int rte_power_kvm_vm_turbo_status(unsigned int lcore_id);\n+\n+/**\n+ * It should be protected outside of this function for threadsafe.\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * - 1 on success.\n+ * - Negative on error.\n+ */\n+int rte_power_kvm_vm_enable_turbo(unsigned int lcore_id);\n+\n+/**\n+ * It should be protected outside of this function for threadsafe.\n+ *\n+ * @param lcore_id\n+ * lcore id.\n+ *\n+ * @return\n+ * - 1 on success.\n+ * - Negative on error.\n+ */\n+int rte_power_kvm_vm_disable_turbo(unsigned int lcore_id);\n #ifdef __cplusplus\n }\n #endif\n-\n #endif\n", "prefixes": [ "dpdk-dev", "v2", "1/4" ] }{ "id": 28651, "url": "