DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wiles, Keith" <keith.wiles@intel.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Subject: [dpdk-dev] Do we need the refcnt set to zero again?
Date: Sat, 28 Feb 2015 18:08:16 +0000	[thread overview]
Message-ID: <D117602F.1576B%keith.wiles@intel.com> (raw)

Looking that the code below does the rte_mbuf_refcnt_set(m,0) need to be present?

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) == 1) ||
likely (rte_mbuf_refcnt_update(m, -1) == 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 = RTE_MBUF_FROM_BADDR(m->buf_addr);
rte_pktmbuf_detach(m);
if (rte_mbuf_refcnt_update(md, -1) == 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) == 0 ) {

/* if this is an indirect mbuf, then
 *  - detach mbuf
 *  - free attached mbuf segment
 */
if (RTE_MBUF_INDIRECT(m)) {
struct rte_mbuf *md = RTE_MBUF_FROM_BADDR(m->buf_addr);
rte_pktmbuf_detach(m);
if (rte_mbuf_refcnt_update(md, -1) == 0)
__rte_mbuf_raw_free(md);
}
return(m);
}
return (NULL);
}

             reply	other threads:[~2015-02-28 18:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-28 18:08 Wiles, Keith [this message]
2015-03-02 10:16 ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D117602F.1576B%keith.wiles@intel.com \
    --to=keith.wiles@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).