get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2475/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2475,
    "url": "https://patches.dpdk.org/api/patches/2475/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1421914598-2747-8-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-8-git-send-email-cunming.liang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1421914598-2747-8-git-send-email-cunming.liang@intel.com",
    "date": "2015-01-22T08:16:30",
    "name": "[dpdk-dev,v1,07/15] eal: apply affinity of EAL thread by assigned cpuset",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "955d562f9cc81dfa6da38506e138151dcf20a504",
    "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-8-git-send-email-cunming.liang@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2475/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2475/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 F2DA75ABC;\n\tThu, 22 Jan 2015 09:17:35 +0100 (CET)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id B844D5AB2\n\tfor <dev@dpdk.org>; Thu, 22 Jan 2015 09:17:27 +0100 (CET)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga101.fm.intel.com with ESMTP; 22 Jan 2015 00:17:25 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby orsmga001.jf.intel.com with ESMTP; 22 Jan 2015 00:17:24 -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 t0M8HM4x005238;\n\tThu, 22 Jan 2015 16:17:22 +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 t0M8HK8O002852; Thu, 22 Jan 2015 16:17:22 +0800",
            "(from cliang18@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t0M8HJkb002848; \n\tThu, 22 Jan 2015 16:17:19 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.09,447,1418112000\"; d=\"scan'208\";a=\"640850206\"",
        "From": "Cunming Liang <cunming.liang@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Thu, 22 Jan 2015 16:16:30 +0800",
        "Message-Id": "<1421914598-2747-8-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 07/15] eal: apply affinity of EAL thread by\n\tassigned cpuset",
        "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": "EAL threads use assigned cpuset to set core affinity during startup.\nIt keeps 1:1 mapping, if no '--lcores' option is used.\n\nSigned-off-by: Cunming Liang <cunming.liang@intel.com>\n---\n lib/librte_eal/bsdapp/eal/eal.c          | 13 ++++---\n lib/librte_eal/bsdapp/eal/eal_thread.c   | 63 +++++++++---------------------\n lib/librte_eal/linuxapp/eal/eal.c        |  7 +++-\n lib/librte_eal/linuxapp/eal/eal_thread.c | 67 +++++++++++---------------------\n 4 files changed, 54 insertions(+), 96 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c\nindex 69f3c03..98c5a83 100644\n--- a/lib/librte_eal/bsdapp/eal/eal.c\n+++ b/lib/librte_eal/bsdapp/eal/eal.c\n@@ -432,6 +432,7 @@ rte_eal_init(int argc, char **argv)\n \tint i, fctret, ret;\n \tpthread_t thread_id;\n \tstatic rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);\n+\tchar cpuset[CPU_STR_LEN];\n \n \tif (!rte_atomic32_test_and_set(&run_once))\n \t\treturn -1;\n@@ -502,13 +503,17 @@ rte_eal_init(int argc, char **argv)\n \tif (rte_eal_pci_init() < 0)\n \t\trte_panic(\"Cannot init PCI\\n\");\n \n-\tRTE_LOG(DEBUG, EAL, \"Master core %u is ready (tid=%p)\\n\",\n-\t\trte_config.master_lcore, thread_id);\n-\n \teal_check_mem_on_local_socket();\n \n \trte_eal_mcfg_complete();\n \n+\teal_thread_init_master(rte_config.master_lcore);\n+\n+\teal_thread_dump_affinity(cpuset, CPU_STR_LEN);\n+\n+\tRTE_LOG(DEBUG, EAL, \"Master lcore %u is ready (tid=%p;cpuset=[%s])\\n\",\n+\t\trte_config.master_lcore, thread_id, cpuset);\n+\n \tif (rte_eal_dev_init() < 0)\n \t\trte_panic(\"Cannot init pmd devices\\n\");\n \n@@ -532,8 +537,6 @@ rte_eal_init(int argc, char **argv)\n \t\t\trte_panic(\"Cannot create thread\\n\");\n \t}\n \n-\teal_thread_init_master(rte_config.master_lcore);\n-\n \t/*\n \t * Launch a dummy function on all slave lcores, so that master lcore\n \t * knows they are all ready when this function returns.\ndiff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c b/lib/librte_eal/bsdapp/eal/eal_thread.c\nindex d0c077b..5b16302 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_thread.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c\n@@ -103,55 +103,27 @@ eal_thread_set_affinity(void)\n {\n \tint s;\n \tpthread_t thread;\n-\n-/*\n- * According to the section VERSIONS of the CPU_ALLOC man page:\n- *\n- * The CPU_ZERO(), CPU_SET(), CPU_CLR(), and CPU_ISSET() macros were added\n- * in glibc 2.3.3.\n- *\n- * CPU_COUNT() first appeared in glibc 2.6.\n- *\n- * CPU_AND(),     CPU_OR(),     CPU_XOR(),    CPU_EQUAL(),    CPU_ALLOC(),\n- * CPU_ALLOC_SIZE(), CPU_FREE(), CPU_ZERO_S(),  CPU_SET_S(),  CPU_CLR_S(),\n- * CPU_ISSET_S(),  CPU_AND_S(), CPU_OR_S(), CPU_XOR_S(), and CPU_EQUAL_S()\n- * first appeared in glibc 2.7.\n- */\n-#if defined(CPU_ALLOC)\n-\tsize_t size;\n-\tcpu_set_t *cpusetp;\n-\n-\tcpusetp = CPU_ALLOC(RTE_MAX_LCORE);\n-\tif (cpusetp == NULL) {\n-\t\tRTE_LOG(ERR, EAL, \"CPU_ALLOC failed\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\tsize = CPU_ALLOC_SIZE(RTE_MAX_LCORE);\n-\tCPU_ZERO_S(size, cpusetp);\n-\tCPU_SET_S(rte_lcore_id(), size, cpusetp);\n+\tunsigned lcore_id = rte_lcore_id();\n \n \tthread = pthread_self();\n-\ts = pthread_setaffinity_np(thread, size, cpusetp);\n+\ts = pthread_setaffinity_np(thread, sizeof(cpuset_t),\n+\t\t\t\t   &lcore_config[lcore_id].cpuset);\n \tif (s != 0) {\n \t\tRTE_LOG(ERR, EAL, \"pthread_setaffinity_np failed\\n\");\n-\t\tCPU_FREE(cpusetp);\n \t\treturn -1;\n \t}\n \n-\tCPU_FREE(cpusetp);\n-#else /* CPU_ALLOC */\n-\tcpuset_t cpuset;\n-\tCPU_ZERO( &cpuset );\n-\tCPU_SET( rte_lcore_id(), &cpuset );\n+\t/* acquire system unique id  */\n+\trte_gettid();\n+\n+\t/* store socket_id in TLS for quick access */\n+\tRTE_PER_LCORE(_socket_id) =\n+\t\teal_cpuset_socket_id(&lcore_config[lcore_id].cpuset);\n+\n+\tCPU_COPY(&lcore_config[lcore_id].cpuset, &RTE_PER_LCORE(_cpuset));\n+\n+\tlcore_config[lcore_id].socket_id = RTE_PER_LCORE(_socket_id);\n \n-\tthread = pthread_self();\n-\ts = pthread_setaffinity_np(thread, sizeof( cpuset ), &cpuset);\n-\tif (s != 0) {\n-\t\tRTE_LOG(ERR, EAL, \"pthread_setaffinity_np failed\\n\");\n-\t\treturn -1;\n-\t}\n-#endif\n \treturn 0;\n }\n \n@@ -174,6 +146,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)\n \tunsigned lcore_id;\n \tpthread_t thread_id;\n \tint m2s, s2m;\n+\tchar cpuset[CPU_STR_LEN];\n \n \tthread_id = pthread_self();\n \n@@ -185,9 +158,6 @@ eal_thread_loop(__attribute__((unused)) void *arg)\n \tif (lcore_id == RTE_MAX_LCORE)\n \t\trte_panic(\"cannot retrieve lcore id\\n\");\n \n-\tRTE_LOG(DEBUG, EAL, \"Core %u is ready (tid=%p)\\n\",\n-\t\tlcore_id, thread_id);\n-\n \tm2s = lcore_config[lcore_id].pipe_master2slave[0];\n \ts2m = lcore_config[lcore_id].pipe_slave2master[1];\n \n@@ -198,6 +168,11 @@ eal_thread_loop(__attribute__((unused)) void *arg)\n \tif (eal_thread_set_affinity() < 0)\n \t\trte_panic(\"cannot set affinity\\n\");\n \n+\teal_thread_dump_affinity(cpuset, CPU_STR_LEN);\n+\n+\tRTE_LOG(DEBUG, EAL, \"lcore %u is ready (tid=%p;cpuset=[%s])\\n\",\n+\t\tlcore_id, thread_id, cpuset);\n+\n \t/* read on our pipe to get commands */\n \twhile (1) {\n \t\tvoid *fct_arg;\ndiff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c\nindex f99e158..c95adec 100644\n--- a/lib/librte_eal/linuxapp/eal/eal.c\n+++ b/lib/librte_eal/linuxapp/eal/eal.c\n@@ -702,6 +702,7 @@ rte_eal_init(int argc, char **argv)\n \tstatic rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);\n \tstruct shared_driver *solib = NULL;\n \tconst char *logid;\n+\tchar cpuset[CPU_STR_LEN];\n \n \tif (!rte_atomic32_test_and_set(&run_once))\n \t\treturn -1;\n@@ -802,8 +803,10 @@ rte_eal_init(int argc, char **argv)\n \n \teal_thread_init_master(rte_config.master_lcore);\n \n-\tRTE_LOG(DEBUG, EAL, \"Master core %u is ready (tid=%x)\\n\",\n-\t\trte_config.master_lcore, (int)thread_id);\n+\teal_thread_dump_affinity(cpuset, CPU_STR_LEN);\n+\n+\tRTE_LOG(DEBUG, EAL, \"Master lcore %u is ready (tid=%x;cpuset=[%s])\\n\",\n+\t\trte_config.master_lcore, (int)thread_id, cpuset);\n \n \tif (rte_eal_dev_init() < 0)\n \t\trte_panic(\"Cannot init pmd devices\\n\");\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_thread.c b/lib/librte_eal/linuxapp/eal/eal_thread.c\nindex ed20c93..6eb1525 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_thread.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_thread.c\n@@ -52,6 +52,7 @@\n #include <rte_eal.h>\n #include <rte_per_lcore.h>\n #include <rte_lcore.h>\n+#include <rte_memcpy.h>\n \n #include \"eal_private.h\"\n #include \"eal_thread.h\"\n@@ -97,61 +98,34 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)\n \treturn 0;\n }\n \n-/* set affinity for current thread */\n+/* set affinity for current EAL thread */\n static int\n eal_thread_set_affinity(void)\n {\n \tint s;\n \tpthread_t thread;\n-\n-/*\n- * According to the section VERSIONS of the CPU_ALLOC man page:\n- *\n- * The CPU_ZERO(), CPU_SET(), CPU_CLR(), and CPU_ISSET() macros were added\n- * in glibc 2.3.3.\n- *\n- * CPU_COUNT() first appeared in glibc 2.6.\n- *\n- * CPU_AND(),     CPU_OR(),     CPU_XOR(),    CPU_EQUAL(),    CPU_ALLOC(),\n- * CPU_ALLOC_SIZE(), CPU_FREE(), CPU_ZERO_S(),  CPU_SET_S(),  CPU_CLR_S(),\n- * CPU_ISSET_S(),  CPU_AND_S(), CPU_OR_S(), CPU_XOR_S(), and CPU_EQUAL_S()\n- * first appeared in glibc 2.7.\n- */\n-#if defined(CPU_ALLOC)\n-\tsize_t size;\n-\tcpu_set_t *cpusetp;\n-\n-\tcpusetp = CPU_ALLOC(RTE_MAX_LCORE);\n-\tif (cpusetp == NULL) {\n-\t\tRTE_LOG(ERR, EAL, \"CPU_ALLOC failed\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\tsize = CPU_ALLOC_SIZE(RTE_MAX_LCORE);\n-\tCPU_ZERO_S(size, cpusetp);\n-\tCPU_SET_S(rte_lcore_id(), size, cpusetp);\n+\tunsigned lcore_id = rte_lcore_id();\n \n \tthread = pthread_self();\n-\ts = pthread_setaffinity_np(thread, size, cpusetp);\n+\ts = pthread_setaffinity_np(thread, sizeof(cpu_set_t),\n+\t\t\t\t   &lcore_config[lcore_id].cpuset);\n \tif (s != 0) {\n \t\tRTE_LOG(ERR, EAL, \"pthread_setaffinity_np failed\\n\");\n-\t\tCPU_FREE(cpusetp);\n \t\treturn -1;\n \t}\n \n-\tCPU_FREE(cpusetp);\n-#else /* CPU_ALLOC */\n-\tcpu_set_t cpuset;\n-\tCPU_ZERO( &cpuset );\n-\tCPU_SET( rte_lcore_id(), &cpuset );\n+\t/* acquire system unique id  */\n+\trte_gettid();\n+\n+\t/* store socket_id in TLS for quick access */\n+\tRTE_PER_LCORE(_socket_id) =\n+\t\teal_cpuset_socket_id(&lcore_config[lcore_id].cpuset);\n+\n+\trte_memcpy(&RTE_PER_LCORE(_cpuset),\n+\t\t   &lcore_config[lcore_id].cpuset, sizeof(rte_cpuset_t));\n+\n+\tlcore_config[lcore_id].socket_id = RTE_PER_LCORE(_socket_id);\n \n-\tthread = pthread_self();\n-\ts = pthread_setaffinity_np(thread, sizeof( cpuset ), &cpuset);\n-\tif (s != 0) {\n-\t\tRTE_LOG(ERR, EAL, \"pthread_setaffinity_np failed\\n\");\n-\t\treturn -1;\n-\t}\n-#endif\n \treturn 0;\n }\n \n@@ -174,6 +148,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)\n \tunsigned lcore_id;\n \tpthread_t thread_id;\n \tint m2s, s2m;\n+\tchar cpuset[CPU_STR_LEN];\n \n \tthread_id = pthread_self();\n \n@@ -185,9 +160,6 @@ eal_thread_loop(__attribute__((unused)) void *arg)\n \tif (lcore_id == RTE_MAX_LCORE)\n \t\trte_panic(\"cannot retrieve lcore id\\n\");\n \n-\tRTE_LOG(DEBUG, EAL, \"Core %u is ready (tid=%x)\\n\",\n-\t\tlcore_id, (int)thread_id);\n-\n \tm2s = lcore_config[lcore_id].pipe_master2slave[0];\n \ts2m = lcore_config[lcore_id].pipe_slave2master[1];\n \n@@ -198,6 +170,11 @@ eal_thread_loop(__attribute__((unused)) void *arg)\n \tif (eal_thread_set_affinity() < 0)\n \t\trte_panic(\"cannot set affinity\\n\");\n \n+\teal_thread_dump_affinity(cpuset, CPU_STR_LEN);\n+\n+\tRTE_LOG(DEBUG, EAL, \"lcore %u is ready (tid=%x;cpuset=[%s])\\n\",\n+\t\tlcore_id, (int)thread_id, cpuset);\n+\n \t/* read on our pipe to get commands */\n \twhile (1) {\n \t\tvoid *fct_arg;\n",
    "prefixes": [
        "dpdk-dev",
        "v1",
        "07/15"
    ]
}