From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 8A0D169A4 for ; Thu, 31 Mar 2016 11:44:00 +0200 (CEST) Received: by mail-wm0-f44.google.com with SMTP id p65so106794794wmp.0 for ; Thu, 31 Mar 2016 02:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=gKYTTBfqQY6ipWeV/nc41+jtz5w0h8XojfT1BEXhGks=; b=sZQdpVbpYvjRkWdO/wtTpOOq2IHqMySsoHmRY0lkYKiiIOfHbYQH5E1jMGJ3KdDTpj bL5XUZ6+XcrByfuv9W0b/VzIrG4EaKRNNH2v2kNOavp1ruuX/Gg8qXUUHau5AVZ/mCjJ 3JsFg2p2+AeT5xyD+25NJbOeLeVCY3Rav3PxG3wOJ7clysn3p1xTERA+P0tsHcr08W5w e7IdMQWXzGBUXf4XXEO+VwLDaXaLf1xXSbdb/vYqSr1bnvlZFbt9V6IEIF7xVtnCpUXs dDMl/MqIclNdQER0L3GwDWCcvq/vjmwMrHDJxth572Cj3zx44OtvaofwS1KXwKhm5z1o SJSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=gKYTTBfqQY6ipWeV/nc41+jtz5w0h8XojfT1BEXhGks=; b=NedTlZQeNqOuzq6bZPnT4GBW90T8oV6mrkTwl0YA3TUHcnD4Nzn06FMdQt6trTQN7Z J3NInqj1RITXHtjgF6YyiLqdWrK5aXJUCVYRjsrfHb0CGT2qevZZkhCc0X+hrKGWNQZV iZRCJUiqX+BGN/xmA7oNpj08jvSNIK2CACvEbnmSmNjIfuAsVqP/ZA/QNEt3Y6d4jhcM X7DCPDO4ujAXw/5Sa+dE/s3MlWgnu/9XMjZMyWyXRMqlTxqiFUOOSZEUYO6QgZ6bgMCF YnTD/bTQkmbqVLTd8exD2ytbHzRt1r2QefA5CwlNseCoBWUV73Gat2/DgCOw0+uXbzVV wS2Q== X-Gm-Message-State: AD7BkJJq3qW5nxlWsncFIePi+A+sdy/v8Pi671eD7yQw3IoU44xbPANZMg4t4ojpdLGJpEBp X-Received: by 10.28.19.204 with SMTP id 195mr29958279wmt.1.1459417440413; Thu, 31 Mar 2016 02:44:00 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id lz5sm8152523wjb.5.2016.03.31.02.43.59 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2016 02:43:59 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Thu, 31 Mar 2016 11:43:43 +0200 Message-Id: <1459417423-19776-1-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] mlx: fix double mbuf free in TX queue clean up function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2016 09:44:00 -0000 Once freed, completed mbufs pointers are not set to NULL in the TX queue. Clean up function must take this into account. Fixes: 2e22920b85d9 ("mlx5: support non-scattered Tx and Rx") Fixes: 7fae69eeff13 ("mlx4: new poll mode driver") Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 25 ++++++++++++++++++++----- drivers/net/mlx5/mlx5_rxtx.c | 4 ++++ drivers/net/mlx5/mlx5_txq.c | 21 ++++++++++++++++----- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index f946f08..5cc995f 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -1047,14 +1047,20 @@ error: static void txq_free_elts(struct txq *txq) { - unsigned int i; unsigned int elts_n = txq->elts_n; + unsigned int elts_head = txq->elts_head; + unsigned int elts_tail = txq->elts_tail; struct txq_elt (*elts)[elts_n] = txq->elts; linear_t (*elts_linear)[elts_n] = txq->elts_linear; struct ibv_mr *mr_linear = txq->mr_linear; DEBUG("%p: freeing WRs", (void *)txq); txq->elts_n = 0; + txq->elts_head = 0; + txq->elts_tail = 0; + txq->elts_comp = 0; + txq->elts_comp_cd = 0; + txq->elts_comp_cd_init = 0; txq->elts = NULL; txq->elts_linear = NULL; txq->mr_linear = NULL; @@ -1064,12 +1070,17 @@ txq_free_elts(struct txq *txq) rte_free(elts_linear); if (elts == NULL) return; - for (i = 0; (i != elemof(*elts)); ++i) { - struct txq_elt *elt = &(*elts)[i]; + while (elts_tail != elts_head) { + struct txq_elt *elt = &(*elts)[elts_tail]; - if (elt->buf == NULL) - continue; + assert(elt->buf != NULL); rte_pktmbuf_free(elt->buf); +#ifndef NDEBUG + /* Poisoning. */ + memset(elt, 0x77, sizeof(*elt)); +#endif + if (++elts_tail == elts_n) + elts_tail = 0; } rte_free(elts); } @@ -1588,6 +1599,10 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) if (likely(elt->buf != NULL)) { struct rte_mbuf *tmp = elt->buf; +#ifndef NDEBUG + /* Poisoning. */ + memset(elt, 0x66, sizeof(*elt)); +#endif /* Faster than rte_pktmbuf_free(). */ do { struct rte_mbuf *next = NEXT(tmp); diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index edf64aa..9d1380a 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -120,6 +120,10 @@ txq_complete(struct txq *txq) struct rte_mbuf *tmp = elt->buf; struct txq_elt *elt_next = &(*txq->elts)[elts_free_next]; +#ifndef NDEBUG + /* Poisoning. */ + memset(elt, 0x66, sizeof(*elt)); +#endif RTE_MBUF_PREFETCH_TO_FREE(elt_next->buf); /* Faster than rte_pktmbuf_free(). */ do { diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index ce2bb42..31ce53a 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -144,14 +144,20 @@ error: static void txq_free_elts(struct txq *txq) { - unsigned int i; unsigned int elts_n = txq->elts_n; + unsigned int elts_head = txq->elts_head; + unsigned int elts_tail = txq->elts_tail; struct txq_elt (*elts)[elts_n] = txq->elts; linear_t (*elts_linear)[elts_n] = txq->elts_linear; struct ibv_mr *mr_linear = txq->mr_linear; DEBUG("%p: freeing WRs", (void *)txq); txq->elts_n = 0; + txq->elts_head = 0; + txq->elts_tail = 0; + txq->elts_comp = 0; + txq->elts_comp_cd = 0; + txq->elts_comp_cd_init = 0; txq->elts = NULL; txq->elts_linear = NULL; txq->mr_linear = NULL; @@ -161,12 +167,17 @@ txq_free_elts(struct txq *txq) rte_free(elts_linear); if (elts == NULL) return; - for (i = 0; (i != RTE_DIM(*elts)); ++i) { - struct txq_elt *elt = &(*elts)[i]; + while (elts_tail != elts_head) { + struct txq_elt *elt = &(*elts)[elts_tail]; - if (elt->buf == NULL) - continue; + assert(elt->buf != NULL); rte_pktmbuf_free(elt->buf); +#ifndef NDEBUG + /* Poisoning. */ + memset(elt, 0x77, sizeof(*elt)); +#endif + if (++elts_tail == elts_n) + elts_tail = 0; } rte_free(elts); } -- 2.1.4