Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/53426/?format=api
http://patches.dpdk.org/api/patches/53426/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190515083842.15116-4-xiaolong.ye@intel.com/", "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": "<20190515083842.15116-4-xiaolong.ye@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20190515083842.15116-4-xiaolong.ye@intel.com", "date": "2019-05-15T08:38:42", "name": "[v1,3/3] net/af_xdp: add busy poll support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "757e0b1415c1db89ac0400fe74a19c0b148c265d", "submitter": { "id": 1120, "url": "http://patches.dpdk.org/api/people/1120/?format=api", "name": "Xiaolong Ye", "email": "xiaolong.ye@intel.com" }, "delegate": { "id": 319, "url": "http://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190515083842.15116-4-xiaolong.ye@intel.com/mbox/", "series": [ { "id": 4663, "url": "http://patches.dpdk.org/api/series/4663/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4663", "date": "2019-05-15T08:38:39", "name": "add more features for AF_XDP pmd", "version": 1, "mbox": "http://patches.dpdk.org/series/4663/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/53426/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/53426/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 AD9435F2B;\n\tWed, 15 May 2019 10:49:53 +0200 (CEST)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id 02B685F1B\n\tfor <dev@dpdk.org>; Wed, 15 May 2019 10:49:50 +0200 (CEST)", "from fmsmga008.fm.intel.com ([10.253.24.58])\n\tby orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t15 May 2019 01:49:50 -0700", "from yexl-server.sh.intel.com (HELO\n\tNPG-DPDK-XDP-yexl-server.sh.intel.com) ([10.67.110.206])\n\tby fmsmga008.fm.intel.com with ESMTP; 15 May 2019 01:49:49 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "From": "Xiaolong Ye <xiaolong.ye@intel.com>", "To": "Xiaolong Ye <xiaolong.ye@intel.com>, Qi Zhang <qi.z.zhang@intel.com>,\n\tJohn McNamara <john.mcnamara@intel.com>,\n\tMarko Kovacevic <marko.kovacevic@intel.com>", "Cc": "Karlsson Magnus <magnus.karlsson@intel.com>,\n\tTopel Bjorn <bjorn.topel@intel.com>, dev@dpdk.org", "Date": "Wed, 15 May 2019 16:38:42 +0800", "Message-Id": "<20190515083842.15116-4-xiaolong.ye@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20190515083842.15116-1-xiaolong.ye@intel.com>", "References": "<20190515083842.15116-1-xiaolong.ye@intel.com>", "Subject": "[dpdk-dev] [PATCH v1 3/3] net/af_xdp: add busy poll support", "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": "This patch enables busy-poll support for AF_XDP pmd. With busy-poll, the\nkernel driver is executed in process context by calling the poll() syscall.\n\nThe main advantage of busy-poll feature is that all processing occurs on a\nsingle core. This eliminates the core-to-core cache transfers that occur\nbetween the application and the softirqd processing on another core.\n\nThe drawback of busy-poll is that it will downgrade the max throughput due\nto syscall, but from a per-core perspective, the performance is better as\nnormal mode runs on two cores and busy-poll only runs on a single core.\n\nSigned-off-by: Xiaolong Ye <xiaolong.ye@intel.com>\n---\n doc/guides/nics/af_xdp.rst | 1 +\n drivers/net/af_xdp/rte_eth_af_xdp.c | 48 ++++++++++++++++++++++++++---\n 2 files changed, 45 insertions(+), 4 deletions(-)", "diff": "diff --git a/doc/guides/nics/af_xdp.rst b/doc/guides/nics/af_xdp.rst\nindex 18defcda3..e42065170 100644\n--- a/doc/guides/nics/af_xdp.rst\n+++ b/doc/guides/nics/af_xdp.rst\n@@ -29,6 +29,7 @@ The following options can be provided to set up an af_xdp port in DPDK.\n * ``iface`` - name of the Kernel interface to attach to (required);\n * ``start_queue`` - starting netdev queue id (optional, default 0);\n * ``queue_count`` - total netdev queue number (optional, default 1);\n+* ``busy_poll_size`` - busy poll batch size (optional, default 0);\n * ``pmd_zero_copy`` - enable zero copy or not (optional, default 0);\n \n Prerequisites\ndiff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c\nindex 9a4510701..1e46a4ef4 100644\n--- a/drivers/net/af_xdp/rte_eth_af_xdp.c\n+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c\n@@ -6,6 +6,7 @@\n #include <stdlib.h>\n #include <string.h>\n #include <netinet/in.h>\n+#include <poll.h>\n #include <net/if.h>\n #include <sys/socket.h>\n #include <sys/ioctl.h>\n@@ -72,6 +73,7 @@ struct xsk_umem_info {\n \tstruct rte_ring *buf_ring;\n \tconst struct rte_memzone *mz;\n \tint pmd_zc;\n+\tint busy_poll;\n };\n \n struct rx_stats {\n@@ -114,6 +116,7 @@ struct pmd_internals {\n \tint queue_cnt;\n \n \tint pmd_zc;\n+\tint busy_poll_size;\n \tstruct ether_addr eth_addr;\n \tstruct xsk_umem_info *umem;\n \tstruct rte_mempool *mb_pool_share;\n@@ -126,12 +129,14 @@ struct pmd_internals {\n #define ETH_AF_XDP_START_QUEUE_ARG\t\t\"start_queue\"\n #define ETH_AF_XDP_QUEUE_COUNT_ARG\t\t\"queue_count\"\n #define ETH_AF_XDP_PMD_ZC_ARG\t\t\t\"pmd_zero_copy\"\n+#define ETH_AF_XDP_BUSY_POLL_SIZE_ARG\t\t\"busy_poll_size\"\n \n static const char * const valid_arguments[] = {\n \tETH_AF_XDP_IFACE_ARG,\n \tETH_AF_XDP_START_QUEUE_ARG,\n \tETH_AF_XDP_QUEUE_COUNT_ARG,\n \tETH_AF_XDP_PMD_ZC_ARG,\n+\tETH_AF_XDP_BUSY_POLL_SIZE_ARG,\n \tNULL\n };\n \n@@ -191,6 +196,7 @@ eth_af_xdp_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \tstruct xsk_ring_cons *rx = &rxq->rx;\n \tstruct xsk_umem_info *umem = rxq->umem;\n \tstruct xsk_ring_prod *fq = &umem->fq;\n+\tstruct pollfd pfds[1];\n \tuint32_t idx_rx = 0;\n \tuint32_t free_thresh = fq->size >> 1;\n \tint pmd_zc = umem->pmd_zc;\n@@ -199,6 +205,15 @@ eth_af_xdp_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \tunsigned long rx_bytes = 0;\n \tint rcvd, i;\n \n+\tif (umem->busy_poll) {\n+\t\tmemset(pfds, 0, sizeof(pfds));\n+\t\tpfds[0].fd = xsk_socket__fd(rxq->xsk);\n+\t\tpfds[0].events = POLLIN;\n+\n+\t\tif (poll(pfds, 1, 0) <= 0)\n+\t\t\treturn 0;\n+\t}\n+\n \tnb_pkts = RTE_MIN(nb_pkts, ETH_AF_XDP_RX_BATCH_SIZE);\n \n \tif (unlikely(rte_pktmbuf_alloc_bulk(rxq->mb_pool, mbufs, nb_pkts) != 0))\n@@ -305,12 +320,23 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n \tstruct pkt_tx_queue *txq = queue;\n \tstruct xsk_umem_info *umem = txq->pair->umem;\n \tstruct rte_mbuf *mbuf;\n+\tstruct pollfd pfds[1];\n \tint pmd_zc = umem->pmd_zc;\n \tvoid *addrs[ETH_AF_XDP_TX_BATCH_SIZE];\n \tunsigned long tx_bytes = 0;\n \tint i;\n \tuint32_t idx_tx;\n \n+\tif (umem->busy_poll) {\n+\t\tmemset(pfds, 0, sizeof(pfds));\n+\t\tpfds[0].fd = xsk_socket__fd(txq->pair->xsk);\n+\t\tpfds[0].events = POLLOUT;\n+\t\tif (poll(pfds, 1, 0) <= 0)\n+\t\t\treturn 0;\n+\t\tif (!(pfds[0].revents & POLLOUT))\n+\t\t\treturn 0;\n+\t}\n+\n \tnb_pkts = RTE_MIN(nb_pkts, ETH_AF_XDP_TX_BATCH_SIZE);\n \n \tpull_umem_cq(umem, nb_pkts);\n@@ -615,6 +641,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,\n \tcfg.rx_size = ring_size;\n \tcfg.tx_size = ring_size;\n \tcfg.libbpf_flags = 0;\n+\tcfg.busy_poll = internals->busy_poll_size;\n \tcfg.xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST;\n \tcfg.bind_flags = 0;\n \tret = xsk_socket__create(&rxq->xsk, internals->if_name,\n@@ -680,10 +707,14 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,\n \n \tinternals->umem = rxq->umem;\n \tinternals->umem->pmd_zc = internals->pmd_zc;\n+\tinternals->umem->busy_poll = internals->busy_poll_size ? 1 : 0;\n \n \tif (internals->umem->pmd_zc)\n \t\tAF_XDP_LOG(INFO, \"Zero copy between umem and mbuf enabled.\\n\");\n \n+\tif (internals->umem->busy_poll)\n+\t\tAF_XDP_LOG(INFO, \"Busy poll enabled.\\n\");\n+\n \tdev->data->rx_queues[rx_queue_id] = rxq;\n \treturn 0;\n \n@@ -818,7 +849,7 @@ parse_name_arg(const char *key __rte_unused,\n \n static int\n parse_parameters(struct rte_kvargs *kvlist, char *if_name, int *start_queue,\n-\t\t\tint *queue_cnt, int *pmd_zc)\n+\t\t\tint *queue_cnt, int *pmd_zc, int *busy_poll_size)\n {\n \tint ret;\n \n@@ -844,6 +875,11 @@ parse_parameters(struct rte_kvargs *kvlist, char *if_name, int *start_queue,\n \tif (ret < 0)\n \t\tgoto free_kvlist;\n \n+\tret = rte_kvargs_process(kvlist, ETH_AF_XDP_BUSY_POLL_SIZE_ARG,\n+\t\t\t\t &parse_integer_arg, busy_poll_size);\n+\tif (ret < 0)\n+\t\tgoto free_kvlist;\n+\n free_kvlist:\n \trte_kvargs_free(kvlist);\n \treturn ret;\n@@ -881,7 +917,8 @@ get_iface_info(const char *if_name,\n \n static struct rte_eth_dev *\n init_internals(struct rte_vdev_device *dev, const char *if_name,\n-\t\t\tint start_queue_idx, int queue_cnt, int pmd_zc)\n+\t\t\tint start_queue_idx, int queue_cnt, int pmd_zc,\n+\t\t\t\tint busy_poll_size)\n {\n \tconst char *name = rte_vdev_device_name(dev);\n \tconst unsigned int numa_node = dev->device.numa_node;\n@@ -897,6 +934,7 @@ init_internals(struct rte_vdev_device *dev, const char *if_name,\n \tinternals->start_queue_idx = start_queue_idx;\n \tinternals->queue_cnt = queue_cnt;\n \tinternals->pmd_zc = pmd_zc;\n+\tinternals->busy_poll_size = busy_poll_size;\n \tstrlcpy(internals->if_name, if_name, IFNAMSIZ);\n \n \tfor (i = 0; i < queue_cnt; i++) {\n@@ -941,6 +979,7 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)\n \tstruct rte_eth_dev *eth_dev = NULL;\n \tconst char *name;\n \tint pmd_zc = 0;\n+\tint busy_poll_size = 0;\n \n \tAF_XDP_LOG(INFO, \"Initializing pmd_af_xdp for %s\\n\",\n \t\trte_vdev_device_name(dev));\n@@ -968,7 +1007,7 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)\n \t\tdev->device.numa_node = rte_socket_id();\n \n \tif (parse_parameters(kvlist, if_name, &xsk_start_queue_idx,\n-\t\t\t &xsk_queue_cnt, &pmd_zc) < 0) {\n+\t\t\t &xsk_queue_cnt, &pmd_zc, &busy_poll_size) < 0) {\n \t\tAF_XDP_LOG(ERR, \"Invalid kvargs value\\n\");\n \t\treturn -EINVAL;\n \t}\n@@ -979,7 +1018,7 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)\n \t}\n \n \teth_dev = init_internals(dev, if_name, xsk_start_queue_idx,\n-\t\t\t\t\txsk_queue_cnt, pmd_zc);\n+\t\t\t\t xsk_queue_cnt, pmd_zc, busy_poll_size);\n \tif (eth_dev == NULL) {\n \t\tAF_XDP_LOG(ERR, \"Failed to init internals\\n\");\n \t\treturn -1;\n@@ -1023,6 +1062,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_xdp,\n \t\t\t \"iface=<string> \"\n \t\t\t \"start_queue=<int> \"\n \t\t\t \"queue_count=<int> \"\n+\t\t\t \"busy_poll_size=<int> \"\n \t\t\t \"pmd_zero_copy=<0|1>\");\n \n RTE_INIT(af_xdp_init_log)\n", "prefixes": [ "v1", "3/3" ] }{ "id": 53426, "url": "