Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/131380/?format=api
http://patchwork.dpdk.org/api/patches/131380/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230913103600.1935292-6-thomas@monjalon.net/", "project": { "id": 1, "url": "http://patchwork.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": "<20230913103600.1935292-6-thomas@monjalon.net>", "list_archive_url": "https://inbox.dpdk.org/dev/20230913103600.1935292-6-thomas@monjalon.net", "date": "2023-09-13T10:34:24", "name": "[v2,05/11] eal: force prefix for internal threads", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "fcac7b50b83680499728d6de9fa7e256e2bf815b", "submitter": { "id": 685, "url": "http://patchwork.dpdk.org/api/people/685/?format=api", "name": "Thomas Monjalon", "email": "thomas@monjalon.net" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230913103600.1935292-6-thomas@monjalon.net/mbox/", "series": [ { "id": 29493, "url": "http://patchwork.dpdk.org/api/series/29493/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=29493", "date": "2023-09-13T10:34:19", "name": "rework thread management", "version": 2, "mbox": "http://patchwork.dpdk.org/series/29493/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/131380/comments/", "check": "warning", "checks": "http://patchwork.dpdk.org/api/patches/131380/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 91F9842588;\n\tWed, 13 Sep 2023 12:37:09 +0200 (CEST)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 28BCA4064A;\n\tWed, 13 Sep 2023 12:37:09 +0200 (CEST)", "from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com\n [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id 6461940698\n for <dev@dpdk.org>; Wed, 13 Sep 2023 12:37:07 +0200 (CEST)", "from compute6.internal (compute6.nyi.internal [10.202.2.47])\n by mailout.west.internal (Postfix) with ESMTP id 29DB03200034;\n Wed, 13 Sep 2023 06:37:06 -0400 (EDT)", "from mailfrontend1 ([10.202.2.162])\n by compute6.internal (MEProxy); Wed, 13 Sep 2023 06:37:06 -0400", "by mail.messagingengine.com (Postfix) with ESMTPA; Wed,\n 13 Sep 2023 06:37:04 -0400 (EDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=\n cc:cc:content-transfer-encoding:content-type:content-type:date\n :date:from:from:in-reply-to:in-reply-to:message-id:mime-version\n :references:reply-to:sender:subject:subject:to:to; s=fm2; t=\n 1694601425; x=1694687825; bh=lzZrcDoZqS8nGj9M1y0hbtQRNekkmoZFyrn\n dO3XUe7Y=; b=oM46EFr+jtSCI8Cu2KxZLEQyasftRuJ8LwzJgnGaweJ+D7hMud8\n bcr5xE5b9+mqiKjmeNAmHwYqKxsBUNBXtfNrjLn/Go/kQJDgTngJVrvLxI8Mtv8i\n ghZX/epY70Yqa4/O18PyGlM9GSPByNDkdH3KUg4xMa8p41/zLXNypnNr4dkSUYNy\n BCuqU5EzHSytXQA5xeR9X8FBLf8q/qru0jXDIULxJD04hkj+cfk8aw2PWehgZV0l\n 7jp1ufhZpvCo96ZGP66DDJPqKN/TnqQM5lXgelcXlV5uPzx85hoAa/U2JxzwbYOh\n K1RdSxWtf4gw2HbcLg3QBQNA0YPrEg3CXKQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n messagingengine.com; h=cc:cc:content-transfer-encoding\n :content-type:content-type:date:date:feedback-id:feedback-id\n :from:from:in-reply-to:in-reply-to:message-id:mime-version\n :references:reply-to:sender:subject:subject:to:to:x-me-proxy\n :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=\n 1694601425; x=1694687825; bh=lzZrcDoZqS8nGj9M1y0hbtQRNekkmoZFyrn\n dO3XUe7Y=; b=WO4rwwblbh6ky7opihaMTevBTsXVZrBcCbdVBtr8rPSIGHgyNR0\n rJXjE+U9DLvwNbK3+ZT8y+lVOVy2Ps6/tK+Cpjg2AybmFeiUjmqkY3H5q5jSRlSm\n nN1wX1AMifEvKFNdlXwwNjnkBUiKUz1RrLS2fBS3zbHPrbMGsxHjzMSsy/ozgDSe\n IcOxOdnGHcWnaWxo9zpHQWcgff0FggwR1bYOOiOIzW3crAuh9aSNwX3f4OSyaqvA\n cfcJWyFODX8gelTkmbJrAE+otJ5mOogYGjVSbM9LVWk1Ihel8wBVYAECCDJed3p4\n 1k5myfaOXq2+EBgvWgOCW6QMUwTSXp1O+3Q==" ], "X-ME-Sender": "<xms:0ZABZaR3piRb6o9Q1AJsXmaY6S_6cNtWOEfpSS1aGJ7rChTKl7jJ5w>\n <xme:0ZABZfxkhPUVMsm8y2-5tAdJvk2BwfsGjeNdMIw0Qkbz8KsbLakR1P3qXPnX7fhWL\n 3cMhJEp1uL6-A_0lA>", "X-ME-Received": "\n <xmr:0ZABZX2_yRMGtGDrMcf1h_hEfGG0gVureJrlVPaLCV8sGoN_2XlExn_qRSkTGpbC8nH6-Q>", "X-ME-Proxy-Cause": "\n gggruggvucftvghtrhhoucdtuddrgedviedrudeikedgfedtucetufdoteggodetrfdotf\n fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen\n uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne\n cujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhho\n mhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqne\n cuggftrfgrthhtvghrnheptdeiffffgeefteelhfekueetueduffejgfelvedtieejudek\n gfevheetheehgeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh\n hfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth", "X-ME-Proxy": "<xmx:0ZABZWBCEOGQWbS-KjTkKSz5140bh8cb2dZV-zDPDf1BXYVm_ohZBA>\n <xmx:0ZABZThHUhwd8T3YxoZjx2feuYyXmyBNWus01enxAF3FV9MFHRvK6Q>\n <xmx:0ZABZSo_i7Nt85qvE503dXzTvYkEVM4_jEWpC4lczpV2w1riEJxtHQ>\n <xmx:0ZABZQug6L052kwYzmfNC8OK62vik6LhxtM_jD2vc3U7N4Zc7xKPbA>", "Feedback-ID": "i47234305:Fastmail", "From": "Thomas Monjalon <thomas@monjalon.net>", "To": "dev@dpdk.org", "Cc": "Tyler Retzlaff <roretzla@linux.microsoft.com>,\n David Marchand <david.marchand@redhat.com>,\n Ferruh Yigit <ferruh.yigit@amd.com>,\n =?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>", "Subject": "[PATCH v2 05/11] eal: force prefix for internal threads", "Date": "Wed, 13 Sep 2023 12:34:24 +0200", "Message-ID": "<20230913103600.1935292-6-thomas@monjalon.net>", "X-Mailer": "git-send-email 2.42.0", "In-Reply-To": "<20230913103600.1935292-1-thomas@monjalon.net>", "References": "<20230906162226.1618088-1-thomas@monjalon.net>\n <20230913103600.1935292-1-thomas@monjalon.net>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "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" }, "content": "In order to make sure all threads created in DPDK drivers and libraries\nhave the same prefix in their name, some wrapper functions are added\nfor internal use when creating a control thread or setting a thread name:\n\t- rte_thread_create_internal_control\n\t- rte_thread_set_prefixed_name\n\nThe equivalent public functions are then forbidden for internal use:\n\t- rte_thread_create_control\n\t- rte_thread_set_name\n\nNote: the libraries and drivers conversion is done in next patches,\nwhile doing other thread-related changes.\n\nSigned-off-by: Thomas Monjalon <thomas@monjalon.net>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\nAcked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>\n\n---\nv2: simplify size doc + build time check of internal name size\n---\n devtools/checkpatches.sh | 8 ++++\n lib/eal/common/eal_common_thread.c | 29 +++++++++++++++\n lib/eal/include/rte_thread.h | 59 +++++++++++++++++++++++++++++-\n lib/eal/version.map | 2 +\n 4 files changed, 97 insertions(+), 1 deletion(-)", "diff": "diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh\nindex ec9d232393..e97811192a 100755\n--- a/devtools/checkpatches.sh\n+++ b/devtools/checkpatches.sh\n@@ -159,6 +159,14 @@ check_forbidden_additions() { # <patch>\n \t\t-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \\\n \t\t\"$1\" || res=1\n \n+\t# forbid non-internal thread in drivers and libs\n+\tawk -v FOLDERS='lib drivers' \\\n+\t\t-v EXPRESSIONS=\"rte_thread_(set_name|create_control)\\\\\\(\" \\\n+\t\t-v RET_ON_FAIL=1 \\\n+\t\t-v MESSAGE='Prefer rte_thread_(set_prefixed_name|create_internal_control) in lib & drivers' \\\n+\t\t-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \\\n+\t\t\"$1\" || res=1\n+\n \t# forbid inclusion of driver specific headers in apps and examples\n \tawk -v FOLDERS='app examples' \\\n \t\t-v EXPRESSIONS='include.*_driver\\\\.h include.*_pmd\\\\.h' \\\ndiff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c\nindex 07ac721da1..cd6e00fe8a 100644\n--- a/lib/eal/common/eal_common_thread.c\n+++ b/lib/eal/common/eal_common_thread.c\n@@ -392,6 +392,35 @@ rte_thread_create_control(rte_thread_t *thread, const char *name,\n \treturn ret;\n }\n \n+static void\n+add_internal_prefix(char *prefixed_name, const char *name, size_t size)\n+{\n+\tsize_t prefixlen;\n+\n+\tprefixlen = strlen(RTE_THREAD_INTERNAL_PREFIX);\n+\tstrlcpy(prefixed_name, RTE_THREAD_INTERNAL_PREFIX, size);\n+\tstrlcpy(prefixed_name + prefixlen, name, size - prefixlen);\n+}\n+\n+int\n+rte_thread_create_internal_control(rte_thread_t *id, const char *name,\n+\t\trte_thread_func func, void *arg)\n+{\n+\tchar prefixed_name[RTE_THREAD_NAME_SIZE];\n+\n+\tadd_internal_prefix(prefixed_name, name, sizeof(prefixed_name));\n+\treturn rte_thread_create_control(id, prefixed_name, func, arg);\n+}\n+\n+void\n+rte_thread_set_prefixed_name(rte_thread_t id, const char *name)\n+{\n+\tchar prefixed_name[RTE_THREAD_NAME_SIZE];\n+\n+\tadd_internal_prefix(prefixed_name, name, sizeof(prefixed_name));\n+\trte_thread_set_name(id, prefixed_name);\n+}\n+\n int\n rte_thread_register(void)\n {\ndiff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h\nindex dd1f62523f..afede97bed 100644\n--- a/lib/eal/include/rte_thread.h\n+++ b/lib/eal/include/rte_thread.h\n@@ -28,6 +28,13 @@ extern \"C\" {\n /* Old definition, aliased for compatibility. */\n #define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE\n \n+/** Thread name prefix automatically added to all internal threads. */\n+#define RTE_THREAD_INTERNAL_PREFIX \"dpdk-\"\n+/** Maximum internal thread name length (including '\\0'). */\n+#define RTE_THREAD_INTERNAL_NAME_SIZE 11\n+RTE_BUILD_BUG_ON(RTE_THREAD_INTERNAL_NAME_SIZE !=\n+\tRTE_THREAD_NAME_SIZE - sizeof(RTE_THREAD_INTERNAL_PREFIX) + 1)\n+\n /**\n * Thread id descriptor.\n */\n@@ -112,7 +119,7 @@ int rte_thread_create(rte_thread_t *thread_id,\n * @param thread_func\n * Function to be executed by the new thread.\n * @param arg\n- * Argument passed to start_routine.\n+ * Argument passed to thread_func.\n * @return\n * On success, returns 0; on error, it returns a negative value\n * corresponding to the error number.\n@@ -121,6 +128,35 @@ int\n rte_thread_create_control(rte_thread_t *thread, const char *name,\n \t\trte_thread_func thread_func, void *arg);\n \n+/**\n+ * Create an internal control thread.\n+ *\n+ * Creates a control thread with the given name prefixed.\n+ * If setting the name of the thread fails, the error is ignored and logged.\n+ *\n+ * The affinity of the new thread is based on the CPU affinity retrieved\n+ * at the time rte_eal_init() was called, the EAL threads are then excluded.\n+ *\n+ * @param id\n+ * Filled with the thread ID of the new created thread.\n+ * @param name\n+ * The name of the control thread.\n+ * See RTE_THREAD_INTERNAL_NAME_SIZE for maximum length.\n+ * The name of the driver or library should be first,\n+ * then followed by a hyphen and more details.\n+ * It will be prefixed with RTE_THREAD_INTERNAL_PREFIX by this function.\n+ * @param func\n+ * Function to be executed by the new thread.\n+ * @param arg\n+ * Argument passed to func.\n+ * @return\n+ * On success, returns 0; a negative value otherwise.\n+ */\n+__rte_internal\n+int\n+rte_thread_create_internal_control(rte_thread_t *id, const char *name,\n+\t\trte_thread_func func, void *arg);\n+\n /**\n * Waits for the thread identified by 'thread_id' to terminate\n *\n@@ -159,6 +195,7 @@ rte_thread_t rte_thread_self(void);\n \n /**\n * Set the name of the thread.\n+ *\n * This API is a noop if the underlying platform does not\n * support setting the thread name or the platform-specific\n * API used to set the thread name fails.\n@@ -173,6 +210,26 @@ rte_thread_t rte_thread_self(void);\n void\n rte_thread_set_name(rte_thread_t thread_id, const char *thread_name);\n \n+/**\n+ * Set the name of an internal thread with the common prefix.\n+ *\n+ * This API is a noop if the underlying platform does not support\n+ * setting the thread name, or if it fails.\n+ *\n+ * @param id\n+ * The ID of the thread to set name.\n+ *\n+ * @param name\n+ * The name to set after being prefixed.\n+ * See RTE_THREAD_INTERNAL_NAME_SIZE for maximum length.\n+ * The name of the driver or library should be first,\n+ * then followed by a hyphen and more details.\n+ * It will be prefixed with RTE_THREAD_INTERNAL_PREFIX by this function.\n+ */\n+__rte_internal\n+void\n+rte_thread_set_prefixed_name(rte_thread_t id, const char *name);\n+\n /**\n * Check if 2 thread ids are equal.\n *\ndiff --git a/lib/eal/version.map b/lib/eal/version.map\nindex 33b853d7be..6d32c19286 100644\n--- a/lib/eal/version.map\n+++ b/lib/eal/version.map\n@@ -462,4 +462,6 @@ INTERNAL {\n \trte_mem_map;\n \trte_mem_page_size;\n \trte_mem_unmap;\n+\trte_thread_create_internal_control;\n+\trte_thread_set_prefixed_name;\n };\n", "prefixes": [ "v2", "05/11" ] }{ "id": 131380, "url": "