Skip to content

Commit 8c9292d

Browse files
committed
Merge pull request #1721 from hjelmn/xrc_fix
btl/openib: fix XRC WQE calculation
2 parents 49bd28d + 56bdcd0 commit 8c9292d

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

opal/mca/btl/openib/btl_openib_endpoint.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,42 @@ endpoint_init_qp_xrc(mca_btl_base_endpoint_t *ep, const int qp)
183183
(mca_btl_openib_component.use_eager_rdma ?
184184
mca_btl_openib_component.max_eager_rdma : 0);
185185
mca_btl_openib_endpoint_qp_t *ep_qp = &ep->qps[qp];
186+
int32_t wqe, incr = mca_btl_openib_component.qp_infos[qp].u.srq_qp.sd_max;
187+
int rc;
188+
189+
opal_mutex_lock (&ep->ib_addr->addr_lock);
190+
186191
ep_qp->qp = ep->ib_addr->qp;
187-
ep_qp->qp->sd_wqe += mca_btl_openib_component.qp_infos[qp].u.srq_qp.sd_max;
188-
/* make sure that we don't overrun maximum supported by device */
189-
if (ep_qp->qp->sd_wqe > max)
190-
ep_qp->qp->sd_wqe = max;
192+
if (ep->ib_addr->max_wqe + incr > max) {
193+
/* make sure that we don't overrun maximum supported by device */
194+
incr = max - ep->ib_addr->max_wqe;
195+
}
196+
197+
wqe = ep->ib_addr->max_wqe + incr +
198+
(mca_btl_openib_component.use_eager_rdma ?
199+
mca_btl_openib_component.max_eager_rdma : 0);
200+
201+
ep->ib_addr->max_wqe += incr;
202+
203+
if (NULL != ep_qp->qp->lcl_qp) {
204+
struct ibv_qp_attr qp_attr;
205+
206+
/* if this is modified the code in udcm_xrc_send_qp_create may
207+
* need to be updated as well */
208+
qp_attr.cap.max_recv_wr = 0;
209+
qp_attr.cap.max_send_wr = wqe;
210+
qp_attr.cap.max_inline_data = ep->endpoint_btl->device->max_inline_data;
211+
qp_attr.cap.max_send_sge = 1;
212+
qp_attr.cap.max_recv_sge = 1; /* we do not use SG list */
213+
rc = ibv_modify_qp (ep_qp->qp->lcl_qp, &qp_attr, IBV_QP_CAP);
214+
if (0 == rc) {
215+
opal_atomic_add_32 (&ep_qp->qp->sd_wqe, incr);
216+
}
217+
} else {
218+
ep_qp->qp->sd_wqe = ep->ib_addr->max_wqe;
219+
}
191220
ep_qp->qp->users++;
221+
opal_mutex_unlock (&ep->ib_addr->addr_lock);
192222
}
193223

194224
static void endpoint_init_qp(mca_btl_base_endpoint_t *ep, const int qp)

opal/mca/btl/openib/btl_openib_endpoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ typedef struct mca_btl_openib_endpoint_srq_qp_t {
141141
typedef struct mca_btl_openib_qp_t {
142142
struct ibv_qp *lcl_qp;
143143
uint32_t lcl_psn;
144-
int32_t sd_wqe; /**< number of available send wqe entries */
144+
volatile int32_t sd_wqe; /**< number of available send wqe entries */
145145
int32_t sd_wqe_inflight;
146146
int wqe_count;
147147
int users;

opal/mca/btl/openib/btl_openib_xrc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ static void ib_address_constructor(ib_address_t *ib_addr)
125125
ib_addr->lid = 0;
126126
ib_addr->status = MCA_BTL_IB_ADDR_CLOSED;
127127
ib_addr->qp = NULL;
128+
ib_addr->max_wqe = 0;
128129
/* NTH: make the addr_lock recursive because mca_btl_openib_endpoint_connected can call
129130
* into the CPC with the lock held. The alternative would be to drop the lock but the
130131
* lock is never obtained in a critical path. */

opal/mca/btl/openib/btl_openib_xrc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2007-2008 Mellanox Technologies. All rights reserved.
34
* Copyright (c) 2014 Research Organization for Information Science
45
* and Technology (RIST). All rights reserved.
56
* Copyright (c) 2014 Bull SAS. All rights reserved.
67
* Copyright (c) 2015 Research Organization for Information Science
78
* and Technology (RIST). All rights reserved.
9+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
10+
* reserved.
811
* $COPYRIGHT$
912
*
1013
* Additional copyrights may follow
@@ -43,6 +46,7 @@ struct ib_address_t {
4346
uint32_t remote_xrc_rcv_qp_num; /* remote xrc qp number */
4447
opal_mutex_t addr_lock; /* protection */
4548
mca_btl_openib_ib_addr_state_t status; /* ib port status */
49+
int32_t max_wqe;
4650
};
4751
typedef struct ib_address_t ib_address_t;
4852

opal/mca/btl/openib/connect/btl_openib_connect_udcm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2542,7 +2542,7 @@ static int udcm_xrc_send_qp_create (mca_btl_base_endpoint_t *lcl_ep)
25422542
psn = &lcl_ep->qps[0].qp->lcl_psn;
25432543

25442544
/* reserve additional wr for eager rdma credit management */
2545-
send_wr = lcl_ep->ib_addr->qp->sd_wqe +
2545+
send_wr = lcl_ep->ib_addr->max_wqe +
25462546
(mca_btl_openib_component.use_eager_rdma ?
25472547
mca_btl_openib_component.max_eager_rdma : 0);
25482548
#if OPAL_HAVE_CONNECTX_XRC_DOMAINS
@@ -2554,6 +2554,8 @@ static int udcm_xrc_send_qp_create (mca_btl_base_endpoint_t *lcl_ep)
25542554

25552555
qp_init_attr.send_cq = qp_init_attr.recv_cq = openib_btl->device->ib_cq[prio];
25562556

2557+
/* if this code is update the code in endpoint_init_qp_xrc may need to
2558+
* be updated as well */
25572559
/* no need recv queue; receives are posted to srq */
25582560
qp_init_attr.cap.max_recv_wr = 0;
25592561
qp_init_attr.cap.max_send_wr = send_wr;

0 commit comments

Comments
 (0)