Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/86053/?format=api
http://patchwork.dpdk.org/api/patches/86053/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20210106133333.12528-1-olivier.matz@6wind.com/", "project": { "id": 1, "url": "http://patchwork.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": "<20210106133333.12528-1-olivier.matz@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20210106133333.12528-1-olivier.matz@6wind.com", "date": "2021-01-06T13:33:33", "name": "[v3] mbuf: fix reset on mbuf free", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "f39fb78dc96ea03024e4d54fa6a1696be16ce356", "submitter": { "id": 8, "url": "http://patchwork.dpdk.org/api/people/8/?format=api", "name": "Olivier Matz", "email": "olivier.matz@6wind.com" }, "delegate": { "id": 24651, "url": "http://patchwork.dpdk.org/api/users/24651/?format=api", "username": "dmarchand", "first_name": "David", "last_name": "Marchand", "email": "david.marchand@redhat.com" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20210106133333.12528-1-olivier.matz@6wind.com/mbox/", "series": [ { "id": 14556, "url": "http://patchwork.dpdk.org/api/series/14556/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=14556", "date": "2021-01-06T13:33:33", "name": "[v3] mbuf: fix reset on mbuf free", "version": 3, "mbox": "http://patchwork.dpdk.org/series/14556/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/86053/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/86053/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id E3681A0524;\n\tWed, 6 Jan 2021 14:33:47 +0100 (CET)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6C44C160976;\n\tWed, 6 Jan 2021 14:33:47 +0100 (CET)", "from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com\n [62.23.145.76])\n by mails.dpdk.org (Postfix) with ESMTP id 9722B160973;\n Wed, 6 Jan 2021 14:33:45 +0100 (CET)", "from gojira.dev.6wind.com (unknown [10.16.0.194])\n by proxy.6wind.com (Postfix) with ESMTP id 40D1E50BA8F;\n Wed, 6 Jan 2021 14:33:45 +0100 (CET)" ], "From": "Olivier Matz <olivier.matz@6wind.com>", "To": "dev@dpdk.org", "Cc": "andrew.rybchenko@oktetlabs.ru, konstantin.ananyev@intel.com,\n mb@smartsharesystems.com, alialnu@nvidia.com, ajitkhaparde@gmail.com,\n stable@dpdk.org, Ajit Khaparde <ajit.khaparde@broadcom.com>", "Date": "Wed, 6 Jan 2021 14:33:33 +0100", "Message-Id": "<20210106133333.12528-1-olivier.matz@6wind.com>", "X-Mailer": "git-send-email 2.29.2", "In-Reply-To": "<20201104170007.8026-1-olivier.matz@6wind.com>", "References": "<20201104170007.8026-1-olivier.matz@6wind.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v3] mbuf: fix reset on mbuf free", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "m->nb_seg must be reset on mbuf free whatever the value of m->next,\nbecause it can happen that m->nb_seg is != 1. For instance in this\ncase:\n\n m1 = rte_pktmbuf_alloc(mp);\n rte_pktmbuf_append(m1, 500);\n m2 = rte_pktmbuf_alloc(mp);\n rte_pktmbuf_append(m2, 500);\n rte_pktmbuf_chain(m1, m2);\n m0 = rte_pktmbuf_alloc(mp);\n rte_pktmbuf_append(m0, 500);\n rte_pktmbuf_chain(m0, m1);\n\nAs rte_pktmbuf_chain() does not reset nb_seg in the initial m1\nsegment (this is not required), after this code the mbuf chain\nhave 3 segments:\n - m0: next=m1, nb_seg=3\n - m1: next=m2, nb_seg=2\n - m2: next=NULL, nb_seg=1\n\nThen split this chain between m1 and m2, it would result in 2 packets:\n - first packet\n - m0: next=m1, nb_seg=2\n - m1: next=NULL, nb_seg=2\n - second packet\n - m2: next=NULL, nb_seg=1\n\nFreeing the first packet will not restore nb_seg=1 in the second\nsegment. This is an issue because it is expected that mbufs stored\nin pool have their nb_seg field set to 1.\n\nFixes: 8f094a9ac5d7 (\"mbuf: set mbuf fields while in pool\")\nCc: stable@dpdk.org\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\nAcked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>\n---\n\nv3\n* fix commit log again (thanks Morten for spotting it)\n\nv2\n* avoid write access if uneeded (suggested by Konstantin)\n* enhance comments in mbuf header file (suggested by Morten)\n* fix commit log\n\n\n lib/librte_mbuf/rte_mbuf.c | 4 ++--\n lib/librte_mbuf/rte_mbuf.h | 8 ++++----\n lib/librte_mbuf/rte_mbuf_core.h | 13 +++++++++++--\n 3 files changed, 17 insertions(+), 8 deletions(-)", "diff": "diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex 7d09ee2939..5f77840557 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -129,10 +129,10 @@ rte_pktmbuf_free_pinned_extmem(void *addr, void *opaque)\n \n \trte_mbuf_ext_refcnt_set(m->shinfo, 1);\n \tm->ol_flags = EXT_ATTACHED_MBUF;\n-\tif (m->next != NULL) {\n+\tif (m->next != NULL)\n \t\tm->next = NULL;\n+\tif (m->nb_segs != 1)\n \t\tm->nb_segs = 1;\n-\t}\n \trte_mbuf_raw_free(m);\n }\n \ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex c4c9ebfaa0..8c1097ed76 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -1340,10 +1340,10 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)\n \t\t\t\treturn NULL;\n \t\t}\n \n-\t\tif (m->next != NULL) {\n+\t\tif (m->next != NULL)\n \t\t\tm->next = NULL;\n+\t\tif (m->nb_segs != 1)\n \t\t\tm->nb_segs = 1;\n-\t\t}\n \n \t\treturn m;\n \n@@ -1357,10 +1357,10 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)\n \t\t\t\treturn NULL;\n \t\t}\n \n-\t\tif (m->next != NULL) {\n+\t\tif (m->next != NULL)\n \t\t\tm->next = NULL;\n+\t\tif (m->nb_segs != 1)\n \t\t\tm->nb_segs = 1;\n-\t\t}\n \t\trte_mbuf_refcnt_set(m, 1);\n \n \t\treturn m;\ndiff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h\nindex 567551deab..78a1fcc8ff 100644\n--- a/lib/librte_mbuf/rte_mbuf_core.h\n+++ b/lib/librte_mbuf/rte_mbuf_core.h\n@@ -495,7 +495,12 @@ struct rte_mbuf {\n \t * or non-atomic) is controlled by the RTE_MBUF_REFCNT_ATOMIC flag.\n \t */\n \tuint16_t refcnt;\n-\tuint16_t nb_segs; /**< Number of segments. */\n+\n+\t/**\n+\t * Number of segments. Only valid for the first segment of an mbuf\n+\t * chain.\n+\t */\n+\tuint16_t nb_segs;\n \n \t/** Input port (16 bits to support more than 256 virtual ports).\n \t * The event eth Tx adapter uses this field to specify the output port.\n@@ -591,7 +596,11 @@ struct rte_mbuf {\n \t/* second cache line - fields only used in slow path or on TX */\n \tRTE_MARKER cacheline1 __rte_cache_min_aligned;\n \n-\tstruct rte_mbuf *next; /**< Next segment of scattered packet. */\n+\t/**\n+\t * Next segment of scattered packet. Must be NULL in the last segment or\n+\t * in case of non-segmented packet.\n+\t */\n+\tstruct rte_mbuf *next;\n \n \t/* fields to support TX offloads */\n \tRTE_STD_C11\n", "prefixes": [ "v3" ] }{ "id": 86053, "url": "