get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 71528,
    "url": "http://patches.dpdk.org/api/patches/71528/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200615004354.14380-10-dmitry.kozliuk@gmail.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": "<20200615004354.14380-10-dmitry.kozliuk@gmail.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200615004354.14380-10-dmitry.kozliuk@gmail.com",
    "date": "2020-06-15T00:43:51",
    "name": "[v9,09/12] eal/windows: improve CPU and NUMA node detection",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "8d648871929e889a480738baae65d1140fc7b0f6",
    "submitter": {
        "id": 1581,
        "url": "http://patches.dpdk.org/api/people/1581/?format=api",
        "name": "Dmitry Kozlyuk",
        "email": "dmitry.kozliuk@gmail.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200615004354.14380-10-dmitry.kozliuk@gmail.com/mbox/",
    "series": [
        {
            "id": 10455,
            "url": "http://patches.dpdk.org/api/series/10455/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=10455",
            "date": "2020-06-15T00:43:42",
            "name": "Windows basic memory management",
            "version": 9,
            "mbox": "http://patches.dpdk.org/series/10455/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/71528/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/71528/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 98396A0093;\n\tMon, 15 Jun 2020 02:45:41 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 740A91BE99;\n\tMon, 15 Jun 2020 02:44:35 +0200 (CEST)",
            "from mail-lj1-f193.google.com (mail-lj1-f193.google.com\n [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 9628B4C7A\n for <dev@dpdk.org>; Mon, 15 Jun 2020 02:44:12 +0200 (CEST)",
            "by mail-lj1-f193.google.com with SMTP id x18so17054154lji.1\n for <dev@dpdk.org>; Sun, 14 Jun 2020 17:44:12 -0700 (PDT)",
            "from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru.\n [37.110.65.23])\n by smtp.gmail.com with ESMTPSA id f19sm4176342lfk.24.2020.06.14.17.44.11\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sun, 14 Jun 2020 17:44:11 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=SJMl5RYeSpJR0c08k8R+RC4d3cmcUx9XLA3/R+S799A=;\n b=XqsbRDBufRy7wXCgTPhdKzffhWgVmrCSYVzztlBpfAX5xvea9nDn6cqBfwbiALl6ql\n 6nN9h6EaKXFISs+4atDLcGMbcqCM4Xk2fQTIXh8pifFosDgbMNykIr4R7Th6Jnu+ZqQq\n FCyZ/HPeNkrHUjTbS9gkFUkGd4PnXjt20FwGEp7F6rM7Jr1G+CAk2/O3g4cCurdEyyhZ\n hi4QxULyA6fv+3opJRbEUTIUWsfB2G9ZuoY9v9BKc7TDYYNw9bnGR8/qDWxk7u7bD8Nk\n xUm47PaxR4TWFudn076B4u7eNnUp73+IYfUqIpE6fJMPiz6KbK//unP8aA1Wbom9rVXM\n shZg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=SJMl5RYeSpJR0c08k8R+RC4d3cmcUx9XLA3/R+S799A=;\n b=odcg/plRb82dpJxO7TVad0vXxjFvq0WxWXLU3outCstGaP6T9+tzI1J6Xga0z/6knW\n Vv3brI8AX55ijh0OiuWPvyZa2bjR5vU2bly6A9XHMEjYWQPCGNErySr4Yur8FcSQuLFn\n kmrffcmOm0XqqRt87Yn5JvR0FPPi1+2ax86kdMXpBkXKRch9BvmWYxD6PpFojjz1uCTa\n v4VVvjNCzosHOd1VTWQnd/9SNOzc5YFCwHjoFE7C3kRNaCxDap3Rut95elYQlKE1Ayol\n RsMRkr6ZYj5/cQlJ2Q+c9OnvUx1ZWS8uoqJkY8yj6Yb8JsrWcHlidX1rZrLCk3i5FMW+\n SClw==",
        "X-Gm-Message-State": "AOAM5319RSY5DRZcWXDtLPnGTrRLRu5CNPvwbhzipjV1bbg1EA/1CJj/\n 4Ccwq0D8zRFPyq/pJFA2dkf5okCUPDn1JQ==",
        "X-Google-Smtp-Source": "\n ABdhPJz/kzuLUO3vsu7SIl/ykfnQeKRwjBW1s7w1S900F9tiQ3SpNPcEullq0GbAl91xr+IR+7Ztkg==",
        "X-Received": "by 2002:a2e:3a04:: with SMTP id h4mr7144796lja.103.1592181852018;\n Sun, 14 Jun 2020 17:44:12 -0700 (PDT)",
        "From": "Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>",
        "To": "dev@dpdk.org",
        "Cc": "Dmitry Malloy <dmitrym@microsoft.com>,\n Narcisa Ana Maria Vasile <Narcisa.Vasile@microsoft.com>,\n Fady Bader <fady@mellanox.com>, Tal Shnaiderman <talshn@mellanox.com>,\n Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,\n Harini Ramakrishnan <harini.ramakrishnan@microsoft.com>,\n Omar Cardona <ocardona@microsoft.com>,\n Pallavi Kadam <pallavi.kadam@intel.com>,\n Ranjit Menon <ranjit.menon@intel.com>",
        "Date": "Mon, 15 Jun 2020 03:43:51 +0300",
        "Message-Id": "<20200615004354.14380-10-dmitry.kozliuk@gmail.com>",
        "X-Mailer": "git-send-email 2.25.4",
        "In-Reply-To": "<20200615004354.14380-1-dmitry.kozliuk@gmail.com>",
        "References": "<20200610142730.31376-1-dmitry.kozliuk@gmail.com>\n <20200615004354.14380-1-dmitry.kozliuk@gmail.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v9 09/12] eal/windows: improve CPU and NUMA node\n\tdetection",
        "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 <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": "1. Map CPU cores to their respective NUMA nodes as reported by system.\n2. Support systems with more than 64 cores (multiple processor groups).\n3. Fix magic constants, styling issues, and compiler warnings.\n4. Add EAL private function to map DPDK socket ID to NUMA node number.\n\nSigned-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>\n---\n lib/librte_eal/windows/eal.c         |   7 +-\n lib/librte_eal/windows/eal_lcore.c   | 205 +++++++++++++++++----------\n lib/librte_eal/windows/eal_windows.h |  15 +-\n 3 files changed, 152 insertions(+), 75 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c\nindex e7461f731..dfc10b494 100644\n--- a/lib/librte_eal/windows/eal.c\n+++ b/lib/librte_eal/windows/eal.c\n@@ -263,8 +263,11 @@ rte_eal_init(int argc, char **argv)\n \n \teal_log_level_parse(argc, argv);\n \n-\t/* create a map of all processors in the system */\n-\teal_create_cpu_map();\n+\tif (eal_create_cpu_map() < 0) {\n+\t\trte_eal_init_alert(\"Cannot discover CPU and NUMA.\");\n+\t\t/* rte_errno is set */\n+\t\treturn -1;\n+\t}\n \n \tif (rte_eal_cpu_init() < 0) {\n \t\trte_eal_init_alert(\"Cannot detect lcores.\");\ndiff --git a/lib/librte_eal/windows/eal_lcore.c b/lib/librte_eal/windows/eal_lcore.c\nindex 82ee45413..d5ff721e0 100644\n--- a/lib/librte_eal/windows/eal_lcore.c\n+++ b/lib/librte_eal/windows/eal_lcore.c\n@@ -3,103 +3,164 @@\n  */\n \n #include <pthread.h>\n+#include <stdbool.h>\n #include <stdint.h>\n \n #include <rte_common.h>\n+#include <rte_debug.h>\n+#include <rte_lcore.h>\n+#include <rte_os.h>\n \n #include \"eal_private.h\"\n #include \"eal_thread.h\"\n #include \"eal_windows.h\"\n \n-/* global data structure that contains the CPU map */\n-static struct _wcpu_map {\n-\tunsigned int total_procs;\n-\tunsigned int proc_sockets;\n-\tunsigned int proc_cores;\n-\tunsigned int reserved;\n-\tstruct _win_lcore_map {\n-\t\tuint8_t socket_id;\n-\t\tuint8_t core_id;\n-\t} wlcore_map[RTE_MAX_LCORE];\n-} wcpu_map = { 0 };\n-\n-/*\n- * Create a map of all processors and associated cores on the system\n- */\n-void\n-eal_create_cpu_map()\n+/** Number of logical processors (cores) in a processor group (32 or 64). */\n+#define EAL_PROCESSOR_GROUP_SIZE (sizeof(KAFFINITY) * CHAR_BIT)\n+\n+struct lcore_map {\n+\tuint8_t socket_id;\n+\tuint8_t core_id;\n+};\n+\n+struct socket_map {\n+\tuint16_t node_id;\n+};\n+\n+struct cpu_map {\n+\tunsigned int socket_count;\n+\tunsigned int lcore_count;\n+\tstruct lcore_map lcores[RTE_MAX_LCORE];\n+\tstruct socket_map sockets[RTE_MAX_NUMA_NODES];\n+};\n+\n+static struct cpu_map cpu_map = { 0 };\n+\n+/* eal_create_cpu_map() is called before logging is initialized */\n+static void\n+log_early(const char *format, ...)\n+{\n+\tva_list va;\n+\n+\tva_start(va, format);\n+\tvfprintf(stderr, format, va);\n+\tva_end(va);\n+}\n+\n+int\n+eal_create_cpu_map(void)\n {\n-\twcpu_map.total_procs =\n-\t\tGetActiveProcessorCount(ALL_PROCESSOR_GROUPS);\n-\n-\tLOGICAL_PROCESSOR_RELATIONSHIP lprocRel;\n-\tDWORD lprocInfoSize = 0;\n-\tBOOL ht_enabled = FALSE;\n-\n-\t/* First get the processor package information */\n-\tlprocRel = RelationProcessorPackage;\n-\t/* Determine the size of buffer we need (pass NULL) */\n-\tGetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize);\n-\twcpu_map.proc_sockets = lprocInfoSize / 48;\n-\n-\tlprocInfoSize = 0;\n-\t/* Next get the processor core information */\n-\tlprocRel = RelationProcessorCore;\n-\tGetLogicalProcessorInformationEx(lprocRel, NULL, &lprocInfoSize);\n-\twcpu_map.proc_cores = lprocInfoSize / 48;\n-\n-\tif (wcpu_map.total_procs > wcpu_map.proc_cores)\n-\t\tht_enabled = TRUE;\n-\n-\t/* Distribute the socket and core ids appropriately\n-\t * across the logical cores. For now, split the cores\n-\t * equally across the sockets.\n-\t */\n-\tunsigned int lcore = 0;\n-\tfor (unsigned int socket = 0; socket <\n-\t\t\twcpu_map.proc_sockets; ++socket) {\n-\t\tfor (unsigned int core = 0;\n-\t\t\tcore < (wcpu_map.proc_cores / wcpu_map.proc_sockets);\n-\t\t\t++core) {\n-\t\t\twcpu_map.wlcore_map[lcore]\n-\t\t\t\t\t.socket_id = socket;\n-\t\t\twcpu_map.wlcore_map[lcore]\n-\t\t\t\t\t.core_id = core;\n-\t\t\tlcore++;\n-\t\t\tif (ht_enabled) {\n-\t\t\t\twcpu_map.wlcore_map[lcore]\n-\t\t\t\t\t.socket_id = socket;\n-\t\t\t\twcpu_map.wlcore_map[lcore]\n-\t\t\t\t\t.core_id = core;\n-\t\t\t\tlcore++;\n+\tSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *infos, *info;\n+\tDWORD infos_size;\n+\tbool full = false;\n+\n+\tinfos_size = 0;\n+\tif (!GetLogicalProcessorInformationEx(\n+\t\t\tRelationNumaNode, NULL, &infos_size)) {\n+\t\tDWORD error = GetLastError();\n+\t\tif (error != ERROR_INSUFFICIENT_BUFFER) {\n+\t\t\tlog_early(\"Cannot get NUMA node info size, error %lu\\n\",\n+\t\t\t\tGetLastError());\n+\t\t\trte_errno = ENOMEM;\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tinfos = malloc(infos_size);\n+\tif (infos == NULL) {\n+\t\tlog_early(\"Cannot allocate memory for NUMA node information\\n\");\n+\t\trte_errno = ENOMEM;\n+\t\treturn -1;\n+\t}\n+\n+\tif (!GetLogicalProcessorInformationEx(\n+\t\t\tRelationNumaNode, infos, &infos_size)) {\n+\t\tlog_early(\"Cannot get NUMA node information, error %lu\\n\",\n+\t\t\tGetLastError());\n+\t\trte_errno = EINVAL;\n+\t\treturn -1;\n+\t}\n+\n+\tinfo = infos;\n+\twhile ((uint8_t *)info - (uint8_t *)infos < infos_size) {\n+\t\tunsigned int node_id = info->NumaNode.NodeNumber;\n+\t\tGROUP_AFFINITY *cores = &info->NumaNode.GroupMask;\n+\t\tstruct lcore_map *lcore;\n+\t\tunsigned int i, socket_id;\n+\n+\t\t/* NUMA node may be reported multiple times if it includes\n+\t\t * cores from different processor groups, e. g. 80 cores\n+\t\t * of a physical processor comprise one NUMA node, but two\n+\t\t * processor groups, because group size is limited by 32/64.\n+\t\t */\n+\t\tfor (socket_id = 0; socket_id < cpu_map.socket_count;\n+\t\t    socket_id++) {\n+\t\t\tif (cpu_map.sockets[socket_id].node_id == node_id)\n+\t\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (socket_id == cpu_map.socket_count) {\n+\t\t\tif (socket_id == RTE_DIM(cpu_map.sockets)) {\n+\t\t\t\tfull = true;\n+\t\t\t\tgoto exit;\n+\t\t\t}\n+\n+\t\t\tcpu_map.sockets[socket_id].node_id = node_id;\n+\t\t\tcpu_map.socket_count++;\n+\t\t}\n+\n+\t\tfor (i = 0; i < EAL_PROCESSOR_GROUP_SIZE; i++) {\n+\t\t\tif ((cores->Mask & ((KAFFINITY)1 << i)) == 0)\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (cpu_map.lcore_count == RTE_DIM(cpu_map.lcores)) {\n+\t\t\t\tfull = true;\n+\t\t\t\tgoto exit;\n \t\t\t}\n+\n+\t\t\tlcore = &cpu_map.lcores[cpu_map.lcore_count];\n+\t\t\tlcore->socket_id = socket_id;\n+\t\t\tlcore->core_id =\n+\t\t\t\tcores->Group * EAL_PROCESSOR_GROUP_SIZE + i;\n+\t\t\tcpu_map.lcore_count++;\n \t\t}\n+\n+\t\tinfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(\n+\t\t\t(uint8_t *)info + info->Size);\n \t}\n+\n+exit:\n+\tif (full) {\n+\t\t/* Not a fatal error, but important for troubleshooting. */\n+\t\tlog_early(\"Enumerated maximum of %u NUMA nodes and %u cores\\n\",\n+\t\t\tcpu_map.socket_count, cpu_map.lcore_count);\n+\t}\n+\n+\tfree(infos);\n+\n+\treturn 0;\n }\n \n-/*\n- * Check if a cpu is present by the presence of the cpu information for it\n- */\n int\n eal_cpu_detected(unsigned int lcore_id)\n {\n-\treturn (lcore_id < wcpu_map.total_procs);\n+\treturn lcore_id < cpu_map.lcore_count;\n }\n \n-/*\n- * Get CPU socket id for a logical core\n- */\n unsigned\n eal_cpu_socket_id(unsigned int lcore_id)\n {\n-\treturn wcpu_map.wlcore_map[lcore_id].socket_id;\n+\treturn cpu_map.lcores[lcore_id].socket_id;\n }\n \n-/*\n- * Get CPU socket id (NUMA node) for a logical core\n- */\n unsigned\n eal_cpu_core_id(unsigned int lcore_id)\n {\n-\treturn wcpu_map.wlcore_map[lcore_id].core_id;\n+\treturn cpu_map.lcores[lcore_id].core_id;\n+}\n+\n+unsigned int\n+eal_socket_numa_node(unsigned int socket_id)\n+{\n+\treturn cpu_map.sockets[socket_id].node_id;\n }\ndiff --git a/lib/librte_eal/windows/eal_windows.h b/lib/librte_eal/windows/eal_windows.h\nindex fadd676b2..f3ed8c37f 100644\n--- a/lib/librte_eal/windows/eal_windows.h\n+++ b/lib/librte_eal/windows/eal_windows.h\n@@ -13,8 +13,11 @@\n \n /**\n  * Create a map of processors and cores on the system.\n+ *\n+ * @return\n+ *  0 on success, (-1) on failure and rte_errno is set.\n  */\n-void eal_create_cpu_map(void);\n+int eal_create_cpu_map(void);\n \n /**\n  * Create a thread.\n@@ -26,4 +29,14 @@ void eal_create_cpu_map(void);\n  */\n int eal_thread_create(pthread_t *thread);\n \n+/**\n+ * Get system NUMA node number for a socket ID.\n+ *\n+ * @param socket_id\n+ *  Valid EAL socket ID.\n+ * @return\n+ *  NUMA node number to use with Win32 API.\n+ */\n+unsigned int eal_socket_numa_node(unsigned int socket_id);\n+\n #endif /* _EAL_WINDOWS_H_ */\n",
    "prefixes": [
        "v9",
        "09/12"
    ]
}