Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/96484/?format=api
http://patches.dpdk.org/api/patches/96484/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1627684312-28630-6-git-send-email-navasile@linux.microsoft.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": "<1627684312-28630-6-git-send-email-navasile@linux.microsoft.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1627684312-28630-6-git-send-email-navasile@linux.microsoft.com", "date": "2021-07-30T22:31:47", "name": "[v11,05/10] eal: implement thread priority management functions", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "f21e68c33b1aa8510c5f64a27e28c75bdd7754bc", "submitter": { "id": 1668, "url": "http://patches.dpdk.org/api/people/1668/?format=api", "name": "Narcisa Ana Maria Vasile", "email": "navasile@linux.microsoft.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1627684312-28630-6-git-send-email-navasile@linux.microsoft.com/mbox/", "series": [ { "id": 18112, "url": "http://patches.dpdk.org/api/series/18112/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=18112", "date": "2021-07-30T22:31:42", "name": "eal: Add EAL API for threading", "version": 11, "mbox": "http://patches.dpdk.org/series/18112/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/96484/comments/", "check": "warning", "checks": "http://patches.dpdk.org/api/patches/96484/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 1992DA0C40;\n\tSat, 31 Jul 2021 00:32:23 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 016CE4111D;\n\tSat, 31 Jul 2021 00:32:05 +0200 (CEST)", "from linux.microsoft.com (linux.microsoft.com [13.77.154.182])\n by mails.dpdk.org (Postfix) with ESMTP id A2F63410F6\n for <dev@dpdk.org>; Sat, 31 Jul 2021 00:31:59 +0200 (CEST)", "by linux.microsoft.com (Postfix, from userid 1059)\n id 0D68B20B36F3; Fri, 30 Jul 2021 15:31:58 -0700 (PDT)" ], "DKIM-Filter": "OpenDKIM Filter v2.11.0 linux.microsoft.com 0D68B20B36F3", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;\n s=default; t=1627684319;\n bh=9tQgQy/VKalZOroXCVUUA088gtJhV5zBVjYsZjWA5Vc=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=SpouM6L1YnNIhO06YvU+Q/25UaJm15S7sJMgR6tiVxBjEO6xyEhQhZ5fLqq7xBa0H\n F2NibyzNDpV0Rx3zyg//dC72BlsTfh854RFP+X7OJS8iwkfrt3Sx1kQco9H89Wpzu5\n RurPsmBrzRs8t8hLkSw36wpfqHtSFrr+iirgXiNo=", "From": "Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>", "To": "dev@dpdk.org, thomas@monjalon.net, dmitry.kozliuk@gmail.com,\n khot@microsoft.com, navasile@microsoft.com, dmitrym@microsoft.com,\n roretzla@microsoft.com, talshn@nvidia.com, ocardona@microsoft.com", "Cc": "bruce.richardson@intel.com, david.marchand@redhat.com,\n pallavi.kadam@intel.com", "Date": "Fri, 30 Jul 2021 15:31:47 -0700", "Message-Id": "<1627684312-28630-6-git-send-email-navasile@linux.microsoft.com>", "X-Mailer": "git-send-email 1.8.3.1", "In-Reply-To": "<1627684312-28630-1-git-send-email-navasile@linux.microsoft.com>", "References": "<1624051606-26779-1-git-send-email-navasile@linux.microsoft.com>\n <1627684312-28630-1-git-send-email-navasile@linux.microsoft.com>", "Subject": "[dpdk-dev] [PATCH v11 05/10] eal: implement thread priority\n management functions", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "From: Narcisa Vasile <navasile@microsoft.com>\n\nAdd function for setting the priority for a thread.\nPriorities on multiple platforms are similarly determined by\na priority value and a priority class/policy.\n\nOn Linux, the following mapping is created:\nRTE_THREAD_PRIORITY_NORMAL corresponds to\n* policy SCHED_OTHER\n* priority value: (sched_get_priority_min(SCHED_OTHER) +\n sched_get_priority_max(SCHED_OTHER))/2;\nRTE_THREAD_PRIORITY_REALTIME_CRITICAL corresponds to\n* policy SCHED_RR\n* priority value: sched_get_priority_max(SCHED_RR);\n\nOn Windows, the following mapping is created:\nRTE_THREAD_PRIORITY_NORMAL corresponds to\n* class NORMAL_PRIORITY_CLASS\n* priority THREAD_PRIORITY_NORMAL\nRTE_THREAD_PRIORITY_REALTIME_CRITICAL corresponds to\n* class REALTIME_PRIORITY_CLASS\n* priority THREAD_PRIORITY_TIME_CRITICAL\n\nSigned-off-by: Narcisa Vasile <navasile@microsoft.com>\n---\n lib/eal/common/rte_thread.c | 49 ++++++++++++++++++++++++++\n lib/eal/include/rte_thread.h | 17 ++++++++++\n lib/eal/version.map | 1 +\n lib/eal/windows/rte_thread.c | 66 ++++++++++++++++++++++++++++++++++++\n 4 files changed, 133 insertions(+)", "diff": "diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c\nindex 73b7b3141c..fcebf7097c 100644\n--- a/lib/eal/common/rte_thread.c\n+++ b/lib/eal/common/rte_thread.c\n@@ -50,6 +50,55 @@ rte_thread_get_affinity_by_id(rte_thread_t thread_id,\n \t\tsizeof(*cpuset), cpuset);\n }\n \n+static int\n+thread_map_priority_to_os_value(enum rte_thread_priority eal_pri,\n+\t\tint *os_pri, int *pol)\n+{\n+\t/* Clear the output parameters */\n+\t*os_pri = sched_get_priority_min(SCHED_OTHER) - 1;\n+\t*pol = -1;\n+\n+\tswitch (eal_pri) {\n+\tcase RTE_THREAD_PRIORITY_NORMAL:\n+\t\t*pol = SCHED_OTHER;\n+\n+\t\t/*\n+\t\t * Choose the middle of the range to represent\n+\t\t * the priority 'normal'.\n+\t\t * On Linux, this should be 0, since both\n+\t\t * sched_get_priority_min/_max return 0 for SCHED_OTHER.\n+\t\t */\n+\t\t*os_pri = (sched_get_priority_min(SCHED_OTHER) +\n+\t\t\tsched_get_priority_max(SCHED_OTHER))/2;\n+\t\tbreak;\n+\tcase RTE_THREAD_PRIORITY_REALTIME_CRITICAL:\n+\t\t*pol = SCHED_RR;\n+\t\t*os_pri = sched_get_priority_max(SCHED_RR);\n+\t\tbreak;\n+\tdefault:\n+\t\tRTE_LOG(DEBUG, EAL, \"The requested priority value is invalid.\\n\");\n+\t\treturn EINVAL;\n+\t}\n+\treturn 0;\n+}\n+\n+int\n+rte_thread_set_priority(rte_thread_t thread_id,\n+\t\tenum rte_thread_priority priority)\n+{\n+\tint ret;\n+\tint policy;\n+\tstruct sched_param param;\n+\n+\tret = thread_map_priority_to_os_value(priority, ¶m.sched_priority,\n+\t\t&policy);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\treturn pthread_setschedparam((pthread_t)thread_id.opaque_id,\n+\t\tpolicy, ¶m);\n+}\n+\n int\n rte_thread_attr_init(rte_thread_attr_t *attr)\n {\ndiff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h\nindex ca4ade60e2..5514b2f57f 100644\n--- a/lib/eal/include/rte_thread.h\n+++ b/lib/eal/include/rte_thread.h\n@@ -215,6 +215,23 @@ void rte_thread_get_affinity(rte_cpuset_t *cpusetp);\n \n #endif /* RTE_HAS_CPUSET */\n \n+/**\n+ * Set the priority of a thread.\n+ *\n+ * @param thread_id\n+ * Id of the thread for which to set priority.\n+ *\n+ * @param priority\n+ * Priority value to be set.\n+ *\n+ * @return\n+ * On success, return 0.\n+ * On failure, return a positive errno-style error number.\n+ */\n+__rte_experimental\n+int rte_thread_set_priority(rte_thread_t thread_id,\n+\t\tenum rte_thread_priority priority);\n+\n /**\n * Create a TLS data key visible to all threads in the process.\n * the created key is later used to get/set a value.\ndiff --git a/lib/eal/version.map b/lib/eal/version.map\nindex 7ed4cd779e..df01bbbbe4 100644\n--- a/lib/eal/version.map\n+++ b/lib/eal/version.map\n@@ -435,6 +435,7 @@ EXPERIMENTAL {\n \trte_thread_attr_set_priority;\n \trte_thread_get_affinity_by_id;\n \trte_thread_set_affinity_by_id;\n+\trte_thread_set_priority;\n };\n \n INTERNAL {\ndiff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c\nindex 0127119f49..fb04718f58 100644\n--- a/lib/eal/windows/rte_thread.c\n+++ b/lib/eal/windows/rte_thread.c\n@@ -200,6 +200,72 @@ rte_thread_get_affinity_by_id(rte_thread_t thread_id,\n \treturn ret;\n }\n \n+static int\n+thread_map_priority_to_os_value(enum rte_thread_priority eal_pri,\n+\t\tint *os_pri, int *pri_class)\n+{\n+\t/* Clear the output parameters */\n+\t*os_pri = -1;\n+\t*pri_class = -1;\n+\n+\tswitch (eal_pri) {\n+\tcase RTE_THREAD_PRIORITY_NORMAL:\n+\t\t*pri_class = NORMAL_PRIORITY_CLASS;\n+\t\t*os_pri = THREAD_PRIORITY_NORMAL;\n+\t\tbreak;\n+\tcase RTE_THREAD_PRIORITY_REALTIME_CRITICAL:\n+\t\t*pri_class = REALTIME_PRIORITY_CLASS;\n+\t\t*os_pri = THREAD_PRIORITY_TIME_CRITICAL;\n+\t\tbreak;\n+\tdefault:\n+\t\tRTE_LOG(DEBUG, EAL, \"The requested priority value is invalid.\\n\");\n+\t\treturn EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+rte_thread_set_priority(rte_thread_t thread_id,\n+\t\t\tenum rte_thread_priority priority)\n+{\n+\tHANDLE thread_handle;\n+\tint priority_class;\n+\tint os_priority;\n+\tint ret = 0;\n+\n+\tthread_handle = OpenThread(THREAD_SET_INFORMATION |\n+\t\tTHREAD_QUERY_INFORMATION, FALSE,\n+\t\tthread_id.opaque_id);\n+\tif (thread_handle == NULL) {\n+\t\tret = thread_log_last_error(\"OpenThread()\");\n+\t\tgoto cleanup;\n+\t}\n+\n+\tret = thread_map_priority_to_os_value(priority, &os_priority,\n+\t\t&priority_class);\n+\tif (ret != 0)\n+\t\tgoto cleanup;\n+\n+\tif (!SetPriorityClass(GetCurrentProcess(), priority_class)) {\n+\t\tret = thread_log_last_error(\"SetPriorityClass()\");\n+\t\tgoto cleanup;\n+\t}\n+\n+\tif (!SetThreadPriority(thread_handle, os_priority)) {\n+\t\tret = thread_log_last_error(\"SetThreadPriority()\");\n+\t\tgoto cleanup;\n+\t}\n+\n+cleanup:\n+\tif (thread_handle != NULL) {\n+\t\tCloseHandle(thread_handle);\n+\t\tthread_handle = NULL;\n+\t}\n+\n+\treturn ret;\n+}\n+\n int\n rte_thread_attr_init(rte_thread_attr_t *attr)\n {\n", "prefixes": [ "v11", "05/10" ] }{ "id": 96484, "url": "