Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2474/?format=api
https://patches.dpdk.org/api/patches/2474/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1421914598-2747-7-git-send-email-cunming.liang@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": "<1421914598-2747-7-git-send-email-cunming.liang@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1421914598-2747-7-git-send-email-cunming.liang@intel.com", "date": "2015-01-22T08:16:29", "name": "[dpdk-dev,v1,06/15] eal: add rte_gettid() to acquire unique system tid", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "0bca0a09d0efa0e22921151984685de150468623", "submitter": { "id": 46, "url": "https://patches.dpdk.org/api/people/46/?format=api", "name": "Cunming Liang", "email": "cunming.liang@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1421914598-2747-7-git-send-email-cunming.liang@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/2474/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/2474/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id B1A085AB7;\n\tThu, 22 Jan 2015 09:17:34 +0100 (CET)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 0A65D5934\n\tfor <dev@dpdk.org>; Thu, 22 Jan 2015 09:17:23 +0100 (CET)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga101.jf.intel.com with ESMTP; 22 Jan 2015 00:17:23 -0800", "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga002.fm.intel.com with ESMTP; 22 Jan 2015 00:17:21 -0800", "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id t0M8HJh8005160;\n\tThu, 22 Jan 2015 16:17:19 +0800", "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid t0M8HHa1002845; Thu, 22 Jan 2015 16:17:19 +0800", "(from cliang18@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t0M8HHp5002841; \n\tThu, 22 Jan 2015 16:17:17 +0800" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.09,447,1418112000\"; d=\"scan'208\";a=\"665686852\"", "From": "Cunming Liang <cunming.liang@intel.com>", "To": "dev@dpdk.org", "Date": "Thu, 22 Jan 2015 16:16:29 +0800", "Message-Id": "<1421914598-2747-7-git-send-email-cunming.liang@intel.com>", "X-Mailer": "git-send-email 1.7.4.1", "In-Reply-To": "<1421914598-2747-1-git-send-email-cunming.liang@intel.com>", "References": "<1417589628-43666-1-git-send-email-cunming.liang@intel.com>\n\t<1421914598-2747-1-git-send-email-cunming.liang@intel.com>", "Subject": "[dpdk-dev] [PATCH v1 06/15] eal: add rte_gettid() to acquire unique\n\tsystem tid", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <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": "The rte_gettid() wraps the linux and freebsd syscall gettid().\nIt provides a persistent unique thread id for the calling thread.\nIt will save the unique id in TLS on the first time.\n\nSigned-off-by: Cunming Liang <cunming.liang@intel.com>\n---\n lib/librte_eal/bsdapp/eal/eal_thread.c | 9 +++++++++\n lib/librte_eal/common/include/rte_eal.h | 27 +++++++++++++++++++++++++++\n lib/librte_eal/linuxapp/eal/eal_thread.c | 7 +++++++\n 3 files changed, 43 insertions(+)", "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c b/lib/librte_eal/bsdapp/eal/eal_thread.c\nindex 10220c7..d0c077b 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_thread.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c\n@@ -39,6 +39,7 @@\n #include <sched.h>\n #include <pthread_np.h>\n #include <sys/queue.h>\n+#include <sys/thr.h>\n \n #include <rte_debug.h>\n #include <rte_atomic.h>\n@@ -233,3 +234,11 @@ eal_thread_loop(__attribute__((unused)) void *arg)\n \t/* pthread_exit(NULL); */\n \t/* return NULL; */\n }\n+\n+/* require calling thread tid by gettid() */\n+int rte_sys_gettid(void)\n+{\n+\tlong lwpid;\n+\tthr_self(&lwpid);\n+\treturn (int)lwpid;\n+}\ndiff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h\nindex f4ecd2e..8ccdd65 100644\n--- a/lib/librte_eal/common/include/rte_eal.h\n+++ b/lib/librte_eal/common/include/rte_eal.h\n@@ -41,6 +41,9 @@\n */\n \n #include <stdint.h>\n+#include <sched.h>\n+\n+#include <rte_per_lcore.h>\n \n #ifdef __cplusplus\n extern \"C\" {\n@@ -262,6 +265,30 @@ rte_set_application_usage_hook( rte_usage_hook_t usage_func );\n */\n int rte_eal_has_hugepages(void);\n \n+/**\n+ * A wrap API for syscall gettid.\n+ *\n+ * @return\n+ * On success, returns the thread ID of calling process.\n+ * It always successful.\n+ */\n+int rte_sys_gettid(void);\n+\n+/**\n+ * Get system unique thread id.\n+ *\n+ * @return\n+ * On success, returns the thread ID of calling process.\n+ * It always successful.\n+ */\n+static inline int rte_gettid(void)\n+{\n+\tstatic RTE_DEFINE_PER_LCORE(int, _thread_id) = -1;\n+\tif (RTE_PER_LCORE(_thread_id) == -1)\n+\t\tRTE_PER_LCORE(_thread_id) = rte_sys_gettid();\n+\treturn RTE_PER_LCORE(_thread_id);\n+}\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_thread.c b/lib/librte_eal/linuxapp/eal/eal_thread.c\nindex 748a83a..ed20c93 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_thread.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_thread.c\n@@ -39,6 +39,7 @@\n #include <pthread.h>\n #include <sched.h>\n #include <sys/queue.h>\n+#include <sys/syscall.h>\n \n #include <rte_debug.h>\n #include <rte_atomic.h>\n@@ -233,3 +234,9 @@ eal_thread_loop(__attribute__((unused)) void *arg)\n \t/* pthread_exit(NULL); */\n \t/* return NULL; */\n }\n+\n+/* require calling thread tid by gettid() */\n+int rte_sys_gettid(void)\n+{\n+\treturn (int)syscall(SYS_gettid);\n+}\n", "prefixes": [ "dpdk-dev", "v1", "06/15" ] }{ "id": 2474, "url": "