From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 65D733989 for ; Mon, 4 Sep 2017 16:27:57 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 04 Sep 2017 07:27:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,475,1498546800"; d="scan'208,217";a="896950225" Received: from rnicolau-mobl.ger.corp.intel.com (HELO [10.237.221.79]) ([10.237.221.79]) by FMSMGA003.fm.intel.com with ESMTP; 04 Sep 2017 07:27:55 -0700 To: "Charles (Chas) Williams" , dev@dpdk.org Cc: olivier.matz@6wind.com References: <1502120243-8902-1-git-send-email-ciwillia@brocade.com> <1502122274-15657-1-git-send-email-ciwillia@brocade.com> From: Radu Nicolau Message-ID: Date: Mon, 4 Sep 2017 15:27:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <1502122274-15657-1-git-send-email-ciwillia@brocade.com> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use refcnt = 0 when debugging X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Sep 2017 14:27:57 -0000 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 > --- > > @@ -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