All of lore.kernel.org
 help / color / mirror / Atom feed
From: dennis.dalessandro@cornelisnetworks.com
To: dledford@redhat.com, jgg@ziepe.ca
Cc: linux-rdma@vger.kernel.org,
	Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>,
	Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Subject: [PATCH for-next 03/10] IB/hfi1: Correct oversized ring allocation
Date: Mon, 29 Mar 2021 09:54:09 -0400	[thread overview]
Message-ID: <1617026056-50483-4-git-send-email-dennis.dalessandro@cornelisnetworks.com> (raw)
In-Reply-To: <1617026056-50483-1-git-send-email-dennis.dalessandro@cornelisnetworks.com>

From: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>

The completion ring for tx is using the wrong size to size the
ring, oversizing the ring by two orders of magniture.

Correct the allocation size and use kcalloc_node() to allocate
the ring.  Fix mistaken GFP defines in similar allocations.

Reviewed-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
---
 drivers/infiniband/hw/hfi1/ipoib.h    |  3 ++-
 drivers/infiniband/hw/hfi1/ipoib_tx.c | 14 +++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/ipoib.h b/drivers/infiniband/hw/hfi1/ipoib.h
index 1659beb..39c8909 100644
--- a/drivers/infiniband/hw/hfi1/ipoib.h
+++ b/drivers/infiniband/hw/hfi1/ipoib.h
@@ -52,8 +52,9 @@
  * @producer_lock: producer sync lock
  * @consumer_lock: consumer sync lock
  */
+struct ipoib_txreq;
 struct hfi1_ipoib_circ_buf {
-	void **items;
+	struct ipoib_txreq **items;
 	unsigned long head;
 	unsigned long tail;
 	unsigned long max_items;
diff --git a/drivers/infiniband/hw/hfi1/ipoib_tx.c b/drivers/infiniband/hw/hfi1/ipoib_tx.c
index e8dece5..1c38c38 100644
--- a/drivers/infiniband/hw/hfi1/ipoib_tx.c
+++ b/drivers/infiniband/hw/hfi1/ipoib_tx.c
@@ -714,14 +714,14 @@ int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv)
 
 	priv->tx_napis = kcalloc_node(dev->num_tx_queues,
 				      sizeof(struct napi_struct),
-				      GFP_ATOMIC,
+				      GFP_KERNEL,
 				      priv->dd->node);
 	if (!priv->tx_napis)
 		goto free_txreq_cache;
 
 	priv->txqs = kcalloc_node(dev->num_tx_queues,
 				  sizeof(struct hfi1_ipoib_txq),
-				  GFP_ATOMIC,
+				  GFP_KERNEL,
 				  priv->dd->node);
 	if (!priv->txqs)
 		goto free_tx_napis;
@@ -753,9 +753,9 @@ int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv)
 					     priv->dd->node);
 
 		txq->tx_ring.items =
-			vzalloc_node(array_size(tx_ring_size,
-						sizeof(struct ipoib_txreq)),
-				     priv->dd->node);
+			kcalloc_node(tx_ring_size,
+				     sizeof(struct ipoib_txreq *),
+				     GFP_KERNEL, priv->dd->node);
 		if (!txq->tx_ring.items)
 			goto free_txqs;
 
@@ -776,7 +776,7 @@ int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv)
 		struct hfi1_ipoib_txq *txq = &priv->txqs[i];
 
 		netif_napi_del(txq->napi);
-		vfree(txq->tx_ring.items);
+		kfree(txq->tx_ring.items);
 	}
 
 	kfree(priv->txqs);
@@ -829,7 +829,7 @@ void hfi1_ipoib_txreq_deinit(struct hfi1_ipoib_dev_priv *priv)
 		hfi1_ipoib_drain_tx_list(txq);
 		netif_napi_del(txq->napi);
 		(void)hfi1_ipoib_drain_tx_ring(txq, txq->tx_ring.max_items);
-		vfree(txq->tx_ring.items);
+		kfree(txq->tx_ring.items);
 	}
 
 	kfree(priv->txqs);
-- 
1.8.3.1


  parent reply	other threads:[~2021-03-29 13:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 13:54 [PATCH for-next 00/10] Fixes for 5.13 dennis.dalessandro
2021-03-29 13:54 ` [PATCH for-next 01/10] IB/hfi1: Add AIP tx traces dennis.dalessandro
2021-03-29 13:54 ` [PATCH for-next 02/10] IB/{ipoib,hfi1}: Add a timeout handler for rdma_netdev dennis.dalessandro
2021-03-29 13:54 ` dennis.dalessandro [this message]
2021-03-29 13:54 ` [PATCH for-next 04/10] IB/hfi1: Use napi_schedule_irqoff() for tx napi dennis.dalessandro
2021-03-29 13:54 ` [PATCH for-next 05/10] IB/hfi1: Remove indirect call to hfi1_ipoib_send_dma() dennis.dalessandro
2021-03-29 13:54 ` [PATCH for-next 06/10] rdma: Set physical MTU for query_port function dennis.dalessandro
2021-04-01  8:42   ` Leon Romanovsky
2021-04-07 23:13     ` Jason Gunthorpe
2021-04-08 12:06     ` Dennis Dalessandro
2021-04-08 12:14       ` Leon Romanovsky
2021-04-08 12:31         ` Dennis Dalessandro
2021-04-19 12:20           ` Wan, Kaike
2021-04-19 12:29             ` Leon Romanovsky
2021-04-19 13:08               ` Dennis Dalessandro
2021-04-20  5:11                 ` Leon Romanovsky
2021-04-20 12:17                   ` Dennis Dalessandro
2021-04-20 12:31                     ` Leon Romanovsky
2021-04-20 12:34                       ` Dennis Dalessandro
2021-04-19 13:09               ` Wan, Kaike
2021-04-20  5:15                 ` Leon Romanovsky
2021-03-29 13:54 ` [PATCH for-next 07/10] IB/hfi1: Add additional usdma traces dennis.dalessandro
2021-03-29 13:54 ` [PATCH for-next 08/10] IB/hfi1: Use kzalloc() for mmu_rb_handler allocation dennis.dalessandro
2021-03-29 13:54 ` [PATCH for-next 09/10] IB/hfi1: Remove unused function dennis.dalessandro
2021-03-29 14:06   ` [PATCH for-next v2 " dennis.dalessandro
2021-03-29 13:54 ` [PATCH for-next 10/10] IB/hfi1: Rework AIP and VNIC dummy netdev usage dennis.dalessandro
2021-04-13 16:59   ` Jason Gunthorpe
2021-04-07 23:21 ` [PATCH for-next 00/10] Fixes for 5.13 Jason Gunthorpe
2021-04-08 12:19   ` Dennis Dalessandro
2021-04-08 12:20     ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1617026056-50483-4-git-send-email-dennis.dalessandro@cornelisnetworks.com \
    --to=dennis.dalessandro@cornelisnetworks.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mike.marciniszyn@cornelisnetworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.