From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Wiles, Keith" Subject: Do we need the refcnt set to zero again? Date: Sat, 28 Feb 2015 18:08:16 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable To: "dev-VfR2kkLFssw@public.gmane.org" Return-path: Content-Language: en-US Content-ID: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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); }