get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 37336,
    "url": "https://patches.dpdk.org/api/patches/37336/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1522950303-17206-3-git-send-email-jianfeng.tan@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": "<1522950303-17206-3-git-send-email-jianfeng.tan@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1522950303-17206-3-git-send-email-jianfeng.tan@intel.com",
    "date": "2018-04-05T17:45:00",
    "name": "[dpdk-dev,v2,2/5] bus/vdev: add lock on vdev device list",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3fda20530bf5df3b0b44456f8bfd1b88d7660173",
    "submitter": {
        "id": 313,
        "url": "https://patches.dpdk.org/api/people/313/?format=api",
        "name": "Jianfeng Tan",
        "email": "jianfeng.tan@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1522950303-17206-3-git-send-email-jianfeng.tan@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/37336/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/37336/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id B8F7B1CD50;\n\tThu,  5 Apr 2018 19:43:19 +0200 (CEST)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n\tby dpdk.org (Postfix) with ESMTP id A3DF41CCEC\n\tfor <dev@dpdk.org>; Thu,  5 Apr 2018 19:43:14 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n\tby orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Apr 2018 10:43:14 -0700",
            "from dpdk06.sh.intel.com ([10.67.110.196])\n\tby orsmga007.jf.intel.com with ESMTP; 05 Apr 2018 10:43:13 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.48,411,1517904000\"; d=\"scan'208\";a=\"31021133\"",
        "From": "Jianfeng Tan <jianfeng.tan@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "thomas@monjalon.net,\n\tJianfeng Tan <jianfeng.tan@intel.com>",
        "Date": "Thu,  5 Apr 2018 17:45:00 +0000",
        "Message-Id": "<1522950303-17206-3-git-send-email-jianfeng.tan@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1522950303-17206-1-git-send-email-jianfeng.tan@intel.com>",
        "References": "<1522950303-17206-1-git-send-email-jianfeng.tan@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 2/5] bus/vdev: add lock on vdev device list",
        "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://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": "<https://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": "As we could add virtual devices from different threads now, we\nadd a spin lock to protect the vdev device list.\n\nSuggested-by: Anatoly Burakov <anatoly.burakov@intel.com>\nSigned-off-by: Jianfeng Tan <jianfeng.tan@intel.com>\n---\n drivers/bus/vdev/vdev.c | 61 +++++++++++++++++++++++++++++++++++++------------\n 1 file changed, 47 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c\nindex 7eae319..1d1c642 100644\n--- a/drivers/bus/vdev/vdev.c\n+++ b/drivers/bus/vdev/vdev.c\n@@ -61,6 +61,8 @@ TAILQ_HEAD(vdev_device_list, rte_vdev_device);\n \n static struct vdev_device_list vdev_device_list =\n \tTAILQ_HEAD_INITIALIZER(vdev_device_list);\n+static rte_spinlock_t vdev_device_list_lock = RTE_SPINLOCK_INITIALIZER;\n+\n struct vdev_driver_list vdev_driver_list =\n \tTAILQ_HEAD_INITIALIZER(vdev_driver_list);\n \n@@ -177,6 +179,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)\n \treturn ret;\n }\n \n+/* The caller shall be responsible for thread-safe */\n static struct rte_vdev_device *\n find_vdev(const char *name)\n {\n@@ -231,10 +234,6 @@ rte_vdev_init(const char *name, const char *args)\n \tif (name == NULL)\n \t\treturn -EINVAL;\n \n-\tdev = find_vdev(name);\n-\tif (dev)\n-\t\treturn -EEXIST;\n-\n \tdevargs = alloc_devargs(name, args);\n \tif (!devargs)\n \t\treturn -ENOMEM;\n@@ -249,16 +248,28 @@ rte_vdev_init(const char *name, const char *args)\n \tdev->device.numa_node = SOCKET_ID_ANY;\n \tdev->device.name = devargs->name;\n \n+\trte_spinlock_lock(&vdev_device_list_lock);\n+\tif (find_vdev(name)) {\n+\t\trte_spinlock_unlock(&vdev_device_list_lock);\n+\t\tret = -EEXIST;\n+\t\tgoto fail;\n+\t}\n+\tTAILQ_INSERT_TAIL(&vdev_device_list, dev, next);\n+\trte_spinlock_unlock(&vdev_device_list_lock);\n+\n \tret = vdev_probe_all_drivers(dev);\n \tif (ret) {\n \t\tif (ret > 0)\n \t\t\tVDEV_LOG(ERR, \"no driver found for %s\\n\", name);\n+\t\t/* If fails, remove it from vdev list */\n+\t\trte_spinlock_lock(&vdev_device_list_lock);\n+\t\tTAILQ_REMOVE(&vdev_device_list, dev, next);\n+\t\trte_spinlock_unlock(&vdev_device_list_lock);\n \t\tgoto fail;\n \t}\n \n \tTAILQ_INSERT_TAIL(&devargs_list, devargs, next);\n \n-\tTAILQ_INSERT_TAIL(&vdev_device_list, dev, next);\n \treturn 0;\n \n fail:\n@@ -294,17 +305,25 @@ rte_vdev_uninit(const char *name)\n \tif (name == NULL)\n \t\treturn -EINVAL;\n \n+\trte_spinlock_lock(&vdev_device_list_lock);\n \tdev = find_vdev(name);\n-\tif (!dev)\n+\tif (!dev) {\n+\t\trte_spinlock_unlock(&vdev_device_list_lock);\n \t\treturn -ENOENT;\n+\t}\n+\tTAILQ_REMOVE(&vdev_device_list, dev, next);\n+\trte_spinlock_unlock(&vdev_device_list_lock);\n \n \tdevargs = dev->device.devargs;\n \n \tret = vdev_remove_driver(dev);\n-\tif (ret)\n+\tif (ret) {\n+\t\t/* If fails, add back to vdev list */\n+\t\trte_spinlock_lock(&vdev_device_list_lock);\n+\t\tTAILQ_INSERT_TAIL(&vdev_device_list, dev, next);\n+\t\trte_spinlock_unlock(&vdev_device_list_lock);\n \t\treturn ret;\n-\n-\tTAILQ_REMOVE(&vdev_device_list, dev, next);\n+\t}\n \n \tTAILQ_REMOVE(&devargs_list, devargs, next);\n \n@@ -342,19 +361,25 @@ vdev_scan(void)\n \t\tif (devargs->bus != &rte_vdev_bus)\n \t\t\tcontinue;\n \n-\t\tdev = find_vdev(devargs->name);\n-\t\tif (dev)\n-\t\t\tcontinue;\n-\n \t\tdev = calloc(1, sizeof(*dev));\n \t\tif (!dev)\n \t\t\treturn -1;\n \n+\t\trte_spinlock_lock(&vdev_device_list_lock);\n+\n+\t\tif (find_vdev(devargs->name)) {\n+\t\t\trte_spinlock_unlock(&vdev_device_list_lock);\n+\t\t\tfree(dev);\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\tdev->device.devargs = devargs;\n \t\tdev->device.numa_node = SOCKET_ID_ANY;\n \t\tdev->device.name = devargs->name;\n \n \t\tTAILQ_INSERT_TAIL(&vdev_device_list, dev, next);\n+\n+\t\trte_spinlock_unlock(&vdev_device_list_lock);\n \t}\n \n \treturn 0;\n@@ -368,6 +393,10 @@ vdev_probe(void)\n \n \t/* call the init function for each virtual device */\n \tTAILQ_FOREACH(dev, &vdev_device_list, next) {\n+\t\t/* we don't use the vdev lock here, as it's only used in DPDK\n+\t\t * initialization; and we don't want to hold such a lock when\n+\t\t * we call each driver probe.\n+\t\t */\n \n \t\tif (dev->device.driver)\n \t\t\tcontinue;\n@@ -388,14 +417,18 @@ vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,\n {\n \tstruct rte_vdev_device *dev;\n \n+\trte_spinlock_lock(&vdev_device_list_lock);\n \tTAILQ_FOREACH(dev, &vdev_device_list, next) {\n \t\tif (start && &dev->device == start) {\n \t\t\tstart = NULL;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (cmp(&dev->device, data) == 0)\n+\t\tif (cmp(&dev->device, data) == 0) {\n+\t\t\trte_spinlock_unlock(&vdev_device_list_lock);\n \t\t\treturn &dev->device;\n+\t\t}\n \t}\n+\trte_spinlock_unlock(&vdev_device_list_lock);\n \treturn NULL;\n }\n \n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "2/5"
    ]
}