From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id 24D6E2935 for ; Fri, 5 May 2017 15:54:54 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id 142so7062544wma.1 for ; Fri, 05 May 2017 06:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C7wdCl0lDaMoWpxefQ5Y1Wf/szjW7k3+N3OqYWjoBXU=; b=czm0HERmkhlW4aiEyUWAVM8lwDDHHnKVlcHoRV4gS1KeWwEfZSerZNwIs6kZFGgDXE N8uGE/MFTR6wJlBznNprM3kW+9D2D6ZdW+LnF1jC0rDTxJo8/w41dfvalodTVN9k4B2T nE8Quh9qY8IvcD775fOrQs9zTItyryQZG45TYgNS9STdF+lwK29nNLeR+76AJW5clKg3 oc1T5t6RPgccSs5PAwf3kJe62F9NU3CP9xyCZ+qgVnR3ctXRfBkuLyBfI94SDYZaJlRD BlLl6kn+W4CGAGl+ycyUZ10rSzb3fDr2CZZyGwYWCOqUNj54tVgjB601SRnsxBhUXrsX qRWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C7wdCl0lDaMoWpxefQ5Y1Wf/szjW7k3+N3OqYWjoBXU=; b=oVDIItCBeBCxDrQ9UIaIOHNk9ZqFdgIBZwjyyFalXVjdN10I6A2ejzJfn8v1m1kwS2 3TtdrEhRpIJkGY1OwmlVU6VoYCTrZsNh69coFc9oicwD7bIBV2owKYdi6MUDrYCKY+bX b8aqVdRwRnPXiggV5FRegFXwQeg/DtS+Ap3A20XYFmIf36OkdHJkMKmHdVSwmlrXj03O /xaw69Qtv7ZwHDaMNUsxq+6GowdlMS+J1CPdgVFFZfQ82op0hE21zPenwP1YPwLUSYr4 bY5rsNCOAyH7AGXChwwdLz/SsgDwyarNfthn0L02aH2rlgRE1uwMz0CkIaFo1ohL7Ktg AuiA== X-Gm-Message-State: AODbwcD2UjySA/H2/QY+LtJdXP7UZSSjs+tQL/9r5N6T2hyaxCFDUGOI asbrGLIy1jhLhuujshA= X-Received: by 10.28.191.145 with SMTP id o17mr5956154wmi.20.1493992493815; Fri, 05 May 2017 06:54:53 -0700 (PDT) Received: from platinum (2a01cb0c03c651000226b0fffeed02fc.ipv6.abo.wanadoo.fr. [2a01:cb0c:3c6:5100:226:b0ff:feed:2fc]) by smtp.gmail.com with ESMTPSA id s5sm4983263wra.60.2017.05.05.06.54.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 May 2017 06:54:53 -0700 (PDT) Date: Fri, 5 May 2017 15:54:51 +0200 From: Olivier Matz To: Gregory Etelson Cc: dev@dpdk.org Message-ID: <20170505155451.6193fe26@platinum> In-Reply-To: <4935498.pT9graIqJa@polaris> References: <4935498.pT9graIqJa@polaris> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] mbuf: rte_pktmbuf_alloc_bulk bugfix 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: Fri, 05 May 2017 13:54:54 -0000 Hi Gregory, On Fri, 05 May 2017 16:29:59 +0300, Gregory Etelson wrote: > bugfix in rte_pktmbuf_alloc_bulk > > Signed-off-by: Gregory Etelson Thank you for the fix. I suggest the following title instead: mbuf: fix bulk allocation when debug enabled Please refer to the guidelines: http://dpdk.org/doc/guides/contributing/patches.html#commit-messages-subject-line A description would have been welcome, for instance: The debug assertions when allocating a raw mbuf are not correct since commit 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool"), which triggers a panic when using this function in debug mode. Change the expected number of segments to 1 instead of 0, and factorize these sanity checks. Fixes: 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool") Can you please submit a v2 with these changes? You can validate your changes with checkpatches.sh and check-git-log.sh. Thanks, Olivier > --- > lib/librte_mbuf/rte_mbuf.h | 24 +++++++++++------------- > 1 file changed, 11 insertions(+), 13 deletions(-) > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index 466ec00..bebe94f 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -788,6 +788,12 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value) > void > rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header); > > +#define MBUF_RAW_ALLOC_CHECK(m_) \ > + RTE_ASSERT(rte_mbuf_refcnt_read(m_) == 1); \ > + RTE_ASSERT(m_->next == NULL); \ > + RTE_ASSERT(m_->nb_segs == 1); \ > + __rte_mbuf_sanity_check(m_, 0); > + > /** > * Allocate an unitialized mbuf from mempool *mp*. > * > @@ -815,11 +821,7 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp) > if (rte_mempool_get(mp, &mb) < 0) > return NULL; > m = (struct rte_mbuf *)mb; > - RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1); > - RTE_ASSERT(m->next == NULL); > - RTE_ASSERT(m->nb_segs == 1); > - __rte_mbuf_sanity_check(m, 0); > - > + MBUF_RAW_ALLOC_CHECK(m); > return m; > } > > @@ -1152,23 +1154,19 @@ static inline int rte_pktmbuf_alloc_bulk(struct rte_mempool *pool, > switch (count % 4) { > case 0: > while (idx != count) { > - RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0); > - rte_mbuf_refcnt_set(mbufs[idx], 1); > + MBUF_RAW_ALLOC_CHECK(mbufs[idx]); > rte_pktmbuf_reset(mbufs[idx]); > idx++; > case 3: > - RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0); > - rte_mbuf_refcnt_set(mbufs[idx], 1); > + MBUF_RAW_ALLOC_CHECK(mbufs[idx]); > rte_pktmbuf_reset(mbufs[idx]); > idx++; > case 2: > - RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0); > - rte_mbuf_refcnt_set(mbufs[idx], 1); > + MBUF_RAW_ALLOC_CHECK(mbufs[idx]); > rte_pktmbuf_reset(mbufs[idx]); > idx++; > case 1: > - RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0); > - rte_mbuf_refcnt_set(mbufs[idx], 1); > + MBUF_RAW_ALLOC_CHECK(mbufs[idx]); > rte_pktmbuf_reset(mbufs[idx]); > idx++; > }