Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/51194/?format=api
https://patches.dpdk.org/api/patches/51194/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20190313194844.11820-2-marcinx.hajkowski@intel.com/", "project": { "id": 1, "url": "https://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": "<20190313194844.11820-2-marcinx.hajkowski@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20190313194844.11820-2-marcinx.hajkowski@intel.com", "date": "2019-03-13T19:48:41", "name": "[1/4] power: fix non thread-safe power env modification", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "b817c14d0d59f83372bf22443d1243b99cb222a2", "submitter": { "id": 1246, "url": "https://patches.dpdk.org/api/people/1246/?format=api", "name": "Marcin Hajkowski", "email": "marcinx.hajkowski@intel.com" }, "delegate": { "id": 1, "url": "https://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20190313194844.11820-2-marcinx.hajkowski@intel.com/mbox/", "series": [ { "id": 3746, "url": "https://patches.dpdk.org/api/series/3746/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=3746", "date": "2019-03-13T19:48:40", "name": "rte_power APIs enhancement", "version": 1, "mbox": "https://patches.dpdk.org/series/3746/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/51194/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/51194/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 B01CF4F91;\n\tThu, 14 Mar 2019 15:56:54 +0100 (CET)", "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id 892C337B0;\n\tWed, 13 Mar 2019 20:50:17 +0100 (CET)", "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t13 Mar 2019 12:50:15 -0700", "from mhajkowx-mobl.ger.corp.intel.com ([10.104.116.179])\n\tby orsmga001.jf.intel.com with ESMTP; 13 Mar 2019 12:50:03 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.58,475,1544515200\"; d=\"scan'208\";a=\"213891631\"", "From": "Hajkowski <marcinx.hajkowski@intel.com>", "To": "david.hunt@intel.com", "Cc": "dev@dpdk.org, Marcin Hajkowski <marcinx.hajkowski@intel.com>,\n\tstable@dpdk.org", "Date": "Wed, 13 Mar 2019 20:48:41 +0100", "Message-Id": "<20190313194844.11820-2-marcinx.hajkowski@intel.com>", "X-Mailer": "git-send-email 2.20.1.windows.1", "In-Reply-To": "<20190313194844.11820-1-marcinx.hajkowski@intel.com>", "References": "<20190313194844.11820-1-marcinx.hajkowski@intel.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "X-Mailman-Approved-At": "Thu, 14 Mar 2019 15:56:49 +0100", "Subject": "[dpdk-dev] [PATCH 1/4] power: fix non thread-safe power env\n\tmodification", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "From: Marcin Hajkowski <marcinx.hajkowski@intel.com>\n\nDue to lack of thread safety in exisiting solution\nuse spinlock mechanism for atomic\nmodification of power environment related data.\n\nFixes: 445c6528b5 (\"power: common interface for guest and host\")\nCc: stable@dpdk.org\n\nSigned-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>\n---\n doc/guides/rel_notes/release_19_05.rst | 2 ++\n lib/librte_power/rte_power.c | 30 ++++++++++++++++++--------\n lib/librte_power/rte_power.h | 2 +-\n 3 files changed, 24 insertions(+), 10 deletions(-)", "diff": "diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst\nindex 61a2c7383..65371e4c8 100644\n--- a/doc/guides/rel_notes/release_19_05.rst\n+++ b/doc/guides/rel_notes/release_19_05.rst\n@@ -120,6 +120,8 @@ API Changes\n Also, make sure to start the actual text at the margin.\n =========================================================\n \n+ * power: ``rte_power_set_env`` and ``rte_power_unset_env`` functions\n+ have been modified to be thread safe.\n \n ABI Changes\n -----------\ndiff --git a/lib/librte_power/rte_power.c b/lib/librte_power/rte_power.c\nindex a05fbef94..540d69be7 100644\n--- a/lib/librte_power/rte_power.c\n+++ b/lib/librte_power/rte_power.c\n@@ -2,7 +2,7 @@\n * Copyright(c) 2010-2014 Intel Corporation\n */\n \n-#include <rte_atomic.h>\n+#include <rte_spinlock.h>\n \n #include \"rte_power.h\"\n #include \"power_acpi_cpufreq.h\"\n@@ -12,7 +12,7 @@\n \n enum power_management_env global_default_env = PM_ENV_NOT_SET;\n \n-volatile uint32_t global_env_cfg_status = 0;\n+static rte_spinlock_t global_env_cfg_lock = RTE_SPINLOCK_INITIALIZER;\n \n /* function pointers */\n rte_power_freqs_t rte_power_freqs = NULL;\n@@ -30,9 +30,15 @@ rte_power_get_capabilities_t rte_power_get_capabilities;\n int\n rte_power_set_env(enum power_management_env env)\n {\n-\tif (rte_atomic32_cmpset(&global_env_cfg_status, 0, 1) == 0) {\n+\trte_spinlock_lock(&global_env_cfg_lock);\n+\n+\tif (global_default_env != PM_ENV_NOT_SET) {\n+\t\trte_spinlock_unlock(&global_env_cfg_lock);\n \t\treturn 0;\n \t}\n+\n+\tint ret = 0;\n+\n \tif (env == PM_ENV_ACPI_CPUFREQ) {\n \t\trte_power_freqs = power_acpi_cpufreq_freqs;\n \t\trte_power_get_freq = power_acpi_cpufreq_get_freq;\n@@ -73,18 +79,24 @@ rte_power_set_env(enum power_management_env env)\n \t} else {\n \t\tRTE_LOG(ERR, POWER, \"Invalid Power Management Environment(%d) set\\n\",\n \t\t\t\tenv);\n-\t\trte_power_unset_env();\n-\t\treturn -1;\n+\t\tret = -1;\n \t}\n-\tglobal_default_env = env;\n-\treturn 0;\n+\n+\tif (ret == 0)\n+\t\tglobal_default_env = env;\n+\telse\n+\t\tglobal_default_env = PM_ENV_NOT_SET;\n+\n+\trte_spinlock_unlock(&global_env_cfg_lock);\n+\treturn ret;\n }\n \n void\n rte_power_unset_env(void)\n {\n-\tif (rte_atomic32_cmpset(&global_env_cfg_status, 1, 0) != 0)\n-\t\tglobal_default_env = PM_ENV_NOT_SET;\n+\trte_spinlock_lock(&global_env_cfg_lock);\n+\tglobal_default_env = PM_ENV_NOT_SET;\n+\trte_spinlock_unlock(&global_env_cfg_lock);\n }\n \n enum power_management_env\ndiff --git a/lib/librte_power/rte_power.h b/lib/librte_power/rte_power.h\nindex c5e8f6b5b..54b76b4ee 100644\n--- a/lib/librte_power/rte_power.h\n+++ b/lib/librte_power/rte_power.h\n@@ -26,7 +26,7 @@ enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM,\n /**\n * Set the default power management implementation. If this is not called prior\n * to rte_power_init(), then auto-detect of the environment will take place.\n- * It is not thread safe.\n+ * It is thread safe.\n *\n * @param env\n * env. The environment in which to initialise Power Management for.\n", "prefixes": [ "1/4" ] }{ "id": 51194, "url": "