From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 4557E1E2F; Thu, 3 May 2018 19:01:42 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 10:01:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,359,1520924400"; d="scan'208";a="225567083" Received: from pakumpul-mobl.ger.corp.intel.com (HELO [10.252.6.99]) ([10.252.6.99]) by fmsmga006.fm.intel.com with ESMTP; 03 May 2018 10:01:39 -0700 To: Reshma Pattan , dev@dpdk.org Cc: stable@dpdk.org backport References: <1525365019-31371-1-git-send-email-reshma.pattan@intel.com> <1525365403-32529-1-git-send-email-reshma.pattan@intel.com> From: "Hunt, David" Message-ID: <1b7454ef-b229-11a2-255f-1b1925893dce@intel.com> Date: Thu, 3 May 2018 18:02:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1525365403-32529-1-git-send-email-reshma.pattan@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v3] app/test: fix reorder test failure 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: Thu, 03 May 2018 17:01:45 -0000 Hi Reshma, On 3/5/2018 5:36 PM, Reshma Pattan wrote: > mbufs are being freed twice in error, once in rte_mempool_put_bulk() > and then in rte_reorder_free(). Refactor the code so that we use > rte_reorder_free() to free mbufs in the reorder buffer, and use > rte_pktmbuf_free() to free any unused or drained mbufs. > > Fixes: d0c9b58d71 ("app/test: new reorder unit test") > Cc: stable@dpdk.org backport > Cc: david.hunt@intel.com > Signed-off-by: Reshma Pattan > --- > v3 > fix the indentation > --- > test/test/test_reorder.c | 35 +++++++++++++++++++++++++---------- > 1 file changed, 25 insertions(+), 10 deletions(-) > > diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c > index 65e4f38b2..b7f664f66 100644 > --- a/test/test/test_reorder.c > +++ b/test/test/test_reorder.c > @@ -146,11 +146,11 @@ test_reorder_insert(void) > b = rte_reorder_create("test_insert", rte_socket_id(), size); > TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); > > - ret = rte_mempool_get_bulk(p, (void *)bufs, num_bufs); > - TEST_ASSERT_SUCCESS(ret, "Error getting mbuf from pool"); > - > - for (i = 0; i < num_bufs; i++) > + for (i = 0; i < num_bufs; i++) { > + bufs[i] = rte_pktmbuf_alloc(p); > + TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); > bufs[i]->seqn = i; > + } > > /* This should fill up order buffer: > * reorder_seq = 0 > @@ -165,6 +165,7 @@ test_reorder_insert(void) > ret = -1; > goto exit; > } > + bufs[i] = NULL; > } > > /* early packet - should move mbufs to ready buf and move sequence window > @@ -179,6 +180,7 @@ test_reorder_insert(void) > ret = -1; > goto exit; > } > + bufs[4] = NULL; > > /* early packet from current sequence window - full ready buffer */ > bufs[5]->seqn = 2 * size; > @@ -189,6 +191,7 @@ test_reorder_insert(void) > ret = -1; > goto exit; > } > + bufs[5] = NULL; > > /* late packet */ > bufs[6]->seqn = 3 * size; > @@ -199,11 +202,15 @@ test_reorder_insert(void) > ret = -1; > goto exit; > } > + bufs[6] = NULL; > > ret = 0; > exit: > - rte_mempool_put_bulk(p, (void *)bufs, num_bufs); > rte_reorder_free(b); > + for (i = 0; i < num_bufs; i++) { > + if (bufs[i] != NULL) > + rte_pktmbuf_free(bufs[i]); > + } > return ret; > } > > @@ -227,9 +234,6 @@ test_reorder_drain(void) > b = rte_reorder_create("test_drain", rte_socket_id(), size); > TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer"); > > - ret = rte_mempool_get_bulk(p, (void *)bufs, num_bufs); > - TEST_ASSERT_SUCCESS(ret, "Error getting mbuf from pool"); > - > /* Check no drained packets if reorder is empty */ > cnt = rte_reorder_drain(b, robufs, 1); > if (cnt != 0) { > @@ -239,8 +243,11 @@ test_reorder_drain(void) > goto exit; > } > > - for (i = 0; i < num_bufs; i++) > + for (i = 0; i < num_bufs; i++) { > + bufs[i] = rte_pktmbuf_alloc(p); > + TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n"); > bufs[i]->seqn = i; > + } > > /* Insert packet with seqn 1: > * reorder_seq = 0 > @@ -248,6 +255,7 @@ test_reorder_drain(void) > * OB[] = {1, NULL, NULL, NULL} > */ > rte_reorder_insert(b, bufs[1]); > + bufs[1] = NULL; > > cnt = rte_reorder_drain(b, robufs, 1); I think we need a loop here to pktmbuf_free() each of the mbufs in the robufs array that was populated by the drain() function. > if (cnt != 1) { > @@ -263,18 +271,22 @@ test_reorder_drain(void) > */ > rte_reorder_insert(b, bufs[2]); > rte_reorder_insert(b, bufs[3]); > + bufs[2] = NULL; > + bufs[3] = NULL; > > /* Insert more packets > * RB[] = {NULL, NULL, NULL, NULL} > * OB[] = {NULL, 2, 3, 4} > */ > rte_reorder_insert(b, bufs[4]); > + bufs[4] = NULL; > > /* Insert more packets > * RB[] = {2, 3, 4, NULL} > * OB[] = {NULL, NULL, 7, NULL} > */ > rte_reorder_insert(b, bufs[7]); > + bufs[7] = NULL; > > /* drained expected packets */ > cnt = rte_reorder_drain(b, robufs, 4); And again here. > @@ -298,8 +310,11 @@ test_reorder_drain(void) > } > ret = 0; > exit: > - rte_mempool_put_bulk(p, (void *)bufs, num_bufs); > rte_reorder_free(b); > + for (i = 0; i < num_bufs; i++) { > + if (bufs[i] != NULL) > + rte_pktmbuf_free(bufs[i]); > + } > return ret; > } > Reviewed-by: David Hunt Thanks, Dave.