From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by dpdk.org (Postfix) with ESMTP id 8AFE82935 for ; Fri, 5 May 2017 15:30:02 +0200 (CEST) Received: by mail-wr0-f182.google.com with SMTP id l9so3924693wre.1 for ; Fri, 05 May 2017 06:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weka.io; s=google; h=from:to:subject:date:message-id:organization:mime-version :content-transfer-encoding; bh=ezQuNk8OooMgo/MY1xfwYeKVis0Qo5hYB0cANjzsKM0=; b=MAqt2009+jtQpa3uOcQY4LdOLivpxLtszKa6gil6ihIzXxJNAOfJ1CPxem+TUMM6DA NgdnwqvyIk831F5zCEKJACxkTrB2noxwmkO1PFwGGh52/obxLbQJElpLI6WXnNnQW/Wx oaGhfufkT9+EZOWI61WvizCbV+3YGwppOqhBY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:organization :mime-version:content-transfer-encoding; bh=ezQuNk8OooMgo/MY1xfwYeKVis0Qo5hYB0cANjzsKM0=; b=MEYXVnCbTMB2YkTYdDiTQ0rl7J6FRQ6gLQ0kfyPgEm3959RhmWhC5Emjwaw3+isFjU CooGf3wOJvRTnEZRRYJCLm0wensvSOYPWj3pyjM95yUHTFXaj9nQDKAv8ypNu2zvKrfe IYFt6JOX4cu4LDgoQeN1Up+rbGPOpJTzlxpHloevJJQbPdfA4I5AobMMsUol6XUa34Uk juSLybQWqZ/qqUlItWelr8CziyIF9UD5HaPslShY0HAqwMdbScTYbKHCMJd8CyK0hOs1 LRkeHr8O1AyQZ3XWUL37XNh9TOfvuS64Byzzez6MovMDDJZ8c/+TghhHsA2Kiwrk+5+n hBMw== X-Gm-Message-State: AN3rC/6h296QLcItmjKM+5rq8fFiZIblQWgx7E2AHz05Zv3NWD55739W whfznnDQwlIHBGQObEY= X-Received: by 10.223.179.198 with SMTP id x6mr23102163wrd.167.1493991001973; Fri, 05 May 2017 06:30:01 -0700 (PDT) Received: from polaris.localnet (bzq-84-109-69-99.cablep.bezeqint.net. [84.109.69.99]) by smtp.gmail.com with ESMTPSA id 1sm5006403wrw.32.2017.05.05.06.30.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 06:30:01 -0700 (PDT) From: Gregory Etelson To: dev@dpdk.org Date: Fri, 05 May 2017 16:29:59 +0300 Message-ID: <4935498.pT9graIqJa@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] 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:30:02 -0000 bugfix in rte_pktmbuf_alloc_bulk Signed-off-by: Gregory Etelson --- 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++; } -- 2.9.3