Show a patch.

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

{
    "id": 1,
    "url": "http://patches.dpdk.org/api/patches/1/",
    "web_url": "http://patches.dpdk.org/patch/1/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<534DD019.108@gmail.com>",
    "date": "2014-04-16T00:34:33",
    "name": "[dpdk-dev] eal_lcore: check /sys/devices/system/node/nodeY/cpuX as a, fallback for socket id detecting",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": true,
    "hash": "639d214a9bd0a0484e71a272f25d1d5618be0e8a",
    "submitter": {
        "id": 2,
        "url": "http://patches.dpdk.org/api/people/2/",
        "name": "Wang Sheng-Hui",
        "email": "shhuiw@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/patch/1/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/1/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/1/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<shhuiw@gmail.com>",
        "MIME-Version": "1.0",
        "X-Mailman-Version": "2.1.15",
        "From": "Wang Sheng-Hui <shhuiw@gmail.com>",
        "X-List-Received-Date": "Wed, 16 Apr 2014 00:34:46 -0000",
        "User-Agent": "Mozilla/5.0 (X11; Linux i686;\n\trv:24.0) Gecko/20100101 Thunderbird/24.2.0",
        "Content-Type": "text/plain; charset=ISO-8859-1",
        "X-BeenThere": "dev@dpdk.org",
        "Received": [
            "from mail-pd0-f171.google.com (mail-pd0-f171.google.com\n\t[209.85.192.171]) by dpdk.org (Postfix) with ESMTP id 30FEEAFDC\n\tfor <dev@dpdk.org>; Wed, 16 Apr 2014 02:34:46 +0200 (CEST)",
            "by mail-pd0-f171.google.com with SMTP id r10so10082642pdi.2\n\tfor <dev@dpdk.org>; Tue, 15 Apr 2014 17:34:46 -0700 (PDT)",
            "from [10.200.0.70] ([124.207.145.166])\n\tby mx.google.com with ESMTPSA id\n\tsy1sm102414849pab.30.2014.04.15.17.34.42 for <dev@dpdk.org>\n\t(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);\n\tTue, 15 Apr 2014 17:34:44 -0700 (PDT)"
        ],
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "X-Received": "by 10.69.31.42 with SMTP id kj10mr5029616pbd.165.1397608486112; \n\tTue, 15 Apr 2014 17:34:46 -0700 (PDT)",
        "Subject": "[dpdk-dev] [PATCH] eal_lcore: check\n\t/sys/devices/system/node/nodeY/cpuX as a,\n\tfallback for socket id detecting",
        "Message-ID": "<534DD019.108@gmail.com>",
        "Precedence": "list",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\n\th=message-id:date:from:user-agent:mime-version:to:subject\n\t:content-type:content-transfer-encoding;\n\tbh=fxrjgGAX4G6Ux0usUzttaUeL3R+FIIW5G4KWxBoF4hA=;\n\tb=OUAiDKLi08FdJCKdFiVsBGJ5gYLYtT11xfZGUf4ZlSyWlEEvipGzKZ/tWY683ZfkRQ\n\tFhpEtqLaW+32JXrQkp13hdbqNp9K9IKI9lR2ynSIt+F9rIC7duhlJWLBecrp84+sD4Ba\n\tMRDFjaf9izifIgnfAFErC5/pCOioVYDH/2ThPV0Og/MJnpEox5jvFEypkuNWK4lhTrFg\n\tpDECkwSvlLX8TcFu80vJL6LjVskZVLaINRubKxXhyK6FVKr5q9dLagzkfE3zcVeXzR1K\n\t06zrtvkaq7L2Cq37UJgf/9ArWcZqvTBMzPLRZE0ZIEr2gp4VSkjOwxLkOkkov5fyhHPR\n\t4STA==",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "Date": "Wed, 16 Apr 2014 08:34:33 +0800",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "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>",
        "Content-Transfer-Encoding": "7bit",
        "To": "dev@dpdk.org"
    },
    "content": "3 ways to get the NUMA info:\n        1) check the existence of symlink /sys/devices/system/cpu/cpuX/nodeY\n        2) check the existence of symlink /sys/devices/system/node/nodeY/cpuX\n        3) get the value from\n                /sys/devices/system/cpu/cpuX/topology/physical_package_id\n\nSigned-off-by: Wang Sheng-Hui <shhuiw@gmail.com>\n---\n lib/librte_eal/linuxapp/eal/eal_lcore.c | 76 +++++++++++++++++++++++++--------\n 1 file changed, 59 insertions(+), 17 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/linuxapp/eal/eal_lcore.c b/lib/librte_eal/linuxapp/eal/eal_lcore.c\nindex da20fa3..ace5cec 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_lcore.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_lcore.c\n@@ -35,6 +35,9 @@\n #include <limits.h>\n #include <string.h>\n #include <dirent.h>\n+#include <sys/types.h>\n+#include <sys/stat.h>\n+#include <fcntl.h>\n\n #include <rte_log.h>\n #include <rte_eal.h>\n@@ -49,6 +52,7 @@\n #define SYS_CPU_DIR \"/sys/devices/system/cpu/cpu%u\"\n #define CORE_ID_FILE \"topology/core_id\"\n #define PHYS_PKG_FILE \"topology/physical_package_id\"\n+#define SYS_NODE_DIR \"/sys/devices/system/node\"\n\n /* Check if a cpu is present by the presence of the cpu information for it */\n static int\n@@ -66,31 +70,36 @@ cpu_detected(unsigned lcore_id)\n }\n\n /* Get CPU socket id (NUMA node) by reading directory\n- * /sys/devices/system/cpu/cpuX looking for symlink \"nodeY\"\n+ * /sys/devices/system/cpu/cpuX looking for symlink \"nodeY\",\n+ * or /sys/devices/system/node/nodeY for symlink \"cpuX\",\n  * which gives the NUMA topology information.\n  * Note: physical package id != NUMA node, but we use it as a\n- * fallback for kernels which don't create a nodeY link\n+ * fallback for kernels which don't create a nodeY or cpuX link.\n  */\n static unsigned\n cpu_socket_id(unsigned lcore_id)\n {\n        const char node_prefix[] = \"node\";\n+       const char cpu_prefix[] = \"cpu\";\n        const size_t prefix_len = sizeof(node_prefix) - 1;\n        char path[PATH_MAX];\n        DIR *d;\n+       DIR *sub_dir = NULL;\n        unsigned long id = 0;\n        struct dirent *e;\n        char *endptr = NULL;\n\n+       RTE_LOG(DEBUG, EAL, \"Read numa node link for lcore %u from\"\n+                       \"/sys/devices/system/cpu/cpu%u/nodeX\\n\",\n+                       lcore_id, lcore_id);\n+\n        int len = rte_snprintf(path, sizeof(path),\n                               SYS_CPU_DIR, lcore_id);\n        if (len <= 0 || (unsigned)len >= sizeof(path))\n                goto err;\n-\n        d = opendir(path);\n        if (!d)\n                goto err;\n-\n        while ((e = readdir(d)) != NULL) {\n                if (strncmp(e->d_name, node_prefix, prefix_len) == 0) {\n                        id = strtoul(e->d_name+prefix_len, &endptr, 0);\n@@ -98,23 +107,56 @@ cpu_socket_id(unsigned lcore_id)\n                }\n        }\n        closedir(d);\n-       if (endptr == NULL || *endptr!='\\0' || endptr == e->d_name+prefix_len) {\n-               RTE_LOG(WARNING, EAL, \"Cannot read numa node link \"\n-                               \"for lcore %u - using physical package id instead\\n\",\n-                               lcore_id);\n-\n-               len = rte_snprintf(path, sizeof(path), SYS_CPU_DIR \"/%s\",\n-                               lcore_id, PHYS_PKG_FILE);\n-               if (len <= 0 || (unsigned)len >= sizeof(path))\n-                       goto err;\n-               if (eal_parse_sysfs_value(path, &id) != 0)\n-                       goto err;\n+       if (! (endptr == NULL || *endptr!='\\0' ||\n+               endptr == e->d_name+prefix_len))\n+               goto out;\n+\n+       RTE_LOG(DEBUG, EAL, \"Read numa node topo for lcore %u from \"\n+                       \"/sys/devices/system/node/nodeX/cpu%u\\n\",\n+                       lcore_id, lcore_id);\n+\n+       len = rte_snprintf(path, sizeof(path), SYS_NODE_DIR);\n+       if (len <= 0 || (unsigned)len >= sizeof(path))\n+               goto err;\n+       d = opendir(path);\n+       if (!d)\n+               goto err;\n+       while ((e = readdir(d)) != NULL) {\n+               if (strncmp(e->d_name, node_prefix, prefix_len) == 0) {\n+                       len = rte_snprintf(path, sizeof(path), SYS_NODE_DIR \"/%s/%s%d\",\n+                                       e->d_name, cpu_prefix, lcore_id);\n+                       if (len <= 0 || (unsigned)len >= sizeof(path))\n+                               goto err;\n+                       sub_dir = opendir(path);\n+                       closedir(sub_dir);\n+                       if (!sub_dir)\n+                               continue;\n+                       id = strtoul(e->d_name+prefix_len, &endptr, 0);\n+                       break;\n+               }\n        }\n+       closedir(d);\n+       if (! (endptr == NULL || *endptr!='\\0' ||\n+               endptr == e->d_name+prefix_len))\n+               goto out;\n+\n+       RTE_LOG(WARNING, EAL, \"Cannot read numa node link \"\n+                       \"for lcore %u - using physical package id instead\\n\",\n+                       lcore_id);\n+       len = rte_snprintf(path, sizeof(path), SYS_CPU_DIR \"/%s\",\n+                       lcore_id, PHYS_PKG_FILE);\n+       if (len <= 0 || (unsigned)len >= sizeof(path))\n+               goto err;\n+       if (eal_parse_sysfs_value(path, &id) != 0)\n+               goto err;\n+\n+out:\n        return (unsigned)id;\n\n err:\n-       RTE_LOG(ERR, EAL, \"Error getting NUMA socket information from %s \"\n-                       \"for lcore %u - assuming NUMA socket 0\\n\", SYS_CPU_DIR, lcore_id);\n+       RTE_LOG(ERR, EAL, \"Error getting NUMA socket information from %s or %s\"\n+                       \"for lcore %u - assuming NUMA socket 0\\n\", SYS_CPU_DIR,\n+                       SYS_NODE_DIR, lcore_id);\n        return 0;\n }\n\n",
    "prefixes": [
        "dpdk-dev"
    ]
}