浏览代码

RDS/IB: add _to_node() macros for numa and use {k,v}malloc_node()

Allocate send/recv rings in memory that is node-local to the HCA.
This significantly helps performance.

Signed-off-by: Andy Grover <andy.grover@oracle.com>
Andy Grover 15 年之前
父节点
当前提交
e4c52c98e0
共有 4 个文件被更改,包括 14 次插入5 次删除
  1. 1 1
      net/rds/ib.c
  2. 6 0
      net/rds/ib.h
  3. 4 2
      net/rds/ib_cm.c
  4. 3 2
      net/rds/ib_rdma.c

+ 1 - 1
net/rds/ib.c

@@ -77,7 +77,7 @@ void rds_ib_add_one(struct ib_device *device)
 		goto free_attr;
 		goto free_attr;
 	}
 	}
 
 
-	rds_ibdev = kmalloc(sizeof *rds_ibdev, GFP_KERNEL);
+	rds_ibdev = kmalloc_node(sizeof *rds_ibdev, GFP_KERNEL, ibdev_to_node(device));
 	if (!rds_ibdev)
 	if (!rds_ibdev)
 		goto free_attr;
 		goto free_attr;
 
 

+ 6 - 0
net/rds/ib.h

@@ -3,6 +3,8 @@
 
 
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_verbs.h>
 #include <rdma/rdma_cm.h>
 #include <rdma/rdma_cm.h>
+#include <linux/pci.h>
+#include <linux/slab.h>
 #include "rds.h"
 #include "rds.h"
 #include "rdma_transport.h"
 #include "rdma_transport.h"
 
 
@@ -167,6 +169,10 @@ struct rds_ib_device {
 	spinlock_t		spinlock;	/* protect the above */
 	spinlock_t		spinlock;	/* protect the above */
 };
 };
 
 
+#define pcidev_to_node(pcidev) pcibus_to_node(pcidev->bus)
+#define ibdev_to_node(ibdev) pcidev_to_node(to_pci_dev(ibdev->dma_device))
+#define rdsibdev_to_node(rdsibdev) ibdev_to_node(rdsibdev->dev)
+
 /* bits for i_ack_flags */
 /* bits for i_ack_flags */
 #define IB_ACK_IN_FLIGHT	0
 #define IB_ACK_IN_FLIGHT	0
 #define IB_ACK_REQUESTED	1
 #define IB_ACK_REQUESTED	1

+ 4 - 2
net/rds/ib_cm.c

@@ -347,7 +347,8 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
 		goto out;
 		goto out;
 	}
 	}
 
 
-	ic->i_sends = vmalloc(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work));
+	ic->i_sends = vmalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work),
+				   ibdev_to_node(dev));
 	if (!ic->i_sends) {
 	if (!ic->i_sends) {
 		ret = -ENOMEM;
 		ret = -ENOMEM;
 		rdsdebug("send allocation failed\n");
 		rdsdebug("send allocation failed\n");
@@ -355,7 +356,8 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
 	}
 	}
 	memset(ic->i_sends, 0, ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work));
 	memset(ic->i_sends, 0, ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work));
 
 
-	ic->i_recvs = vmalloc(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work));
+	ic->i_recvs = vmalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work),
+				   ibdev_to_node(dev));
 	if (!ic->i_recvs) {
 	if (!ic->i_recvs) {
 		ret = -ENOMEM;
 		ret = -ENOMEM;
 		rdsdebug("recv allocation failed\n");
 		rdsdebug("recv allocation failed\n");

+ 3 - 2
net/rds/ib_rdma.c

@@ -297,7 +297,7 @@ static struct rds_ib_mr *rds_ib_alloc_fmr(struct rds_ib_device *rds_ibdev)
 		rds_ib_flush_mr_pool(pool, 0);
 		rds_ib_flush_mr_pool(pool, 0);
 	}
 	}
 
 
-	ibmr = kzalloc(sizeof(*ibmr), GFP_KERNEL);
+	ibmr = kzalloc_node(sizeof(*ibmr), GFP_KERNEL, rdsibdev_to_node(rds_ibdev));
 	if (!ibmr) {
 	if (!ibmr) {
 		err = -ENOMEM;
 		err = -ENOMEM;
 		goto out_no_cigar;
 		goto out_no_cigar;
@@ -376,7 +376,8 @@ static int rds_ib_map_fmr(struct rds_ib_device *rds_ibdev, struct rds_ib_mr *ibm
 	if (page_cnt > fmr_message_size)
 	if (page_cnt > fmr_message_size)
 		return -EINVAL;
 		return -EINVAL;
 
 
-	dma_pages = kmalloc(sizeof(u64) * page_cnt, GFP_ATOMIC);
+	dma_pages = kmalloc_node(sizeof(u64) * page_cnt, GFP_ATOMIC,
+				 rdsibdev_to_node(rds_ibdev));
 	if (!dma_pages)
 	if (!dma_pages)
 		return -ENOMEM;
 		return -ENOMEM;