Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/60963/?format=api
http://patches.dpdk.org/api/patches/60963/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20191011121458.56388-2-mb@smartsharesystems.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": "<20191011121458.56388-2-mb@smartsharesystems.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20191011121458.56388-2-mb@smartsharesystems.com", "date": "2019-10-11T12:14:57", "name": "[v8,1/2] mbuf: add bulk free function", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "d842df7ac5fdf8be8a71b6f89093fa52c22af211", "submitter": { "id": 591, "url": "http://patches.dpdk.org/api/people/591/?format=api", "name": "Morten Brørup", "email": "mb@smartsharesystems.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20191011121458.56388-2-mb@smartsharesystems.com/mbox/", "series": [ { "id": 6803, "url": "http://patches.dpdk.org/api/series/6803/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=6803", "date": "2019-10-11T12:14:56", "name": "mbuf: add bulk free function", "version": 8, "mbox": "http://patches.dpdk.org/series/6803/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/60963/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/60963/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 9D3C9235;\n\tFri, 11 Oct 2019 14:15:04 +0200 (CEST)", "from smartserver.smartsharesystems.com\n\t(smartserver.smartsharesystems.com [77.243.40.215])\n\tby dpdk.org (Postfix) with ESMTP id 2E8A71EA6E\n\tfor <dev@dpdk.org>; Fri, 11 Oct 2019 14:15:01 +0200 (CEST)", "from dkrd2.smartsharesys.local ([192.168.4.12]) by\n\tsmartserver.smartsharesystems.com with Microsoft\n\tSMTPSVC(6.0.3790.4675); Fri, 11 Oct 2019 14:15:00 +0200" ], "From": "=?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>", "To": "dev@dpdk.org", "Cc": "olivier.matz@6wind.com, stephen@networkplumber.org,\n\tharry.van.haaren@intel.com, konstantin.ananyev@intel.com, \n\tmattias.ronnblom@ericsson.com, bruce.richardson@intel.com, \n\tarybchenko@solarflare.com, =?utf-8?q?Morten_Br=C3=B8rup?=\n\t<mb@smartsharesystems.com>", "Date": "Fri, 11 Oct 2019 12:14:57 +0000", "Message-Id": "<20191011121458.56388-2-mb@smartsharesystems.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20191011121458.56388-1-mb@smartsharesystems.com>", "References": "<20191011121458.56388-1-mb@smartsharesystems.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-OriginalArrivalTime": "11 Oct 2019 12:15:00.0678 (UTC)\n\tFILETIME=[8132EE60:01D5802D]", "Subject": "[dpdk-dev] [PATCH v8 1/2] mbuf: add bulk free function", "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": "Add function for freeing a bulk of mbufs.\n\nSigned-off-by: Morten Brørup <mb@smartsharesystems.com>\nAcked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>\nReviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>\nAcked-by: Stephen Hemminger <stephen@networkplumber.org>\n\n---\n\nv8:\n* Add unit test, covering both bulk alloc and bulk free.\nv7:\n* Squash multiple modifications into one.\nv6:\n* Remove __rte_always_inline from static function.\n The compiler will inline anyway.\nv5:\n* Rename variables from \"free\" to \"pending\" for improved readability.\n* Add prefix __ to rte_pktmbuf_free_seg_via_array().\n* Add array size parameter to __rte_pktmbuf_free_seg_via_array().\n The compiler will optimize the parameter away anyway.\n* Add description to __rte_pktmbuf_free_seg_via_array().\n* Minor description updates.\nv4:\n* Mark as experimental by adding __rte_experimental.\n* Add function to experimental section of map file.\n* Fix source code formatting regarding pointer to pointer.\n* Squash multiple modifications into one.\nv3:\n* Bugfix: Handle pakets with multiple segments.\n* Add inline helper function, mainly for readability.\n* Fix source code formatting regarding indentation.\nv2:\n* Function is not inline.\n* Optimize to free multible mbufs belonging to the same mempool in\n bulk. Inspired by ixgbe_tx_free_bufs(), but allowing NULL pointers\n in the array, just like rte_pktmbuf_free() can take a NULL pointer.\n* Use unsigned int instead of unsigned. Passes checkpatch, but\n mismatches the original coding style of the modified files.\n* Fix a typo in the description headline: mempools is plural.\n---\n lib/librte_mbuf/rte_mbuf.c | 66 ++++++++++++++++++++++++++++\n lib/librte_mbuf/rte_mbuf.h | 15 +++++++\n lib/librte_mbuf/rte_mbuf_version.map | 1 +\n 3 files changed, 82 insertions(+)", "diff": "diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex 37718d49c..854af1104 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -245,6 +245,72 @@ int rte_mbuf_check(const struct rte_mbuf *m, int is_header,\n \treturn 0;\n }\n \n+/**\n+ * @internal helper function for freeing a bulk of packet mbuf segments\n+ * via an array holding the packet mbuf segments from the same mempool\n+ * pending to be freed.\n+ *\n+ * @param m\n+ * The packet mbuf segment to be freed.\n+ * @param pending\n+ * Pointer to the array of packet mbuf segments pending to be freed.\n+ * @param nb_pending\n+ * Pointer to the number of elements held in the array.\n+ * @param pending_sz\n+ * Number of elements the array can hold.\n+ * Note: The compiler should optimize this parameter away when using a\n+ * constant value, such as RTE_PKTMBUF_FREE_PENDING_SZ.\n+ */\n+static void\n+__rte_pktmbuf_free_seg_via_array(struct rte_mbuf *m,\n+\tstruct rte_mbuf ** const pending, unsigned int * const nb_pending,\n+\tconst unsigned int pending_sz)\n+{\n+\tm = rte_pktmbuf_prefree_seg(m);\n+\tif (likely(m != NULL)) {\n+\t\tif (*nb_pending == pending_sz ||\n+\t\t (*nb_pending > 0 && m->pool != pending[0]->pool)) {\n+\t\t\trte_mempool_put_bulk(pending[0]->pool,\n+\t\t\t\t\t(void **)pending, *nb_pending);\n+\t\t\t*nb_pending = 0;\n+\t\t}\n+\n+\t\tpending[(*nb_pending)++] = m;\n+\t}\n+}\n+\n+/**\n+ * Size of the array holding mbufs from the same membool pending to be freed\n+ * in bulk.\n+ */\n+#define RTE_PKTMBUF_FREE_PENDING_SZ 64\n+\n+/* Free a bulk of packet mbufs back into their original mempools. */\n+void rte_pktmbuf_free_bulk(struct rte_mbuf **mbufs, unsigned int count)\n+{\n+\tstruct rte_mbuf *m, *m_next, *pending[RTE_PKTMBUF_FREE_PENDING_SZ];\n+\tunsigned int idx, nb_pending = 0;\n+\n+\tfor (idx = 0; idx < count; idx++) {\n+\t\tm = mbufs[idx];\n+\t\tif (unlikely(m == NULL))\n+\t\t\tcontinue;\n+\n+\t\t__rte_mbuf_sanity_check(m, 1);\n+\n+\t\tdo {\n+\t\t\tm_next = m->next;\n+\t\t\t__rte_pktmbuf_free_seg_via_array(m,\n+\t\t\t\t\tpending, &nb_pending,\n+\t\t\t\t\tRTE_PKTMBUF_FREE_PENDING_SZ);\n+\t\t\tm = m_next;\n+\t\t} while (m != NULL);\n+\t}\n+\n+\tif (nb_pending > 0)\n+\t\trte_mempool_put_bulk(pending[0]->pool, (void **)pending, nb_pending);\n+}\n+\n /* dump a mbuf on console */\n void\n rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 98225ec80..a02c8b12c 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -1907,6 +1907,21 @@ static inline void rte_pktmbuf_free(struct rte_mbuf *m)\n \t}\n }\n \n+/**\n+ * Free a bulk of packet mbufs back into their original mempools.\n+ *\n+ * Free a bulk of mbufs, and all their segments in case of chained buffers.\n+ * Each segment is added back into its original mempool.\n+ *\n+ * @param mbufs\n+ * Array of pointers to packet mbufs.\n+ * The array may contain NULL pointers.\n+ * @param count\n+ * Array size.\n+ */\n+__rte_experimental\n+void rte_pktmbuf_free_bulk(struct rte_mbuf **mbufs, unsigned int count);\n+\n /**\n * Creates a \"clone\" of the given packet mbuf.\n *\ndiff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map\nindex 2662a37bf..cd6154ef2 100644\n--- a/lib/librte_mbuf/rte_mbuf_version.map\n+++ b/lib/librte_mbuf/rte_mbuf_version.map\n@@ -50,4 +50,5 @@ EXPERIMENTAL {\n \tglobal:\n \n \trte_mbuf_check;\n+\trte_pktmbuf_free_bulk;\n } DPDK_18.08;\n", "prefixes": [ "v8", "1/2" ] }{ "id": 60963, "url": "