Show a patch.

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

{
    "id": 43326,
    "url": "http://patches.dpdk.org/api/patches/43326/",
    "web_url": "http://patches.dpdk.org/patch/43326/",
    "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": "<20180724210853.22767-5-stephen@networkplumber.org>",
    "date": "2018-07-24T21:08:53",
    "name": "[4/4] netvsc/vmbus: avoid signalling host on read",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "67249f40ea8b381ec7f878fc258a7404fef22443",
    "submitter": {
        "id": 27,
        "url": "http://patches.dpdk.org/api/people/27/",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@intel.com"
    },
    "mbox": "http://patches.dpdk.org/patch/43326/mbox/",
    "series": [
        {
            "id": 748,
            "url": "http://patches.dpdk.org/api/series/748/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=748",
            "date": "2018-07-24T21:08:49",
            "name": "netvsc PMD performance fixes",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/748/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/43326/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/43326/checks/",
    "tags": {},
    "headers": {
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "To": "dev@dpdk.org",
        "X-Google-Smtp-Source": "AAOMgpd+iA30u/hhN2O4/TlsVons6cFJGLFJXSJHtXB6qK9YFB0FckJ292Ju9ZkKvL+toCF/44y/FQ==",
        "Message-Id": "<20180724210853.22767-5-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.18.0",
        "X-Gm-Message-State": "AOUpUlFj0QGWEvTTriXwy1za09gfXseWkZiR450qdx+Yzl3ggZoxhnwW\n\tPIJIaFMXkDtTqZhuwx0jbi+WE/QcVbs=",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=networkplumber-org.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=HaoleF6LEwfv/RUyTJXu/pNeriaeB4qgaJoPjlofCcY=;\n\tb=IMy+pQXKwlm+HJfMpxX1HrwbyaUpnD4B41BdNQoahnsehZsWzXDDRD01ybSHHiEYfM\n\t7KNQr6W5jvt3NkoVNx7PGKIfjfS5IMuPxhXAUotYB8GFwEy/BagEI3iziuoUKlimnLR8\n\tn915SvBanMoBDt2A3T1Ctm5B75KTfVrPoKsW2rzK4NoaEjRLSITZjANLoRYJBwAU7mB7\n\tpDWp6cYnx9zLufR5+TGyMxxQx554iturCDMUFS4sGIvt683MWo3RBvZcgMlAFeRDCAW5\n\telHIiw7vkPZgjdB+KmuHy738hWiBfdAtlXIzE0EEqknMJMSCtgjlu0GL75w89j+x99HE\n\th3Og==",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-BeenThere": "dev@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 554A2378B;\n\tTue, 24 Jul 2018 23:09:15 +0200 (CEST)",
            "from mail-pg1-f193.google.com (mail-pg1-f193.google.com\n\t[209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 536B431FC\n\tfor <dev@dpdk.org>; Tue, 24 Jul 2018 23:09:08 +0200 (CEST)",
            "by mail-pg1-f193.google.com with SMTP id y5-v6so3738683pgv.1\n\tfor <dev@dpdk.org>; Tue, 24 Jul 2018 14:09:08 -0700 (PDT)",
            "from xeon-e3.wavecable.com (204-195-22-127.wavecable.com.\n\t[204.195.22.127]) by smtp.gmail.com with ESMTPSA id\n\td11-v6sm16921161pfo.135.2018.07.24.14.09.05\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 24 Jul 2018 14:09:06 -0700 (PDT)"
        ],
        "Subject": "[dpdk-dev] [PATCH 4/4] netvsc/vmbus: avoid signalling host on read",
        "In-Reply-To": "<20180724210853.22767-1-stephen@networkplumber.org>",
        "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-Post": "<mailto:dev@dpdk.org>",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n\tStephen Hemminger <sthemmin@microsoft.com>",
        "Precedence": "list",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "X-Received": "by 2002:a63:2dc1:: with SMTP id\n\tt184-v6mr17756291pgt.62.1532466547106; \n\tTue, 24 Jul 2018 14:09:07 -0700 (PDT)",
        "References": "<20180724210853.22767-1-stephen@networkplumber.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Errors-To": "dev-bounces@dpdk.org",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Delivered-To": "patchwork@dpdk.org",
        "Date": "Tue, 24 Jul 2018 14:08:53 -0700",
        "X-Mailman-Version": "2.1.15",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=HaoleF6LEwfv/RUyTJXu/pNeriaeB4qgaJoPjlofCcY=;\n\tb=pLCnw8i+a+2dUFo7Pmhfjr6kjUzAoyCsRN2eZK3GuaEbqthp0Xgia3oBeNBf0Mp5XQ\n\tpDOrz4jHOOd7CzOiDKT42MgYdW2PZx7TqpiSNgfxFbsuqYyhgjjI4vs8rfSLdy66j9Ci\n\t5OeoGTaQyq27DRC5tmlKURxXx/IwEMfwo+27bvC45BOlE5rUUtDdFCIKzozNbfWoapZt\n\tGBQiUiKX+0uoWeEn9BVpI/NZFTzcqQhNDEHJKUnk6Onlwb0dw1D3OWwEB6pSjDVlTHAy\n\tHXR7dw3FrsLMEsI1cEcaPBX5R4UGcyjgG/DfbdFQdineCxz2seXOi1LJSJlnkF/GjcrK\n\toZug=="
    },
    "content": "Don't signal host that receive ring has been read until all events\nhave been processed. This reduces the number of guest exits and\ntherefore improves performance.\n\nSigned-off-by: Stephen Hemminger <sthemmin@microsoft.com>\n---\n drivers/bus/vmbus/rte_bus_vmbus.h           | 13 +++++-\n drivers/bus/vmbus/rte_bus_vmbus_version.map |  1 +\n drivers/bus/vmbus/vmbus_bufring.c           |  3 ++\n drivers/bus/vmbus/vmbus_channel.c           | 45 +++++++++----------\n drivers/net/netvsc/hn_rxtx.c                | 49 +++++++--------------\n drivers/net/netvsc/hn_var.h                 |  3 +-\n 6 files changed, 56 insertions(+), 58 deletions(-)",
    "diff": "diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h\nindex 0100f80ff9a0..4a2c1f6fd918 100644\n--- a/drivers/bus/vmbus/rte_bus_vmbus.h\n+++ b/drivers/bus/vmbus/rte_bus_vmbus.h\n@@ -337,12 +337,23 @@ int rte_vmbus_chan_recv(struct vmbus_channel *chan,\n  * @param len\n  *\tPointer to size of receive buffer (in/out)\n  * @return\n- *   On success, returns 0\n+ *   On success, returns number of bytes read.\n  *   On failure, returns negative errno.\n  */\n int rte_vmbus_chan_recv_raw(struct vmbus_channel *chan,\n \t\t\t    void *data, uint32_t *len);\n \n+/**\n+ * Notify host of bytes read (after recv_raw)\n+ * Signals host if required.\n+ *\n+ * @param channel\n+ *\tPointer to vmbus_channel structure.\n+ * @param bytes_read\n+ *\tNumber of bytes read since last signal\n+ */\n+void rte_vmbus_chan_signal_read(struct vmbus_channel *chan, uint32_t bytes_read);\n+\n /**\n  * Determine sub channel index of the given channel\n  *\ndiff --git a/drivers/bus/vmbus/rte_bus_vmbus_version.map b/drivers/bus/vmbus/rte_bus_vmbus_version.map\nindex 5324fef4662c..dabb9203104b 100644\n--- a/drivers/bus/vmbus/rte_bus_vmbus_version.map\n+++ b/drivers/bus/vmbus/rte_bus_vmbus_version.map\n@@ -10,6 +10,7 @@ DPDK_18.08 {\n \trte_vmbus_chan_rx_empty;\n \trte_vmbus_chan_send;\n \trte_vmbus_chan_send_sglist;\n+\trte_vmbus_chan_signal_read;\n \trte_vmbus_chan_signal_tx;\n \trte_vmbus_irq_mask;\n \trte_vmbus_irq_read;\ndiff --git a/drivers/bus/vmbus/vmbus_bufring.c b/drivers/bus/vmbus/vmbus_bufring.c\nindex c2d7d8cc2254..c88001605dbb 100644\n--- a/drivers/bus/vmbus/vmbus_bufring.c\n+++ b/drivers/bus/vmbus/vmbus_bufring.c\n@@ -221,6 +221,9 @@ vmbus_rxbr_read(struct vmbus_br *rbr, void *data, size_t dlen, size_t skip)\n \tif (vmbus_br_availread(rbr) < dlen + skip + sizeof(uint64_t))\n \t\treturn -EAGAIN;\n \n+\t/* Record where host was when we started read (for debug) */\n+\trbr->windex = rbr->vbr->windex;\n+\n \t/*\n \t * Copy channel packet from RX bufring.\n \t */\ndiff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_channel.c\nindex f9feada9b047..cc5f3e8379a5 100644\n--- a/drivers/bus/vmbus/vmbus_channel.c\n+++ b/drivers/bus/vmbus/vmbus_channel.c\n@@ -176,49 +176,37 @@ bool rte_vmbus_chan_rx_empty(const struct vmbus_channel *channel)\n \treturn br->vbr->rindex == br->vbr->windex;\n }\n \n-static int vmbus_read_and_signal(struct vmbus_channel *chan,\n-\t\t\t\t void *data, size_t dlen, size_t skip)\n+/* Signal host after reading N bytes */\n+void rte_vmbus_chan_signal_read(struct vmbus_channel *chan, uint32_t bytes_read)\n {\n \tstruct vmbus_br *rbr = &chan->rxbr;\n-\tuint32_t write_sz, pending_sz, bytes_read;\n-\tint error;\n-\n-\t/* Record where host was when we started read (for debug) */\n-\trbr->windex = rbr->vbr->windex;\n-\n-\t/* Read data and skip packet header */\n-\terror = vmbus_rxbr_read(rbr, data, dlen, skip);\n-\tif (error)\n-\t\treturn error;\n+\tuint32_t write_sz, pending_sz;\n \n \t/* No need for signaling on older versions */\n \tif (!rbr->vbr->feature_bits.feat_pending_send_sz)\n-\t\treturn 0;\n+\t\treturn;\n \n \t/* Make sure reading of pending happens after new read index */\n \trte_mb();\n \n \tpending_sz = rbr->vbr->pending_send;\n \tif (!pending_sz)\n-\t\treturn 0;\n+\t\treturn;\n \n \trte_smp_rmb();\n \twrite_sz = vmbus_br_availwrite(rbr, rbr->vbr->windex);\n-\tbytes_read = dlen + skip + sizeof(uint64_t);\n \n \t/* If there was space before then host was not blocked */\n \tif (write_sz - bytes_read > pending_sz)\n-\t\treturn 0;\n+\t\treturn;\n \n \t/* If pending write will not fit */\n \tif (write_sz <= pending_sz)\n-\t\treturn 0;\n+\t\treturn;\n \n \tvmbus_set_event(chan->device, chan);\n-\treturn 0;\n }\n \n-/* TODO: replace this with inplace ring buffer (no copy) */\n int rte_vmbus_chan_recv(struct vmbus_channel *chan, void *data, uint32_t *len,\n \t\t\tuint64_t *request_id)\n {\n@@ -256,10 +244,16 @@ int rte_vmbus_chan_recv(struct vmbus_channel *chan, void *data, uint32_t *len,\n \tif (request_id)\n \t\t*request_id = pkt.xactid;\n \n-\t/* Read data and skip the header */\n-\treturn vmbus_read_and_signal(chan, data, dlen, hlen);\n+\t/* Read data and skip packet header */\n+\terror = vmbus_rxbr_read(&chan->rxbr, data, dlen, hlen);\n+\tif (error)\n+\t\treturn error;\n+\n+\trte_vmbus_chan_signal_read(chan, dlen + hlen + sizeof(uint64_t));\n+\treturn 0;\n }\n \n+/* TODO: replace this with inplace ring buffer (no copy) */\n int rte_vmbus_chan_recv_raw(struct vmbus_channel *chan,\n \t\t\t    void *data, uint32_t *len)\n {\n@@ -291,8 +285,13 @@ int rte_vmbus_chan_recv_raw(struct vmbus_channel *chan,\n \tif (unlikely(dlen > bufferlen))\n \t\treturn -ENOBUFS;\n \n-\t/* Put packet header in data buffer */\n-\treturn vmbus_read_and_signal(chan, data, dlen, 0);\n+\t/* Read data and skip packet header */\n+\terror = vmbus_rxbr_read(&chan->rxbr, data, dlen, 0);\n+\tif (error)\n+\t\treturn error;\n+\n+\t/* Return the number of bytes read */\n+\treturn dlen + sizeof(uint64_t);\n }\n \n int vmbus_chan_create(const struct rte_vmbus_device *device,\ndiff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c\nindex 17cebeb74456..38c1612a6ac6 100644\n--- a/drivers/net/netvsc/hn_rxtx.c\n+++ b/drivers/net/netvsc/hn_rxtx.c\n@@ -40,7 +40,7 @@\n #define HN_TXCOPY_THRESHOLD\t512\n \n #define HN_RXCOPY_THRESHOLD\t256\n-#define HN_RXQ_EVENT_DEFAULT\t1024\n+#define HN_RXQ_EVENT_DEFAULT\t2048\n \n struct hn_rxinfo {\n \tuint32_t\tvlan_info;\n@@ -709,7 +709,8 @@ struct hn_rx_queue *hn_rx_queue_alloc(struct hn_data *hv,\n {\n \tstruct hn_rx_queue *rxq;\n \n-\trxq = rte_zmalloc_socket(\"HN_RXQ\", sizeof(*rxq),\n+\trxq = rte_zmalloc_socket(\"HN_RXQ\",\n+\t\t\t\t sizeof(*rxq) + HN_RXQ_EVENT_DEFAULT,\n \t\t\t\t RTE_CACHE_LINE_SIZE, socket_id);\n \tif (rxq) {\n \t\trxq->hv = hv;\n@@ -717,16 +718,6 @@ struct hn_rx_queue *hn_rx_queue_alloc(struct hn_data *hv,\n \t\trte_spinlock_init(&rxq->ring_lock);\n \t\trxq->port_id = hv->port_id;\n \t\trxq->queue_id = queue_id;\n-\n-\t\trxq->event_sz = HN_RXQ_EVENT_DEFAULT;\n-\t\trxq->event_buf = rte_malloc_socket(\"RX_EVENTS\",\n-\t\t\t\t\t\t   rxq->event_sz,\n-\t\t\t\t\t\t   RTE_CACHE_LINE_SIZE,\n-\t\t\t\t\t\t   socket_id);\n-\t\tif (!rxq->event_buf) {\n-\t\t\trte_free(rxq);\n-\t\t\trxq = NULL;\n-\t\t}\n \t}\n \treturn rxq;\n }\n@@ -835,6 +826,7 @@ void hn_process_events(struct hn_data *hv, uint16_t queue_id)\n {\n \tstruct rte_eth_dev *dev = &rte_eth_devices[hv->port_id];\n \tstruct hn_rx_queue *rxq;\n+\tuint32_t bytes_read = 0;\n \tint ret = 0;\n \n \trxq = queue_id == 0 ? hv->primary : dev->data->rx_queues[queue_id];\n@@ -852,34 +844,21 @@ void hn_process_events(struct hn_data *hv, uint16_t queue_id)\n \n \tfor (;;) {\n \t\tconst struct vmbus_chanpkt_hdr *pkt;\n-\t\tuint32_t len = rxq->event_sz;\n+\t\tuint32_t len = HN_RXQ_EVENT_DEFAULT;\n \t\tconst void *data;\n \n \t\tret = rte_vmbus_chan_recv_raw(rxq->chan, rxq->event_buf, &len);\n \t\tif (ret == -EAGAIN)\n \t\t\tbreak;\t/* ring is empty */\n \n-\t\tif (ret == -ENOBUFS) {\n-\t\t\t/* expanded buffer needed */\n-\t\t\tlen = rte_align32pow2(len);\n-\t\t\tPMD_DRV_LOG(DEBUG, \"expand event buf to %u\", len);\n-\n-\t\t\trxq->event_buf = rte_realloc(rxq->event_buf,\n-\t\t\t\t\t\t     len, RTE_CACHE_LINE_SIZE);\n-\t\t\tif (rxq->event_buf) {\n-\t\t\t\trxq->event_sz = len;\n-\t\t\t\tcontinue;\n-\t\t\t}\n-\n-\t\t\trte_exit(EXIT_FAILURE, \"can not expand event buf!\\n\");\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\tif (ret != 0) {\n-\t\t\tPMD_DRV_LOG(ERR, \"vmbus ring buffer error: %d\", ret);\n-\t\t\tbreak;\n-\t\t}\n+\t\telse if (ret == -ENOBUFS)\n+\t\t\trte_exit(EXIT_FAILURE, \"event buffer not big enough (%u < %u)\",\n+\t\t\t\t HN_RXQ_EVENT_DEFAULT, len);\n+\t\telse if (ret <= 0)\n+\t\t\trte_exit(EXIT_FAILURE,\n+\t\t\t\t \"vmbus ring buffer error: %d\", ret);\n \n+\t\tbytes_read += ret;\n \t\tpkt = (const struct vmbus_chanpkt_hdr *)rxq->event_buf;\n \t\tdata = (char *)rxq->event_buf + vmbus_chanpkt_getlen(pkt->hlen);\n \n@@ -904,6 +883,10 @@ void hn_process_events(struct hn_data *hv, uint16_t queue_id)\n \t\tif (rxq->rx_ring && rte_ring_full(rxq->rx_ring))\n \t\t\tbreak;\n \t}\n+\n+\tif (bytes_read > 0)\n+\t\trte_vmbus_chan_signal_read(rxq->chan, bytes_read);\n+\n \trte_spinlock_unlock(&rxq->ring_lock);\n }\n \ndiff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h\nindex 3f3b442697af..f7ff8585bc1c 100644\n--- a/drivers/net/netvsc/hn_var.h\n+++ b/drivers/net/netvsc/hn_var.h\n@@ -69,7 +69,6 @@ struct hn_rx_queue {\n \tstruct vmbus_channel *chan;\n \tstruct rte_mempool *mb_pool;\n \tstruct rte_ring *rx_ring;\n-\tvoid\t*event_buf;\n \n \trte_spinlock_t ring_lock;\n \tuint32_t event_sz;\n@@ -77,6 +76,8 @@ struct hn_rx_queue {\n \tuint16_t queue_id;\n \tstruct hn_stats stats;\n \tuint64_t ring_full;\n+\n+\tuint8_t\tevent_buf[];\n };\n \n \n",
    "prefixes": [
        "4/4"
    ]
}