From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by dpdk.org (Postfix) with ESMTP id 9746CFE5 for ; Wed, 6 Sep 2017 12:46:15 +0200 (CEST) Received: by mail-qt0-f194.google.com with SMTP id h21so3670383qth.4 for ; Wed, 06 Sep 2017 03:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=UVt+WiAI1GxPCSKbV5fNNJtPmmBUgSUl5Bs5W7c/3TA=; b=KkcJo/qypwlqAwpqE73II8XXC7ZWRbBcF40V5IBT3q5dN6EgiCzVLW9fTu99Qxuke4 psaLqGqNhtBaqSYUkKWEj3a8dEOCdIOzpEnZc9dqc1dV3r6BvFQBjZ1ARhmRZV0sb/38 coXnF4eU+ZWHdCgKko3282gHILEfihUv2Ji904X019BbMkbD0VSfkbvIwJ3aQx0jrwRe NCTcPnz2vEwiHbF5t7uDlflknEX8bpb0oyFiRXXODzPpWR0+sD+LawXh8JT1bGKR8UYA vwgTPILq/Q0BbkDIoEDVp6teaExr9Mht2ARIbAFN3FGNsVnqfW/vIEdA/E9KNqDsZX4B aKeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=UVt+WiAI1GxPCSKbV5fNNJtPmmBUgSUl5Bs5W7c/3TA=; b=RFYqmA5yYPQAr2H/0c3Mo8OydN2jir45bqbhGXPtQbjGzRut9JzagfQ39QM7HdOjGU NqXXxghU9GriLIu5R9YPu8WRTWsp6WhfEMI3a18AMu2YOUwP0sdwx078BGAOAQ3NgkXy 6j3ILZIRzeiPkLbRh1EmvJv9BwlQZzkTwuM2bbYuDHLpt9i7Nb6+DgYCh8u4ptFcvIbh mCwXZEag+vzr0IHllb5RJYFaKM6BFsRl+HlMnOVX7bKvnGgPa0Rja7ekZfgLQJqW32Ze cu/F2zooYVeDDJG4ilKn3lXEN0hJ+K4d3nEH4Uqk5FwGWVmN+K7QK7l7hJ0sg95igd9E bUHg== X-Gm-Message-State: AHPjjUiFOJc2kSif0M8Ohb7T1aPR9W7zEteO/e9VcrrbHzVxffT8zaHp kRXy0cRRVVHF2g== X-Google-Smtp-Source: ADKCNb5ECuZj1728VOeTzHcKRkXwPTExvBAE/3rdYcA20r+7wuuqacvghrtY0gT7kVOi13Wn693C3Q== X-Received: by 10.200.49.38 with SMTP id g35mr2752451qtb.133.1504694774994; Wed, 06 Sep 2017 03:46:14 -0700 (PDT) Received: from monolith.home (pool-96-255-82-208.washdc.fios.verizon.net. [96.255.82.208]) by smtp.googlemail.com with ESMTPSA id j19sm1962109qtc.41.2017.09.06.03.46.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 03:46:14 -0700 (PDT) Message-ID: <1504694773.2192.9.camel@gmail.com> From: Chas Williams <3chas3@gmail.com> To: Radu Nicolau , dev@dpdk.org Cc: olivier.matz@6wind.com, cw817q@att.com Date: Wed, 06 Sep 2017 06:46:13 -0400 In-Reply-To: References: <1502120243-8902-1-git-send-email-ciwillia@brocade.com> <1502122274-15657-1-git-send-email-ciwillia@brocade.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-2.fc25) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit 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: Wed, 06 Sep 2017 10:46:15 -0000 [Note: My former email address is going away eventually. I am moving the conversation to my other email address which is a bit more permanent.] On Mon, 2017-09-04 at 15:27 +0100, Radu Nicolau wrote: > > 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? It doesn't. rte_mbuf_refcnt_update() is also atomic(ish) but it slightly more optimal. This whole section is a little hazy actually. It looks like rte_pktmbuf_prefree_seg() unwraps rte_mbuf_refcnt_update() so they can avoid setting the refcnt when the refcnt is already the 'correct' value. > > > > > > 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 Thanks for the review.