Skip to content

Commit

Permalink
RDMA/rds: Remove FMR support for memory registration
Browse files Browse the repository at this point in the history
Use FRWR method for memory registration by default and remove the ancient
and unsafe FMR method.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Max Gurtovoy <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
Max Gurtovoy authored and jgunthorpe committed Jun 2, 2020
1 parent f273ad4 commit 07549ee
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 322 deletions.
2 changes: 1 addition & 1 deletion net/rds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rds-y := af_rds.o bind.o cong.o connection.o info.o message.o \
obj-$(CONFIG_RDS_RDMA) += rds_rdma.o
rds_rdma-y := rdma_transport.o \
ib.o ib_cm.o ib_recv.o ib_ring.o ib_send.o ib_stats.o \
ib_sysctl.o ib_rdma.o ib_fmr.o ib_frmr.o
ib_sysctl.o ib_rdma.o ib_frmr.o


obj-$(CONFIG_RDS_TCP) += rds_tcp.o
Expand Down
20 changes: 7 additions & 13 deletions net/rds/ib.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ void rds_ib_dev_put(struct rds_ib_device *rds_ibdev)
static int rds_ib_add_one(struct ib_device *device)
{
struct rds_ib_device *rds_ibdev;
bool has_fr, has_fmr;
int ret;

/* Only handle IB (no iWARP) devices */
if (device->node_type != RDMA_NODE_IB_CA)
return -EOPNOTSUPP;

/* Device must support FRWR */
if (!(device->attrs.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS))
return -EOPNOTSUPP;

rds_ibdev = kzalloc_node(sizeof(struct rds_ib_device), GFP_KERNEL,
ibdev_to_node(device));
if (!rds_ibdev)
Expand All @@ -152,11 +155,6 @@ static int rds_ib_add_one(struct ib_device *device)
rds_ibdev->max_wrs = device->attrs.max_qp_wr;
rds_ibdev->max_sge = min(device->attrs.max_send_sge, RDS_IB_MAX_SGE);

has_fr = (device->attrs.device_cap_flags &
IB_DEVICE_MEM_MGT_EXTENSIONS);
has_fmr = (device->ops.alloc_fmr && device->ops.dealloc_fmr &&
device->ops.map_phys_fmr && device->ops.unmap_fmr);
rds_ibdev->use_fastreg = (has_fr && !has_fmr);
rds_ibdev->odp_capable =
!!(device->attrs.device_cap_flags &
IB_DEVICE_ON_DEMAND_PAGING) &&
Expand All @@ -165,7 +163,6 @@ static int rds_ib_add_one(struct ib_device *device)
!!(device->attrs.odp_caps.per_transport_caps.rc_odp_caps &
IB_ODP_SUPPORT_READ);

rds_ibdev->fmr_max_remaps = device->attrs.max_map_per_fmr?: 32;
rds_ibdev->max_1m_mrs = device->attrs.max_mr ?
min_t(unsigned int, (device->attrs.max_mr / 2),
rds_ib_mr_1m_pool_size) : rds_ib_mr_1m_pool_size;
Expand Down Expand Up @@ -219,14 +216,11 @@ static int rds_ib_add_one(struct ib_device *device)
goto put_dev;
}

rdsdebug("RDS/IB: max_mr = %d, max_wrs = %d, max_sge = %d, fmr_max_remaps = %d, max_1m_mrs = %d, max_8k_mrs = %d\n",
rdsdebug("RDS/IB: max_mr = %d, max_wrs = %d, max_sge = %d, max_1m_mrs = %d, max_8k_mrs = %d\n",
device->attrs.max_fmr, rds_ibdev->max_wrs, rds_ibdev->max_sge,
rds_ibdev->fmr_max_remaps, rds_ibdev->max_1m_mrs,
rds_ibdev->max_8k_mrs);
rds_ibdev->max_1m_mrs, rds_ibdev->max_8k_mrs);

pr_info("RDS/IB: %s: %s supported and preferred\n",
device->name,
rds_ibdev->use_fastreg ? "FRMR" : "FMR");
pr_info("RDS/IB: %s: added\n", device->name);

down_write(&rds_ib_devices_lock);
list_add_tail_rcu(&rds_ibdev->list, &rds_ib_devices);
Expand Down
2 changes: 0 additions & 2 deletions net/rds/ib.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,11 @@ struct rds_ib_device {
struct ib_device *dev;
struct ib_pd *pd;
struct dma_pool *rid_hdrs_pool; /* RDS headers DMA pool */
u8 use_fastreg:1;
u8 odp_capable:1;

unsigned int max_mrs;
struct rds_ib_mr_pool *mr_1m_pool;
struct rds_ib_mr_pool *mr_8k_pool;
unsigned int fmr_max_remaps;
unsigned int max_8k_mrs;
unsigned int max_1m_mrs;
int max_sge;
Expand Down
4 changes: 2 additions & 2 deletions net/rds/ib_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,10 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
return -EOPNOTSUPP;

/* The fr_queue_space is currently set to 512, to add extra space on
* completion queue and send queue. This extra space is used for FRMR
* completion queue and send queue. This extra space is used for FRWR
* registration and invalidation work requests
*/
fr_queue_space = (rds_ibdev->use_fastreg ? RDS_IB_DEFAULT_FR_WR : 0);
fr_queue_space = RDS_IB_DEFAULT_FR_WR;

/* add the conn now so that connection establishment has the dev */
rds_ib_add_conn(rds_ibdev, conn);
Expand Down
269 changes: 0 additions & 269 deletions net/rds/ib_fmr.c

This file was deleted.

4 changes: 2 additions & 2 deletions net/rds/ib_frmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static struct rds_ib_mr *rds_ib_alloc_frmr(struct rds_ib_device *rds_ibdev,

frmr = &ibmr->u.frmr;
frmr->mr = ib_alloc_mr(rds_ibdev->pd, IB_MR_TYPE_MEM_REG,
pool->fmr_attr.max_pages);
pool->max_pages);
if (IS_ERR(frmr->mr)) {
pr_warn("RDS/IB: %s failed to allocate MR", __func__);
err = PTR_ERR(frmr->mr);
Expand Down Expand Up @@ -240,7 +240,7 @@ static int rds_ib_map_frmr(struct rds_ib_device *rds_ibdev,
}
frmr->dma_npages += len >> PAGE_SHIFT;

if (frmr->dma_npages > ibmr->pool->fmr_attr.max_pages) {
if (frmr->dma_npages > ibmr->pool->max_pages) {
ret = -EMSGSIZE;
goto out_unmap;
}
Expand Down
Loading

0 comments on commit 07549ee

Please sign in to comment.