get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 105238,
    "url": "http://patches.dpdk.org/api/patches/105238/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20211217182922.159503-1-stephen@networkplumber.org/",
    "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": "<20211217182922.159503-1-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211217182922.159503-1-stephen@networkplumber.org",
    "date": "2021-12-17T18:29:22",
    "name": "eal: fix data race in multi-process support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "32b32e11eeafbf75f6d2b3d373229dceb843af14",
    "submitter": {
        "id": 27,
        "url": "http://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "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/20211217182922.159503-1-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 20972,
            "url": "http://patches.dpdk.org/api/series/20972/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=20972",
            "date": "2021-12-17T18:29:22",
            "name": "eal: fix data race in multi-process support",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/20972/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/105238/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/105238/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 270CCA04A5;\n\tFri, 17 Dec 2021 19:29:29 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 738D84067C;\n\tFri, 17 Dec 2021 19:29:28 +0100 (CET)",
            "from mail-pj1-f46.google.com (mail-pj1-f46.google.com\n [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id 0C98E4013F\n for <dev@dpdk.org>; Fri, 17 Dec 2021 19:29:27 +0100 (CET)",
            "by mail-pj1-f46.google.com with SMTP id co15so3029266pjb.2\n for <dev@dpdk.org>; Fri, 17 Dec 2021 10:29:26 -0800 (PST)",
            "from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199])\n by smtp.gmail.com with ESMTPSA id\n o22sm11357422pfu.45.2021.12.17.10.29.25\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 17 Dec 2021 10:29:25 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20210112.gappssmtp.com; s=20210112;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=s6i48ckjBU1Wm8v3DWc1jIthy8UyNDtq3OvxXzcclB4=;\n b=vIWO5taIcySlCbKNUwC69bGkxCRxa5ixF+zKR5oLhwgYm0qUiqEVPtjTM7HlGd9sWd\n 5SqpxrXvHyzLAd6D3wNhbi9AeIhAAhvWxDxHV0IPS97KHuqo3F+EuJ+zYjKCCGHu39JI\n CG6OjI4lA3CGitOv5B0/hIzXgMVGpKLxvUf5BBdHgEbUV0+AUOTnNG5ltK6Kk0SgSLto\n kJipGMyaDv1K62J11l9ZdAzP4/5IdWkskyR/yT22r7ofPPQsX3V1EAxvOx+cGCQe3+I3\n q3CovO4OPtUy5hzHCj5ZmZ38+YO6FnHrBeKboJLVARgAIf8UTFYmiMS2ZTRiBLHqE3HH\n yFkw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\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=s6i48ckjBU1Wm8v3DWc1jIthy8UyNDtq3OvxXzcclB4=;\n b=bNNBNtZ2WGW6NFxd/NcTZZx4XOKSz25Sw0HP3VyklTHbdYv3qnZp6FMajnRAAMMtk4\n htaO57CUQsKtm87Am+s7zvNnGVUOPYxEw/BQddhH0ut8bvtWVmySPDuLcu8VxizBAyGs\n 0ovZLcKxcSK+dWMyaurTUtCATGH70uePFYsXcX9+z4R6MlX6DXSFuVPvBC5QeNhqGLvf\n /v8RVjSMtO5z2Nje7JD04WuwBYwR+sETWMcLdoZxJSkA4BXAd0bS7k2ZIntDTYyX4jPa\n 0mBfISrQ0nVBnOo/8UPenBbkuaBHZyxj5dH9Ox1P1jSyGlqDL2sz9DToCGsOpPgwItSU\n BmNQ==",
        "X-Gm-Message-State": "AOAM532GNTTSo/Vp1u4+pY1T5WlrjtjRreZQI3Q/3AL3rbon3ZWoNtVX\n 0gJWDmZnuBM+qoOtnDMJQSNS7w==",
        "X-Google-Smtp-Source": "\n ABdhPJwzHn2UbKFGhrPMN0HGaQWdL4LcxaLfZFgvs0rq4pH4tPTUBM/QCoC67R+qX+6AFrNU6hdFCQ==",
        "X-Received": "by 2002:a17:90b:4a89:: with SMTP id\n lp9mr13652584pjb.6.1639765766150;\n Fri, 17 Dec 2021 10:29:26 -0800 (PST)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "anatoly.burakov@intel.com",
        "Cc": "dev@dpdk.org, stable@dpdk.org,\n Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[PATCH] eal: fix data race in multi-process support",
        "Date": "Fri, 17 Dec 2021 10:29:22 -0800",
        "Message-Id": "<20211217182922.159503-1-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20211217181649.154972-1-stephen@networkplumber.org>",
        "References": "<20211217181649.154972-1-stephen@networkplumber.org>",
        "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": "If DPDK is built with thread sanitizer it reports a race\nin setting of multiprocess file descriptor. The fix is to\nuse atomic operations when updating mp_fd.\n\nSimple example:\n$ dpdk-testpmd -l 1-3 --no-huge\n...\nEAL: Error - exiting with code: 1\n  Cause: Creation of mbuf pool for socket 0 failed: Cannot allocate memory\n==================\nWARNING: ThreadSanitizer: data race (pid=83054)\n  Write of size 4 at 0x55e3b7fce450 by main thread:\n    #0 rte_mp_channel_cleanup <null> (dpdk-testpmd+0x160d79c)\n    #1 rte_eal_cleanup <null> (dpdk-testpmd+0x1614fb5)\n    #2 rte_exit <null> (dpdk-testpmd+0x15ec97a)\n    #3 mbuf_pool_create.cold <null> (dpdk-testpmd+0x242e1a)\n    #4 main <null> (dpdk-testpmd+0x5ab05d)\n\n  Previous read of size 4 at 0x55e3b7fce450 by thread T2:\n    #0 mp_handle <null> (dpdk-testpmd+0x160c979)\n    #1 ctrl_thread_init <null> (dpdk-testpmd+0x15ff76e)\n\n  As if synchronized via sleep:\n    #0 nanosleep ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:362 (libtsan.so.0+0x5cd8e)\n    #1 get_tsc_freq <null> (dpdk-testpmd+0x1622889)\n    #2 set_tsc_freq <null> (dpdk-testpmd+0x15ffb9c)\n    #3 rte_eal_timer_init <null> (dpdk-testpmd+0x1622a34)\n    #4 rte_eal_init.cold <null> (dpdk-testpmd+0x26b314)\n    #5 main <null> (dpdk-testpmd+0x5aab45)\n\n  Location is global 'mp_fd' of size 4 at 0x55e3b7fce450 (dpdk-testpmd+0x0000027c7450)\n\n  Thread T2 'rte_mp_handle' (tid=83057, running) created by main thread at:\n    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:962 (libtsan.so.0+0x58ba2)\n    #1 rte_ctrl_thread_create <null> (dpdk-testpmd+0x15ff870)\n    #2 rte_mp_channel_init.cold <null> (dpdk-testpmd+0x269986)\n    #3 rte_eal_init <null> (dpdk-testpmd+0x1615b28)\n    #4 main <null> (dpdk-testpmd+0x5aab45)\n\nSUMMARY: ThreadSanitizer: data race (/home/shemminger/DPDK/main/build/app/dpdk-testpmd+0x160d79c) in rte_mp_channel_cleanup\n==================\nThreadSanitizer: reported 1 warnings\n\nFixes: bacaa2754017 (\"eal: add channel for multi-process communication\")\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n\n---\nv2 - fix the mp socket bind\n\n lib/eal/common/eal_common_proc.c | 17 ++++++++---------\n 1 file changed, 8 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c\nindex ebd0f6673b8b..72c7e8f536af 100644\n--- a/lib/eal/common/eal_common_proc.c\n+++ b/lib/eal/common/eal_common_proc.c\n@@ -262,7 +262,7 @@ rte_mp_action_unregister(const char *name)\n }\n \n static int\n-read_msg(struct mp_msg_internal *m, struct sockaddr_un *s)\n+read_msg(int fd, struct mp_msg_internal *m, struct sockaddr_un *s)\n {\n \tint msglen;\n \tstruct iovec iov;\n@@ -282,7 +282,7 @@ read_msg(struct mp_msg_internal *m, struct sockaddr_un *s)\n \tmsgh.msg_control = control;\n \tmsgh.msg_controllen = sizeof(control);\n \n-\tmsglen = recvmsg(mp_fd, &msgh, 0);\n+\tmsglen = recvmsg(fd, &msgh, 0);\n \tif (msglen < 0) {\n \t\tRTE_LOG(ERR, EAL, \"recvmsg failed, %s\\n\", strerror(errno));\n \t\treturn -1;\n@@ -383,9 +383,10 @@ mp_handle(void *arg __rte_unused)\n {\n \tstruct mp_msg_internal msg;\n \tstruct sockaddr_un sa;\n+\tint fd;\n \n-\twhile (mp_fd >= 0) {\n-\t\tif (read_msg(&msg, &sa) == 0)\n+\twhile ((fd = __atomic_load_n(&mp_fd, __ATOMIC_RELAXED)) >= 0) {\n+\t\tif (read_msg(fd, &msg, &sa) == 0)\n \t\t\tprocess_msg(&msg, &sa);\n \t}\n \n@@ -626,9 +627,8 @@ rte_mp_channel_init(void)\n \t\t\tNULL, mp_handle, NULL) < 0) {\n \t\tRTE_LOG(ERR, EAL, \"failed to create mp thread: %s\\n\",\n \t\t\tstrerror(errno));\n-\t\tclose(mp_fd);\n \t\tclose(dir_fd);\n-\t\tmp_fd = -1;\n+\t\tclose(__atomic_exchange_n(&mp_fd, -1, __ATOMIC_RELAXED));\n \t\treturn -1;\n \t}\n \n@@ -644,11 +644,10 @@ rte_mp_channel_cleanup(void)\n {\n \tint fd;\n \n-\tif (mp_fd < 0)\n+\tfd = __atomic_exchange_n(&mp_fd, -1, __ATOMIC_RELAXED);\n+\tif (fd < 0)\n \t\treturn;\n \n-\tfd = mp_fd;\n-\tmp_fd = -1;\n \tpthread_cancel(mp_handle_tid);\n \tpthread_join(mp_handle_tid, NULL);\n \tclose_socket_fd(fd);\n",
    "prefixes": []
}