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 B815F326B for ; Sat, 6 May 2017 09:26:52 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id u65so39988399wmu.1 for ; Sat, 06 May 2017 00:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weka.io; s=google; h=from:to:cc:subject:date:message-id:organization:mime-version :content-transfer-encoding; bh=BAg6XyD/S6mrtRrKLbV73qXhzD/e4kLF/MNjyp35vEo=; b=FlgB2cvjRJtzbq3PtZov85BxgE0IqZJI8dJ8OhooHwuUGHGCU2wh/0CyHIsQeDfTHw C+jdcP5REPTxcfgqoPAUanQTfn8ztq8ytb0FLgWoCWugxZjuhCMqA5bsuiI77fKpEZtG cHtQedlSXnoBSytpimPfjF0y+qRHw5JNJ1jzA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :mime-version:content-transfer-encoding; bh=BAg6XyD/S6mrtRrKLbV73qXhzD/e4kLF/MNjyp35vEo=; b=pjkNhxw/qPjV00/HCkbosvWMk14wttefHJ6pxnghYggJEVEhXad2K0IH9WwCyrshAY GJSrIJWdpfijv4QWWslZtfdkNYYTS90BWaD+pZlpaV7QWuQWGmWrAHpv4c5+0BMQEHTa G03wydFci6rNhQwlKyrpybkfACAbKqXwYtorbshU5Ts7UZ9PrLnDlqAITluZohBb3K69 d/BhkP3KO28Pxoc2SQ4cWyAmvrxa2ocDsnWqae1Q0Jg9ZrdghZYxjKSq+pSv/vUZNC/2 y2GhHRGSo2v4N/herJVo9a8sUzvWZXGoWEZRSYjY0RT8Dpq7Rjp96Gj2UXXr/yqLaGHP ZjaA== X-Gm-Message-State: AODbwcC74s2oWfPdzD4seBUPkSLEQHMenXIpLgakPY8jlfLWTvDwH04A Ub9dvAb/AoGYmPySfzM= X-Received: by 10.28.136.146 with SMTP id k140mr7871436wmd.55.1494055612172; Sat, 06 May 2017 00:26:52 -0700 (PDT) Received: from polaris.localnet (bzq-84-109-69-99.red.bezeqint.net. [84.109.69.99]) by smtp.gmail.com with ESMTPSA id a73sm7349377wrc.58.2017.05.06.00.26.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 May 2017 00:26:51 -0700 (PDT) From: Gregory Etelson To: dev@dpdk.org Cc: Olivier Matz Date: Sat, 06 May 2017 10:26:49 +0300 Message-ID: <1802735.EECn92tGJO@polaris> Organization: Weka.IO MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] [PATCH v2] mbuf: fix bulk allocation when debug enabled 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: Sat, 06 May 2017 07:26:53 -0000 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 Signed-off-by: Gregory Etelson --- lib/librte_mbuf/rte_mbuf.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 9097f18..05b8300 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -788,6 +788,13 @@ 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_) do { \ + 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); \ +} while (0) + /** * Allocate an unitialized mbuf from mempool *mp*. * @@ -815,11 +822,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,26 +1155,22 @@ 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++; /* fall-through */ 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++; /* fall-through */ 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++; /* fall-through */ 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++; /* fall-through */ -- 2.9.3