From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by dpdk.org (Postfix) with ESMTP id DAC679A9A for ; Sun, 15 May 2016 17:50:45 +0200 (CEST) Received: by mail-pf0-f193.google.com with SMTP id 145so13554954pfz.1 for ; Sun, 15 May 2016 08:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=z29EKv07+ZEmBepjGWsRmRnKSjpRZR6KGPA0bRcZBBo=; b=g5+QQQoHIXIV0Ofz/XSS3nNH+kqgIQ29EpDvas08i99dyHLQbT6NZmKF7gSRw78vPU z0Xn+BBNmMDww5oTPnK07kT580I4oEENRWmMmFnlR+mF16Pgc77rPq4kkmOjgZGdWysU rkcmhu7RY6YR6RlduDc38yOv7/oKT/iedr73H+oVmq7VUa2Ww4U/TyWiDVCyimrlpng+ UXvFoDaR38perAoWe7+19M9A4NYciNZoQdKWuXSPuIy+lXIZOaAPqUHixnDVgRArEVwD AYHmPnVL+OT/kiGnYREvk2Q/mIxb3kHepA6ZA+n+CRrv4spyZ9G0Tysj7ir60trLnb50 mdRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=z29EKv07+ZEmBepjGWsRmRnKSjpRZR6KGPA0bRcZBBo=; b=iRcKuzA2H9Z+yDZ7GgXPkgKQ/iTNPqIBtk7Us9pteS0ysQEundfJPM7Y6EUjCbXVet p0ktI5FQ+9zajhgZcHiWdrO14JMadzi/yYgULFidwRy9xoz0OCsTIWwboJXB1Kw3j+/C brSvnqeo+j1lt5F/nsadGV+Nh0gawA1Rwki0xVqAgJ/wz1woVjJt4uCmDwEYlZXmysV2 cmYXbMODIg91R0MrTjSr19ZQp+x89USmPmxX3eXCWUO/A6xEDWIkRfm6jKMLO2jggLEl 4P2FZEHIyKlZfFH8xCWVPRzqaG61BWT9Cvk1s+T2GBRp+3Tz/B6/ul+m3jtCOKFbh/uT rYXA== X-Gm-Message-State: AOPr4FW7EqSj0KUDmxpOwCnyTrsadJvktv3smbLbNLB3cyNtaEYzlCn7M23mR4gYfYroPg== X-Received: by 10.98.79.199 with SMTP id f68mr38745548pfj.44.1463327445000; Sun, 15 May 2016 08:50:45 -0700 (PDT) Received: from localhost.localdomain (183.180.67.214.ap.gmobb-fix.jp. [183.180.67.214]) by smtp.gmail.com with ESMTPSA id a64sm41327114pfa.6.2016.05.15.08.50.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 May 2016 08:50:44 -0700 (PDT) From: Hiroyuki Mikita To: olivier.matz@6wind.com Cc: dev@dpdk.org Date: Mon, 16 May 2016 00:50:36 +0900 Message-Id: <1463327436-6863-1-git-send-email-h.mikita89@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 May 2016 15:50:46 -0000 The rte_pktmbuf_detach() function should decrease refcnt on a direct buffer. Signed-off-by: Hiroyuki Mikita --- lib/librte_mbuf/rte_mbuf.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 529debb..3b117ca 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -1468,9 +1468,11 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m) */ static inline void rte_pktmbuf_detach(struct rte_mbuf *m) { + struct rte_mbuf *md = rte_mbuf_from_indirect(m); struct rte_mempool *mp = m->pool; uint32_t mbuf_size, buf_len, priv_size; + rte_mbuf_refcnt_update(md, -1); priv_size = rte_pktmbuf_priv_size(mp); mbuf_size = sizeof(struct rte_mbuf) + priv_size; buf_len = rte_pktmbuf_data_room_size(mp); @@ -1498,7 +1500,7 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) if (RTE_MBUF_INDIRECT(m)) { struct rte_mbuf *md = rte_mbuf_from_indirect(m); rte_pktmbuf_detach(m); - if (rte_mbuf_refcnt_update(md, -1) == 0) + if (rte_mbuf_refcnt_read(md) == 0) __rte_mbuf_raw_free(md); } return m; -- 1.9.1