get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 139725,
    "url": "http://patchwork.dpdk.org/api/patches/139725/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20240429195342.42711-1-stephen@networkplumber.org/",
    "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": "<20240429195342.42711-1-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240429195342.42711-1-stephen@networkplumber.org",
    "date": "2024-04-29T19:52:25",
    "name": "[RFC] eal: make lcore_init aware of cgroup",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": false,
    "hash": "a21feff7916eab5d3a892b5d2a36165a405fd2db",
    "submitter": {
        "id": 27,
        "url": "http://patchwork.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "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/20240429195342.42711-1-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 31840,
            "url": "http://patchwork.dpdk.org/api/series/31840/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=31840",
            "date": "2024-04-29T19:52:25",
            "name": "[RFC] eal: make lcore_init aware of cgroup",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/31840/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/139725/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/139725/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 4640743F49;\n\tMon, 29 Apr 2024 21:53:57 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id CD9E0402A3;\n\tMon, 29 Apr 2024 21:53:56 +0200 (CEST)",
            "from mail-pl1-f180.google.com (mail-pl1-f180.google.com\n [209.85.214.180])\n by mails.dpdk.org (Postfix) with ESMTP id C289F4029C\n for <dev@dpdk.org>; Mon, 29 Apr 2024 21:53:54 +0200 (CEST)",
            "by mail-pl1-f180.google.com with SMTP id\n d9443c01a7336-1e8fce77bb2so37889475ad.0\n for <dev@dpdk.org>; Mon, 29 Apr 2024 12:53:54 -0700 (PDT)",
            "from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])\n by smtp.gmail.com with ESMTPSA id\n n16-20020a170903111000b001e2a479954dsm20758671plh.181.2024.04.29.12.53.52\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 29 Apr 2024 12:53:52 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1714420434;\n x=1715025234; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=ZUu+AypWLkRT6c2de6NekNSSFUEELaDu4HY8kec0acE=;\n b=gM5qHgdhdUoK1u00TT6X+wv/6nnmoeqRVumt2yID0LKiQM1unqJ40sIVgmvnTKbrSX\n yU3VHlCSyBMJRRp5WKbjjcoO2+BocqHvPcXr4wgcw/5QvLIH9ZeJX86vMz0IF9uLkesQ\n h3o0OT2Glv2ZMdU4zbNTbqgwsyIYLoNxiVe8Fod0UYSVuEx21TRffhJnU0YuRYbTYIT5\n BZB5bS0e3i4MKf/eB9xPE9+mx3l/65dBok7OJXh0LTNzlI7BFNJkgUsIvmPI4a/CzzZU\n wkC5VNWjPqy8tx0Xmv5OPGNcNanqnRUGtAa+wWH26V/fd4uw4CFYZ4FWDlUblH09W4Ci\n x3YQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1714420434; x=1715025234;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=ZUu+AypWLkRT6c2de6NekNSSFUEELaDu4HY8kec0acE=;\n b=BOqqpd+TTobs+sGE0nHE4paAGlbl7pZVqqpQFtP25VIoWMtPRXYdrPfVihz+hO58gy\n KmHzwmj6qIt+PJIaDxWmzBfa6Fqq6901JXsTowOdjb1jj5yLzuLcVkvr+oIwz5xFalaI\n pyNsC1lhNysVwyZv5CDHWa0rsB/AQ9o4XpqBM/Z5s0Gh3PVMaKPEFu7n5qNt1uC6snCN\n VcxFAJUVkzbB8RumaBAPncMIPfHJPejovnqr5sb9ZzrXDPQEqXcHbORP+yGt0tvBptEJ\n A2aS6dOikxw5N9NkJMHLBY7ThZ5EfvZT8oSrBGH7ao3kpYXfuZgSC1XArq4+NSCQlZ5T\n 1RFg==",
        "X-Gm-Message-State": "AOJu0YxXcaBdraaQXEyZF1kimvI8yg4i3kXX1rauwstClKphK7Ic8rlW\n 3REdP0foV9l5W4WSE0Aw5rfuca5OH85gZeVLcAYH1MmQBn/jdi6uy74QTu02W/rany3BFcFRfBv\n fBpg=",
        "X-Google-Smtp-Source": "\n AGHT+IHWskozALXTvAdjukGZggxOEAS+QXUe0wPupevzVUoywatnNXS2e+tigAj5INmRxt1R430JrA==",
        "X-Received": "by 2002:a17:902:ea11:b0:1e5:963d:963 with SMTP id\n s17-20020a170902ea1100b001e5963d0963mr623906plg.68.1714420433652;\n Mon, 29 Apr 2024 12:53:53 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[RFC] eal: make lcore_init aware of cgroup",
        "Date": "Mon, 29 Apr 2024 12:52:25 -0700",
        "Message-ID": "<20240429195342.42711-1-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "MIME-Version": "1.0",
        "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": "Some lcores maybe restricted from being used by DPDK by cgroups.\nThis should be detected at startup and only those cpu's allowed\nto be used by the process should be marked as enabled.\n\nThis is a lightly tested patch, and parsing the cpuset info here\nprobably needs more checking. It is a response to the problem\nreported with error handling.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/eal/linux/eal_lcore.c | 95 ++++++++++++++++++++++++++++++++++++---\n 1 file changed, 88 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/lib/eal/linux/eal_lcore.c b/lib/eal/linux/eal_lcore.c\nindex 29b36dd610..098892fafa 100644\n--- a/lib/eal/linux/eal_lcore.c\n+++ b/lib/eal/linux/eal_lcore.c\n@@ -4,6 +4,7 @@\n \n #include <unistd.h>\n #include <limits.h>\n+#include <inttypes.h>\n \n #include <rte_log.h>\n \n@@ -11,23 +12,103 @@\n #include \"eal_filesystem.h\"\n #include \"eal_thread.h\"\n \n+#define PROC_STATUS \"/proc/%u/status\"\n #define SYS_CPU_DIR \"/sys/devices/system/cpu/cpu%u\"\n #define CORE_ID_FILE \"topology/core_id\"\n #define NUMA_NODE_PATH \"/sys/devices/system/node\"\n \n-/* Check if a cpu is present by the presence of the cpu information for it */\n+static cpu_set_t *cpus_allowed;\n+\n+/*\n+ * Initialize allowed cpus from /proc/<pid>status\n+ * The cpus allowed is a subset of available lcores on the system\n+ * which maybe restricted by cgroups\n+ */\n+static void\n+get_allowed_cpus(cpu_set_t *set)\n+{\n+\tconst char cpus_allowed[] = \"Cpus_allowed:\";\n+\tconst size_t setsize = CPU_ALLOC_SIZE(RTE_MAX_LCORE);\n+\tchar path[PATH_MAX];\n+\tchar line[LINE_MAX];\n+\tFILE *f;\n+\n+\tCPU_ZERO_S(setsize, set);\n+\n+\tsnprintf(path, sizeof(path), PROC_STATUS, getpid());\n+\tf = fopen(path, \"r\");\n+\tif (f == NULL) {\n+\t\tEAL_LOG(ERR, \"%s(): cannot open %s: %s\",\n+\t\t\t__func__, path, strerror(errno));\n+\t\treturn;\n+\t}\n+\n+\twhile (fgets(line, sizeof(line), f)) {\n+\t\tchar *cp;\n+\t\tunsigned int cpu;\n+\n+\t\tif (strncmp(line, cpus_allowed, sizeof(cpus_allowed) - 1))\n+\t\t\tcontinue;\n+\n+\t\tcp = line + sizeof(cpus_allowed);\n+\n+\t\twhile(*cp && isspace(*cp))\n+\t\t\t++cp;\n+\n+\t\tfor (cpu = 0; cpu < RTE_MAX_LCORE; cpu += 32) {\n+\t\t\tuint32_t cpu_mask;\n+\t\t\tunsigned int i;\n+\n+\t\t\tif (*cp == '\\0')\n+\t\t\t\tbreak;\n+\n+\t\t\tif (sscanf(cp, \"%\" SCNx32, &cpu_mask) != 1) {\n+\t\t\t\tEAL_LOG(NOTICE, \"%s(): can not parse: %s\",\n+\t\t\t\t\t__func__, line);\n+\t\t\t\tgoto error;\n+\t\t\t}\n+\t\t\tfor (i = 0; i < 32; i++) {\n+\t\t\t\tif (cpu_mask & (1u << i))\n+\t\t\t\t\tCPU_SET_S(cpu + i, setsize, set);\n+\t\t\t}\n+\n+\t\t\tcp = strchr(cp, ',');\n+\t\t\tif (cp == NULL)\n+\t\t\t\tbreak;\n+\t\t\tcp += 1; /* skip the comma */\n+\t\t}\n+\t}\n+\n+error:\n+\tfclose(f);\n+}\n+\n+/* Check if a cpu can be used by looking at /proc/<pid>/status */\n int\n-eal_cpu_detected(unsigned lcore_id)\n+eal_cpu_detected(unsigned int lcore_id)\n {\n \tchar path[PATH_MAX];\n-\tint len = snprintf(path, sizeof(path), SYS_CPU_DIR\n-\t\t\"/\"CORE_ID_FILE, lcore_id);\n-\tif (len <= 0 || (unsigned)len >= sizeof(path))\n+\tint len;\n+\n+\tif (cpus_allowed == NULL) {\n+\t\tcpus_allowed = CPU_ALLOC(RTE_MAX_LCORE);\n+\n+\t\tif (cpus_allowed == NULL) {\n+\t\t\tEAL_LOG(ERR, \"%s(): cannot allocate cpuset\", __func__);\n+\t\t\treturn 0;\n+\t\t}\n+\t\tget_allowed_cpus(cpus_allowed);\n+\t}\n+\n+\t/* skip cpus blocked by cgroup */\n+\tif (!CPU_ISSET(lcore_id, cpus_allowed))\n \t\treturn 0;\n-\tif (access(path, F_OK) != 0)\n+\n+\tlen = snprintf(path, sizeof(path), SYS_CPU_DIR \"/\"CORE_ID_FILE, lcore_id);\n+\tif (len <= 0 || (unsigned)len >= sizeof(path))\n \t\treturn 0;\n \n-\treturn 1;\n+\treturn access(path, F_OK) == 0;\n }\n \n /*\n",
    "prefixes": [
        "RFC"
    ]
}