DPDK patches and discussions
 help / color / mirror / Atom feed
From: Radu Nicolau <radu.nicolau@intel.com>
To: "Charles (Chas) Williams" <ciwillia@brocade.com>, dev@dpdk.org
Cc: olivier.matz@6wind.com
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use refcnt = 0 when debugging
Date: Mon, 4 Sep 2017 15:27:55 +0100	[thread overview]
Message-ID: <bff4a6bc-4a57-e9c4-4208-d5950f2f122b@intel.com> (raw)
In-Reply-To: <1502122274-15657-1-git-send-email-ciwillia@brocade.com>



On 8/7/2017 5:11 PM, Charles (Chas) Williams wrote:
> After commit 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool") is it
> much harder to detect a "double free".  If the developer makes a copy
> of an mbuf pointer and frees it twice, this condition is never detected
> and the mbuf gets returned to the pool twice.
>
> Since this requires extra work to track, make this behavior conditional
> on CONFIG_RTE_LIBRTE_MBUF_DEBUG.
>
> Signed-off-by: Chas Williams <ciwillia@brocade.com>
> ---
>
> @@ -1304,10 +1329,13 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)
>   			m->next = NULL;
>   			m->nb_segs = 1;
>   		}
> +#ifdef RTE_LIBRTE_MBUF_DEBUG
> +		rte_mbuf_refcnt_set(m, RTE_MBUF_UNUSED_CNT);
> +#endif
>   
>   		return m;
>   
> -       } else if (rte_atomic16_add_return(&m->refcnt_atomic, -1) == 0) {
> +	} else if (rte_mbuf_refcnt_update(m, -1) == 0) {
Why replace the use of atomic operation?
>   
>   
>   		if (RTE_MBUF_INDIRECT(m))
> @@ -1317,7 +1345,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)
>   			m->next = NULL;
>   			m->nb_segs = 1;
>   		}
> -		rte_mbuf_refcnt_set(m, 1);
> +		rte_mbuf_refcnt_set(m, RTE_MBUF_UNUSED_CNT);
>   
>   		return m;
>   	}
Reviewed-by:  Radu Nicolau <radu.nicolau@intel.com>

  reply	other threads:[~2017-09-04 14:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 15:37 [dpdk-dev] [PATCH] " Charles (Chas) Williams
2017-08-07 16:11 ` [dpdk-dev] [PATCH v2] " Charles (Chas) Williams
2017-09-04 14:27   ` Radu Nicolau [this message]
2017-09-06 10:46     ` Chas Williams
2017-09-06 11:58       ` Ananyev, Konstantin
2017-09-06 13:55         ` Chas Williams
2017-09-06 14:53           ` Ananyev, Konstantin
2017-09-07 15:55             ` Chas Williams
2017-09-07 21:21   ` [dpdk-dev] [PATCH v3] " Charles (Chas) Williams
2017-09-20 11:23     ` Olivier MATZ

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=bff4a6bc-4a57-e9c4-4208-d5950f2f122b@intel.com \
    --to=radu.nicolau@intel.com \
    --cc=ciwillia@brocade.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    /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).