From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id C248D959 for ; Sat, 28 Feb 2015 19:08:19 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 28 Feb 2015 10:08:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,668,1418112000"; d="scan'208";a="673227523" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by fmsmga001.fm.intel.com with ESMTP; 28 Feb 2015 10:08:17 -0800 Received: from orsmsx115.amr.corp.intel.com (10.22.240.11) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.195.1; Sat, 28 Feb 2015 10:08:17 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by ORSMSX115.amr.corp.intel.com (10.22.240.11) with Microsoft SMTP Server (TLS) id 14.3.195.1; Sat, 28 Feb 2015 10:08:17 -0800 Received: from fmsmsx113.amr.corp.intel.com ([169.254.13.112]) by FMSMSX110.amr.corp.intel.com ([169.254.14.19]) with mapi id 14.03.0195.001; Sat, 28 Feb 2015 10:08:16 -0800 From: "Wiles, Keith" To: "dev@dpdk.org" Thread-Topic: Do we need the refcnt set to zero again? Thread-Index: AQHQU4GGbFyGg8dxo0exkAYUXAFarA== Date: Sat, 28 Feb 2015 18:08:16 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.255.66.73] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: [dpdk-dev] Do we need the refcnt set to zero again? 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: Sat, 28 Feb 2015 18:08:20 -0000 Looking that the code below does the rte_mbuf_refcnt_set(m,0) need to be pr= esent? static inline struct rte_mbuf* __attribute__((always_inline)) __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) { __rte_mbuf_sanity_check(m, 0); if (likely (rte_mbuf_refcnt_read(m) =3D=3D 1) || likely (rte_mbuf_refcnt_update(m, -1) =3D=3D 0)) { rte_mbuf_refcnt_set(m, 0); /* if this is an indirect mbuf, then * - detach mbuf * - free attached mbuf segment */ if (RTE_MBUF_INDIRECT(m)) { struct rte_mbuf *md =3D RTE_MBUF_FROM_BADDR(m->buf_addr); rte_pktmbuf_detach(m); if (rte_mbuf_refcnt_update(md, -1) =3D=3D 0) __rte_mbuf_raw_free(md); } return(m); } return (NULL); } It seems like the code could be this or did I miss a race-condition? static inline struct rte_mbuf* __attribute__((always_inline)) __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) { __rte_mbuf_sanity_check(m, 0); /* The sanity check above should have checked for refcnt being zero */ if ( likely (rte_mbuf_refcnt_update(m, -1) =3D=3D 0 ) { /* if this is an indirect mbuf, then * - detach mbuf * - free attached mbuf segment */ if (RTE_MBUF_INDIRECT(m)) { struct rte_mbuf *md =3D RTE_MBUF_FROM_BADDR(m->buf_addr); rte_pktmbuf_detach(m); if (rte_mbuf_refcnt_update(md, -1) =3D=3D 0) __rte_mbuf_raw_free(md); } return(m); } return (NULL); }