get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 58619,
    "url": "https://patches.dpdk.org/api/patches/58619/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20190905161421.55981-11-yong.liu@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": "<20190905161421.55981-11-yong.liu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190905161421.55981-11-yong.liu@intel.com",
    "date": "2019-09-05T16:14:17",
    "name": "[v1,10/14] vhost: optimize Rx function of packed ring",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "9d4ac739c1f48bd4cedd79223583f2d9ba4e611c",
    "submitter": {
        "id": 17,
        "url": "https://patches.dpdk.org/api/people/17/?format=api",
        "name": "Marvin Liu",
        "email": "yong.liu@intel.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20190905161421.55981-11-yong.liu@intel.com/mbox/",
    "series": [
        {
            "id": 6248,
            "url": "https://patches.dpdk.org/api/series/6248/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=6248",
            "date": "2019-09-05T16:14:07",
            "name": "vhost packed ring performance optimization",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/6248/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/58619/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/58619/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 814331EF33;\n\tThu,  5 Sep 2019 10:34:56 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 33CB01EE28\n\tfor <dev@dpdk.org>; Thu,  5 Sep 2019 10:34:43 +0200 (CEST)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Sep 2019 01:34:42 -0700",
            "from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.142])\n\tby fmsmga006.fm.intel.com with ESMTP; 05 Sep 2019 01:34:41 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.64,470,1559545200\"; d=\"scan'208\";a=\"383781597\"",
        "From": "Marvin Liu <yong.liu@intel.com>",
        "To": "tiwei.bie@intel.com,\n\tmaxime.coquelin@redhat.com,\n\tdev@dpdk.org",
        "Cc": "Marvin Liu <yong.liu@intel.com>",
        "Date": "Fri,  6 Sep 2019 00:14:17 +0800",
        "Message-Id": "<20190905161421.55981-11-yong.liu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190905161421.55981-1-yong.liu@intel.com>",
        "References": "<20190905161421.55981-1-yong.liu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v1 10/14] vhost: optimize Rx function of packed\n\tring",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Optimize vhost device rx function by separate descriptors, no-chained\nand direct descriptors will be handled by burst and other will be\nhandled one by one as before. Pre-fetch descriptors in next two cache\nlines as hardware will load two cache line data automatically.\n\nSigned-off-by: Marvin Liu <yong.liu@intel.com>",
    "diff": "diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c\nindex 8d09e1611..269ec8a43 100644\n--- a/lib/librte_vhost/virtio_net.c\n+++ b/lib/librte_vhost/virtio_net.c\n@@ -769,64 +769,6 @@ fill_vec_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \treturn 0;\n }\n \n-/*\n- * Returns -1 on fail, 0 on success\n- */\n-static inline int\n-reserve_avail_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n-\t\t\t\tuint32_t size, struct buf_vector *buf_vec,\n-\t\t\t\tuint16_t *nr_vec, uint16_t *num_buffers,\n-\t\t\t\tuint16_t *nr_descs)\n-{\n-\tuint16_t avail_idx;\n-\tuint16_t vec_idx = 0;\n-\tuint16_t max_tries, tries = 0;\n-\n-\tuint16_t buf_id = 0;\n-\tuint32_t len = 0;\n-\tuint16_t desc_count;\n-\n-\t*num_buffers = 0;\n-\tavail_idx = vq->last_avail_idx;\n-\n-\tif (rxvq_is_mergeable(dev))\n-\t\tmax_tries = vq->size - 1;\n-\telse\n-\t\tmax_tries = 1;\n-\n-\twhile (size > 0) {\n-\t\t/*\n-\t\t * if we tried all available ring items, and still\n-\t\t * can't get enough buf, it means something abnormal\n-\t\t * happened.\n-\t\t */\n-\t\tif (unlikely(++tries > max_tries))\n-\t\t\treturn -1;\n-\n-\t\tif (unlikely(fill_vec_buf_packed(dev, vq,\n-\t\t\t\t\t\tavail_idx, &desc_count,\n-\t\t\t\t\t\tbuf_vec, &vec_idx,\n-\t\t\t\t\t\t&buf_id, &len,\n-\t\t\t\t\t\tVHOST_ACCESS_RW) < 0))\n-\t\t\treturn -1;\n-\n-\t\tlen = RTE_MIN(len, size);\n-\t\tupdate_shadow_packed(vq, buf_id, len, desc_count);\n-\t\tsize -= len;\n-\n-\t\tavail_idx += desc_count;\n-\t\tif (avail_idx >= vq->size)\n-\t\t\tavail_idx -= vq->size;\n-\n-\t\t*nr_descs += desc_count;\n-\t\t*num_buffers += 1;\n-\t}\n-\n-\t*nr_vec = vec_idx;\n-\n-\treturn 0;\n-}\n-\n static __rte_noinline void\n copy_vnet_hdr_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tstruct buf_vector *buf_vec,\n@@ -1120,7 +1062,7 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \treturn pkt_idx;\n }\n \n-static __rte_unused uint16_t\n+static __rte_always_inline uint16_t\n virtio_dev_rx_burst_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t struct rte_mbuf **pkts)\n {\n@@ -1229,7 +1171,7 @@ virtio_dev_rx_burst_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \treturn 0;\n }\n \n-static __rte_unused int16_t\n+static __rte_always_inline int16_t\n virtio_dev_rx_single_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \tstruct rte_mbuf *pkt)\n {\n@@ -1263,46 +1205,45 @@ virtio_dev_rx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \tstruct rte_mbuf **pkts, uint32_t count)\n {\n \tuint32_t pkt_idx = 0;\n-\tuint16_t num_buffers;\n-\tstruct buf_vector buf_vec[BUF_VECTOR_MAX];\n+\tuint32_t pkt_num;\n+\tuint32_t remained = count;\n+\tuint16_t fetch_idx;\n+\tint ret;\n+\tstruct vring_packed_desc *descs = vq->desc_packed;\n \n-\tfor (pkt_idx = 0; pkt_idx < count; pkt_idx++) {\n-\t\tuint32_t pkt_len = pkts[pkt_idx]->pkt_len + dev->vhost_hlen;\n-\t\tuint16_t nr_vec = 0;\n-\t\tuint16_t nr_descs = 0;\n+\tdo {\n+\t\tif ((vq->last_avail_idx & 0x7) == 0) {\n+\t\t\tfetch_idx = vq->last_avail_idx + 8;\n+\t\t\trte_prefetch0((void *)(uintptr_t)&descs[fetch_idx]);\n+\t\t}\n \n-\t\tif (unlikely(reserve_avail_buf_packed(dev, vq,\n-\t\t\t\t\t\tpkt_len, buf_vec, &nr_vec,\n-\t\t\t\t\t\t&num_buffers, &nr_descs) < 0)) {\n-\t\t\tVHOST_LOG_DEBUG(VHOST_DATA,\n-\t\t\t\t\"(%d) failed to get enough desc from vring\\n\",\n-\t\t\t\tdev->vid);\n-\t\t\tvq->shadow_used_idx -= num_buffers;\n-\t\t\tbreak;\n+\t\tif (remained >= PACKED_DESCS_BURST) {\n+\t\t\tret = virtio_dev_rx_burst_packed(dev, vq, pkts);\n+\n+\t\t\tif (!ret) {\n+\t\t\t\tpkt_num = PACKED_DESCS_BURST;\n+\t\t\t\tpkt_idx += pkt_num;\n+\t\t\t\tremained -= pkt_num;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t}\n \n-\t\tVHOST_LOG_DEBUG(VHOST_DATA, \"(%d) current index %d | end index %d\\n\",\n-\t\t\tdev->vid, vq->last_avail_idx,\n-\t\t\tvq->last_avail_idx + num_buffers);\n+\t\tpkt_num = virtio_dev_rx_single_packed(dev, vq, pkts[pkt_idx]);\n \n-\t\tif (copy_mbuf_to_desc(dev, vq, pkts[pkt_idx],\n-\t\t\t\t\t\tbuf_vec, nr_vec,\n-\t\t\t\t\t\tnum_buffers) < 0) {\n-\t\t\tvq->shadow_used_idx -= num_buffers;\n+\t\tif (pkt_num == 0)\n \t\t\tbreak;\n-\t\t}\n \n-\t\tvq->last_avail_idx += nr_descs;\n-\t\tif (vq->last_avail_idx >= vq->size) {\n-\t\t\tvq->last_avail_idx -= vq->size;\n-\t\t\tvq->avail_wrap_counter ^= 1;\n-\t\t}\n-\t}\n+\t\tpkt_idx += pkt_num;\n+\t\tremained -= pkt_num;\n \n-\tdo_data_copy_enqueue(dev, vq);\n+\t} while (pkt_idx < count);\n+\n+\tif (pkt_idx) {\n+\t\tif (vq->shadow_used_idx) {\n+\t\t\tdo_data_copy_enqueue(dev, vq);\n+\t\t\tflush_enqueue_shadow_packed(dev, vq);\n+\t\t}\n \n-\tif (likely(vq->shadow_used_idx)) {\n-\t\tflush_enqueue_shadow_packed(dev, vq);\n \t\tvhost_vring_call_packed(dev, vq);\n \t}\n \n",
    "prefixes": [
        "v1",
        "10/14"
    ]
}