Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/21602/?format=api
https://patches.dpdk.org/api/patches/21602/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1488966121-22853-4-git-send-email-olivier.matz@6wind.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": "<1488966121-22853-4-git-send-email-olivier.matz@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1488966121-22853-4-git-send-email-olivier.matz@6wind.com", "date": "2017-03-08T09:41:55", "name": "[dpdk-dev,3/9] mbuf: set mbuf fields while in pool", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "889ee5a8f6f9ee451661b080095a8cfbba938d80", "submitter": { "id": 8, "url": "https://patches.dpdk.org/api/people/8/?format=api", "name": "Olivier Matz", "email": "olivier.matz@6wind.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/1488966121-22853-4-git-send-email-olivier.matz@6wind.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/21602/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/21602/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id A29E5BD28;\n\tWed, 8 Mar 2017 10:42:54 +0100 (CET)", "from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com\n\t[62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 7327D5589\n\tfor <dev@dpdk.org>; Wed, 8 Mar 2017 10:42:23 +0100 (CET)", "from glumotte.dev.6wind.com (unknown [10.16.0.195])\n\tby proxy.6wind.com (Postfix) with ESMTP id C8AD124D1D;\n\tWed, 8 Mar 2017 10:42:17 +0100 (CET)" ], "From": "Olivier Matz <olivier.matz@6wind.com>", "To": "dev@dpdk.org", "Cc": "bruce.richardson@intel.com, konstantin.ananyev@intel.com,\n\tmb@smartsharesystems.com, andrey.chilikin@intel.com,\n\tjblunck@infradead.org, \n\tnelio.laranjeiro@6wind.com, arybchenko@solarflare.com", "Date": "Wed, 8 Mar 2017 10:41:55 +0100", "Message-Id": "<1488966121-22853-4-git-send-email-olivier.matz@6wind.com>", "X-Mailer": "git-send-email 2.8.1", "In-Reply-To": "<1488966121-22853-1-git-send-email-olivier.matz@6wind.com>", "References": "<1485271173-13408-1-git-send-email-olivier.matz@6wind.com>\n\t<1488966121-22853-1-git-send-email-olivier.matz@6wind.com>", "Subject": "[dpdk-dev] [PATCH 3/9] mbuf: set mbuf fields while in pool", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<http://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": "<http://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": "Set the value of m->refcnt to 1, m->nb_segs to 1 and m->next\nto NULL when the mbuf is stored inside the mempool (unused).\nThis is done in rte_pktmbuf_prefree_seg(), before freeing or\nrecycling a mbuf.\n\nBefore this patch, the value of m->refcnt was expected to be 0\nwhile in pool.\n\nThe objectives are:\n\n- to avoid drivers to set m->next to NULL in the early Rx path, since\n this field is in the second 64B of the mbuf and its access could\n trigger a cache miss\n\n- rationalize the behavior of raw_alloc/raw_free: one is now the\n symmetric of the other, and refcnt is never changed in these functions.\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\n---\n drivers/net/mlx5/mlx5_rxtx.c | 5 ++---\n drivers/net/mpipe/mpipe_tilegx.c | 1 +\n lib/librte_mbuf/rte_mbuf.c | 2 ++\n lib/librte_mbuf/rte_mbuf.h | 42 +++++++++++++++++++++++++++++-----------\n 4 files changed, 36 insertions(+), 14 deletions(-)", "diff": "diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c\nindex 41a5bb2..fc59544 100644\n--- a/drivers/net/mlx5/mlx5_rxtx.c\n+++ b/drivers/net/mlx5/mlx5_rxtx.c\n@@ -1398,7 +1398,8 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)\n \t\t\twhile (pkt != seg) {\n \t\t\t\tassert(pkt != (*rxq->elts)[idx]);\n \t\t\t\trep = NEXT(pkt);\n-\t\t\t\trte_mbuf_refcnt_set(pkt, 0);\n+\t\t\t\tNEXT(pkt) = NULL;\n+\t\t\t\tNB_SEGS(pkt) = 1;\n \t\t\t\trte_mbuf_raw_free(pkt);\n \t\t\t\tpkt = rep;\n \t\t\t}\n@@ -1409,13 +1410,11 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)\n \t\t\tlen = mlx5_rx_poll_len(rxq, cqe, cqe_cnt,\n \t\t\t\t\t &rss_hash_res);\n \t\t\tif (!len) {\n-\t\t\t\trte_mbuf_refcnt_set(rep, 0);\n \t\t\t\trte_mbuf_raw_free(rep);\n \t\t\t\tbreak;\n \t\t\t}\n \t\t\tif (unlikely(len == -1)) {\n \t\t\t\t/* RX error, packet is likely too large. */\n-\t\t\t\trte_mbuf_refcnt_set(rep, 0);\n \t\t\t\trte_mbuf_raw_free(rep);\n \t\t\t\t++rxq->stats.idropped;\n \t\t\t\tgoto skip;\ndiff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c\nindex 536b8ea..0135e2f 100644\n--- a/drivers/net/mpipe/mpipe_tilegx.c\n+++ b/drivers/net/mpipe/mpipe_tilegx.c\n@@ -557,6 +557,7 @@ mpipe_recv_flush_stack(struct mpipe_dev_priv *priv)\n \t\tmbuf->packet_type = 0;\n \t\tmbuf->data_len = 0;\n \t\tmbuf->pkt_len = 0;\n+\t\tmbuf->next = NULL;\n \n \t\trte_mbuf_raw_free(mbuf);\n \t}\ndiff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex 72ad91e..0acc810 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -145,6 +145,8 @@ rte_pktmbuf_init(struct rte_mempool *mp,\n \tm->pool = mp;\n \tm->nb_segs = 1;\n \tm->port = 0xff;\n+\trte_mbuf_refcnt_set(m, 1);\n+\tm->next = NULL;\n }\n \n /* helper to create a mbuf pool */\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 575dc9d..b4fe786 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -768,6 +768,11 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header);\n * initializing all the required fields. See rte_pktmbuf_reset().\n * For standard needs, prefer rte_pktmbuf_alloc().\n *\n+ * The caller can expect that the following fields of the mbuf structure\n+ * are initialized: buf_addr, buf_physaddr, buf_len, refcnt=1, nb_segs=1,\n+ * next=NULL, pool, priv_size. The other fields must be initialized\n+ * by the caller.\n+ *\n * @param mp\n * The mempool from which mbuf is allocated.\n * @return\n@@ -782,8 +787,9 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp)\n \tif (rte_mempool_get(mp, &mb) < 0)\n \t\treturn NULL;\n \tm = (struct rte_mbuf *)mb;\n-\tRTE_ASSERT(rte_mbuf_refcnt_read(m) == 0);\n-\trte_mbuf_refcnt_set(m, 1);\n+\tRTE_ASSERT(rte_mbuf_refcnt_read(m) == 1);\n+\tRTE_ASSERT(m->next == NULL);\n+\tRTE_ASSERT(m->nb_segs == 1);\n \t__rte_mbuf_sanity_check(m, 0);\n \n \treturn m;\n@@ -792,8 +798,13 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp)\n /**\n * Put mbuf back into its original mempool.\n *\n- * The caller must ensure that the mbuf is direct and that the\n- * reference counter is 0.\n+ * The caller must ensure that the mbuf is direct and properly\n+ * reinitialized (refcnt=1, next=NULL, nb_segs=1), as done by\n+ * rte_pktmbuf_prefree_seg().\n+ *\n+ * This function should be used with care, when optimization is\n+ * required. For standard needs, prefer rte_pktmbuf_free() or\n+ * rte_pktmbuf_free_seg().\n *\n * @param m\n * The mbuf to be freed.\n@@ -802,13 +813,16 @@ static inline void __attribute__((always_inline))\n rte_mbuf_raw_free(struct rte_mbuf *m)\n {\n \tRTE_ASSERT(RTE_MBUF_DIRECT(m));\n-\tRTE_ASSERT(rte_mbuf_refcnt_read(m) == 0);\n+\tRTE_ASSERT(rte_mbuf_refcnt_read(m) == 1);\n+\tRTE_ASSERT(m->next == NULL);\n+\tRTE_ASSERT(m->nb_segs == 1);\n+\t__rte_mbuf_sanity_check(m, 0);\n \trte_mempool_put(m->pool, m);\n }\n \n /* compat with older versions */\n __rte_deprecated\n-static inline void __attribute__((always_inline))\n+static inline void\n __rte_mbuf_raw_free(struct rte_mbuf *m)\n {\n \trte_mbuf_raw_free(m);\n@@ -1219,8 +1233,12 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m)\n \tm->data_len = 0;\n \tm->ol_flags = 0;\n \n-\tif (rte_mbuf_refcnt_update(md, -1) == 0)\n+\tif (rte_mbuf_refcnt_update(md, -1) == 0) {\n+\t\tmd->next = NULL;\n+\t\tmd->nb_segs = 1;\n+\t\trte_mbuf_refcnt_set(md, 1);\n \t\trte_mbuf_raw_free(md);\n+\t}\n }\n \n /**\n@@ -1244,9 +1262,13 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)\n \t__rte_mbuf_sanity_check(m, 0);\n \n \tif (likely(rte_mbuf_refcnt_update(m, -1) == 0)) {\n-\t\t/* if this is an indirect mbuf, it is detached. */\n \t\tif (RTE_MBUF_INDIRECT(m))\n \t\t\trte_pktmbuf_detach(m);\n+\n+\t\tm->next = NULL;\n+\t\tm->nb_segs = 1;\n+\t\trte_mbuf_refcnt_set(m, 1);\n+\n \t\treturn m;\n \t}\n \treturn NULL;\n@@ -1273,10 +1295,8 @@ static inline void __attribute__((always_inline))\n rte_pktmbuf_free_seg(struct rte_mbuf *m)\n {\n \tm = rte_pktmbuf_prefree_seg(m);\n-\tif (likely(m != NULL)) {\n-\t\tm->next = NULL;\n+\tif (likely(m != NULL))\n \t\trte_mbuf_raw_free(m);\n-\t}\n }\n \n /**\n", "prefixes": [ "dpdk-dev", "3/9" ] }{ "id": 21602, "url": "