Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/12808/?format=api
http://patches.dpdk.org/api/patches/12808/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1463502902-5295-1-git-send-email-h.mikita89@gmail.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": "<1463502902-5295-1-git-send-email-h.mikita89@gmail.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1463502902-5295-1-git-send-email-h.mikita89@gmail.com", "date": "2016-05-17T16:35:02", "name": "[dpdk-dev,v3] mbuf: decrease refcnt when detaching", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "f364fb22132ecedf09481a632970ec470ae12560", "submitter": { "id": 486, "url": "http://patches.dpdk.org/api/people/486/?format=api", "name": "Hiroyuki Mikita", "email": "h.mikita89@gmail.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1463502902-5295-1-git-send-email-h.mikita89@gmail.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/12808/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/12808/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 9FAE7A6A;\n\tTue, 17 May 2016 18:35:16 +0200 (CEST)", "from mail-pf0-f196.google.com (mail-pf0-f196.google.com\n\t[209.85.192.196]) by dpdk.org (Postfix) with ESMTP id 965FC69A4\n\tfor <dev@dpdk.org>; Tue, 17 May 2016 18:35:14 +0200 (CEST)", "by mail-pf0-f196.google.com with SMTP id g132so2402558pfb.3\n\tfor <dev@dpdk.org>; Tue, 17 May 2016 09:35:14 -0700 (PDT)", "from localhost.localdomain (183.180.67.214.ap.gmobb-fix.jp.\n\t[183.180.67.214]) by smtp.gmail.com with ESMTPSA id\n\th5sm6012491pat.0.2016.05.17.09.35.11\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 17 May 2016 09:35:13 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=t78/dBlDJfXo2mZojAfSBDFVlWDCE7xWJtl02+NyKnU=;\n\tb=YRU275SYEw6DHlwDOM7pC3AqhtitNct8O3MHpyktBJsG1k5rNmMrR9wia8qE5f4Ke5\n\teTd8Kwb6PvrwXyZwFu/vMuHVJuxA3wSvlL5XN2BHGpg0u7gWgAqnEWXW4cJTa9Irdick\n\t2pjH+fOyb4nGlC3yv60KxB8Pv8dSugLu712DkavKq82Q8vgYgDMvXA5s1Kub8if2T9eZ\n\tXSoYJCw5YOeVFq1n+RLyBNzEIrmF/2QdQpIuH9oSMZ93o0be7ipDNH2TdfGR51LsevJc\n\tb/fBTFkxXcH9bD1hupVW6Next9oHKfhK3+Pqem6ErDiFrGq2Rv6WB9yjY6a7+1+gpfLa\n\t7/RQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=t78/dBlDJfXo2mZojAfSBDFVlWDCE7xWJtl02+NyKnU=;\n\tb=ZqRwZBEhwle3gyPatT7lyLq2cIvPciWMKqxX8VqBOlcfbb4DHF84qdzFEWrAbgxsYz\n\tBwmafSaD+40C63iPQiOb1hMh8eXdSo2IprcgJS+SfFaHdOjJh2aItYo3C+4qTXqk6enT\n\tK89GKTG5pnj8ykdLahEwxVTzUri7dE/FaIA0qfAKn/XAFaPVWz7QL2cakSlM9d37WFvH\n\tg9g3aAiQ6MKyyJ/x0bVUL/Rw8p9vbWxQUJQAATU7QEpqlTuPa/IJtxycXfMRtloang/2\n\tDwsY0OgqVcaD1bItncGCTMS+W5A+Fp4287yPpTK5mnbKJnaZRvaJM63tGZmC+Sv1xMeU\n\t75FQ==", "X-Gm-Message-State": "AOPr4FVfzAtq6Fvs5ztx566+3VYLMliSymRqtv3m2ViAbLm84h9zeI/sKZ0Un2wdng/54Q==", "X-Received": "by 10.98.67.7 with SMTP id q7mr3498894pfa.70.1463502913982;\n\tTue, 17 May 2016 09:35:13 -0700 (PDT)", "From": "Hiroyuki Mikita <h.mikita89@gmail.com>", "To": "olivier.matz@6wind.com, thomas.monjalon@6wind.com,\n\tkonstantin.ananyev@intel.com", "Cc": "dev@dpdk.org", "Date": "Wed, 18 May 2016 01:35:02 +0900", "Message-Id": "<1463502902-5295-1-git-send-email-h.mikita89@gmail.com>", "X-Mailer": "git-send-email 1.9.1", "In-Reply-To": "<1463417600-20943-1-git-send-email-h.mikita89@gmail.com>", "References": "<1463417600-20943-1-git-send-email-h.mikita89@gmail.com>", "Subject": "[dpdk-dev] [PATCH v3] mbuf: decrease refcnt when detaching", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <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": "The rte_pktmbuf_detach() function should decrease refcnt on a direct\nbuffer.\n\nSigned-off-by: Hiroyuki Mikita <h.mikita89@gmail.com>\n---\nv3:\n* fixed rte_pktmbuf_detach() to decrease refcnt.\n* free the direct mbuf when refcnt becomes 0.\n* added this issue to Resolved Issues in release notes.\n\nv2:\n* introduced a new function rte_pktmbuf_detach2() which decrease refcnt.\n* marked rte_pktmbuf_detach() as deprecated.\n* added comments about refcnt to rte_pktmbuf_attach() and rte_pktmbuf_detach().\n* checked refcnt when detaching in unit tests.\n* added this issue to release notes.\n\n app/test/test_mbuf.c | 4 ++++\n doc/guides/rel_notes/release_16_07.rst | 6 ++++++\n lib/librte_mbuf/rte_mbuf.h | 17 ++++++++++-------\n 3 files changed, 20 insertions(+), 7 deletions(-)", "diff": "diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c\nindex 98ff93a..8460db7 100644\n--- a/app/test/test_mbuf.c\n+++ b/app/test/test_mbuf.c\n@@ -511,10 +511,14 @@ test_attach_from_different_pool(void)\n \trte_pktmbuf_detach(clone);\n \tif (c_data != rte_pktmbuf_mtod(clone, char *))\n \t\tGOTO_FAIL(\"clone was not detached properly\\n\");\n+\tif (rte_mbuf_refcnt_read(m) != 2)\n+\t\tGOTO_FAIL(\"invalid refcnt in m\\n\");\n \n \trte_pktmbuf_detach(clone2);\n \tif (c_data2 != rte_pktmbuf_mtod(clone2, char *))\n \t\tGOTO_FAIL(\"clone2 was not detached properly\\n\");\n+\tif (rte_mbuf_refcnt_read(m) != 1)\n+\t\tGOTO_FAIL(\"invalid refcnt in m\\n\");\n \n \t/* free the clones and the initial mbuf */\n \trte_pktmbuf_free(clone2);\ndiff --git a/doc/guides/rel_notes/release_16_07.rst b/doc/guides/rel_notes/release_16_07.rst\nindex f6d543c..8283373 100644\n--- a/doc/guides/rel_notes/release_16_07.rst\n+++ b/doc/guides/rel_notes/release_16_07.rst\n@@ -65,6 +65,12 @@ Drivers\n Libraries\n ~~~~~~~~~\n \n+* **mbuf: Fixed refcnt update when detaching.**\n+\n+ Fix the ``rte_pktmbuf_detach()`` function to decrement the direct\n+ mbuf's reference counter. The previous behavior was not to affect\n+ the reference counter. It lead a memory leak of the direct mbuf.\n+\n \n Examples\n ~~~~~~~~\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 529debb..299b60e 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -1408,6 +1408,8 @@ static inline int rte_pktmbuf_alloc_bulk(struct rte_mempool *pool,\n *\n * After attachment we refer the mbuf we attached as 'indirect',\n * while mbuf we attached to as 'direct'.\n+ * The direct mbuf's reference counter is incremented.\n+ * \n * Right now, not supported:\n * - attachment for already indirect mbuf (e.g. - mi has to be direct).\n * - mbuf we trying to attach (mi) is used by someone else\n@@ -1462,12 +1464,15 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m)\n * - restore original mbuf address and length values.\n * - reset pktmbuf data and data_len to their default values.\n * All other fields of the given packet mbuf will be left intact.\n+ * - decrement the direct mbuf's reference counter.\n+ * When the reference counter becomes 0, the direct mbuf is freed.\n *\n * @param m\n * The indirect attached packet mbuf.\n */\n static inline void rte_pktmbuf_detach(struct rte_mbuf *m)\n {\n+\tstruct rte_mbuf *md = rte_mbuf_from_indirect(m);\n \tstruct rte_mempool *mp = m->pool;\n \tuint32_t mbuf_size, buf_len, priv_size;\n \n@@ -1482,6 +1487,10 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m)\n \tm->data_off = RTE_MIN(RTE_PKTMBUF_HEADROOM, (uint16_t)m->buf_len);\n \tm->data_len = 0;\n \tm->ol_flags = 0;\n+\n+\tif (rte_mbuf_refcnt_update(md, -1) == 0) {\n+\t\t__rte_mbuf_raw_free(md);\n+\t}\n }\n \n static inline struct rte_mbuf* __attribute__((always_inline))\n@@ -1491,15 +1500,9 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m)\n \n \tif (likely(rte_mbuf_refcnt_update(m, -1) == 0)) {\n \n-\t\t/* if this is an indirect mbuf, then\n-\t\t * - detach mbuf\n-\t\t * - free attached mbuf segment\n-\t\t */\n+\t\t/* if this is an indirect mbuf, it is detached. */\n \t\tif (RTE_MBUF_INDIRECT(m)) {\n-\t\t\tstruct rte_mbuf *md = rte_mbuf_from_indirect(m);\n \t\t\trte_pktmbuf_detach(m);\n-\t\t\tif (rte_mbuf_refcnt_update(md, -1) == 0)\n-\t\t\t\t__rte_mbuf_raw_free(md);\n \t\t}\n \t\treturn m;\n \t}\n", "prefixes": [ "dpdk-dev", "v3" ] }{ "id": 12808, "url": "