@@ -38,6 +38,9 @@ static void mca_btl_uct_endpoint_destruct(mca_btl_uct_endpoint_t *endpoint)
38
38
}
39
39
40
40
OBJ_DESTRUCT (& endpoint -> ep_lock );
41
+ if (endpoint -> conn_ep ) {
42
+ OBJ_RELEASE (endpoint -> conn_ep );
43
+ }
41
44
}
42
45
43
46
OBJ_CLASS_INSTANCE (mca_btl_uct_endpoint_t , opal_object_t , mca_btl_uct_endpoint_construct ,
@@ -206,7 +209,6 @@ static int mca_btl_uct_endpoint_send_conn_req(mca_btl_uct_module_t *uct_btl,
206
209
mca_btl_uct_conn_req_t * request ,
207
210
size_t request_length )
208
211
{
209
- mca_btl_uct_connection_ep_t * conn_ep = endpoint -> conn_ep ;
210
212
mca_btl_uct_conn_completion_t completion
211
213
= {.super = {.count = 1 , .func = mca_btl_uct_endpoint_flush_complete }, .complete = false};
212
214
ucs_status_t ucs_status ;
@@ -215,15 +217,13 @@ static int mca_btl_uct_endpoint_send_conn_req(mca_btl_uct_module_t *uct_btl,
215
217
("sending connection request to peer. context id: %d, type: %d, length: %" PRIsize_t ,
216
218
request -> context_id , request -> type , request_length ));
217
219
218
- OBJ_RETAIN (endpoint -> conn_ep );
219
-
220
220
/* need to drop the lock to avoid hold-and-wait */
221
221
opal_mutex_unlock (& endpoint -> ep_lock );
222
222
223
223
do {
224
224
MCA_BTL_UCT_CONTEXT_SERIALIZE (conn_tl_context , {
225
- ucs_status = uct_ep_am_short (conn_ep -> uct_ep , MCA_BTL_UCT_CONNECT_RDMA , request -> type ,
226
- request , request_length );
225
+ ucs_status = uct_ep_am_short (endpoint -> conn_ep -> uct_ep , MCA_BTL_UCT_CONNECT_RDMA ,
226
+ request -> type , request , request_length );
227
227
});
228
228
if (OPAL_LIKELY (UCS_OK == ucs_status )) {
229
229
break ;
@@ -238,11 +238,11 @@ static int mca_btl_uct_endpoint_send_conn_req(mca_btl_uct_module_t *uct_btl,
238
238
} while (1 );
239
239
240
240
/* for now we just wait for the connection request to complete before continuing */
241
- ucs_status = uct_ep_flush (conn_ep -> uct_ep , 0 , & completion .super );
241
+ ucs_status = uct_ep_flush (endpoint -> conn_ep -> uct_ep , 0 , & completion .super );
242
242
if (UCS_OK != ucs_status && UCS_INPROGRESS != ucs_status ) {
243
243
/* NTH: I don't know if this path is needed. For some networks we must use a completion. */
244
244
do {
245
- ucs_status = uct_ep_flush (conn_ep -> uct_ep , 0 , NULL );
245
+ ucs_status = uct_ep_flush (endpoint -> conn_ep -> uct_ep , 0 , NULL );
246
246
mca_btl_uct_context_progress (conn_tl_context );
247
247
} while (UCS_INPROGRESS == ucs_status );
248
248
} else {
@@ -253,8 +253,6 @@ static int mca_btl_uct_endpoint_send_conn_req(mca_btl_uct_module_t *uct_btl,
253
253
254
254
opal_mutex_lock (& endpoint -> ep_lock );
255
255
256
- OBJ_RELEASE (endpoint -> conn_ep );
257
-
258
256
return OPAL_SUCCESS ;
259
257
}
260
258
@@ -265,7 +263,6 @@ static int mca_btl_uct_endpoint_send_connection_data(
265
263
{
266
264
mca_btl_uct_tl_t * conn_tl = uct_btl -> conn_tl ;
267
265
mca_btl_uct_device_context_t * conn_tl_context = conn_tl -> uct_dev_contexts [0 ];
268
- mca_btl_uct_connection_ep_t * conn_ep = endpoint -> conn_ep ;
269
266
uct_device_addr_t * device_addr = NULL ;
270
267
uct_iface_addr_t * iface_addr ;
271
268
ucs_status_t ucs_status ;
@@ -274,31 +271,33 @@ static int mca_btl_uct_endpoint_send_connection_data(
274
271
275
272
BTL_VERBOSE (("connecting endpoint to remote endpoint" ));
276
273
277
- if (NULL == conn_ep ) {
274
+ if (NULL == endpoint -> conn_ep ) {
278
275
BTL_VERBOSE (("creating a temporary endpoint for handling connections to %p" ,
279
276
opal_process_name_print (endpoint -> ep_proc -> proc_name )));
280
277
281
278
iface_addr = (uct_iface_addr_t * ) conn_tl_data ;
282
279
device_addr = (uct_device_addr_t * ) ((uintptr_t ) conn_tl_data
283
280
+ MCA_BTL_UCT_TL_ATTR (conn_tl , 0 ).iface_addr_len );
284
281
285
- endpoint -> conn_ep = conn_ep = OBJ_NEW (mca_btl_uct_connection_ep_t );
286
- if (OPAL_UNLIKELY (NULL == conn_ep )) {
282
+ endpoint -> conn_ep = OBJ_NEW (mca_btl_uct_connection_ep_t );
283
+ if (OPAL_UNLIKELY (NULL == endpoint -> conn_ep )) {
287
284
return OPAL_ERR_OUT_OF_RESOURCE ;
288
285
}
289
286
290
287
/* create a temporary endpoint for setting up the rdma endpoint */
291
288
MCA_BTL_UCT_CONTEXT_SERIALIZE (conn_tl_context , {
292
289
ucs_status = mca_btl_uct_ep_create_connected_compat (conn_tl_context -> uct_iface ,
293
290
device_addr , iface_addr ,
294
- & conn_ep -> uct_ep );
291
+ & endpoint -> conn_ep -> uct_ep );
295
292
});
296
293
if (UCS_OK != ucs_status ) {
297
294
BTL_VERBOSE (
298
295
("could not create an endpoint for forming connection to remote peer. code = %d" ,
299
296
ucs_status ));
300
297
return OPAL_ERROR ;
301
298
}
299
+ } else {
300
+ OBJ_RETAIN (endpoint -> conn_ep );
302
301
}
303
302
304
303
size_t request_length = sizeof (mca_btl_uct_conn_req_t )
@@ -368,6 +367,9 @@ static int mca_btl_uct_endpoint_connect_endpoint(
368
367
if (UCS_OK != ucs_status ) {
369
368
return OPAL_ERROR ;
370
369
}
370
+
371
+ mca_btl_uct_endpoint_set_flag (uct_btl , endpoint , tl_context -> context_id , tl_endpoint ,
372
+ MCA_BTL_UCT_ENDPOINT_FLAG_EP_CONNECTED );
371
373
}
372
374
373
375
opal_timer_t now = opal_timer_base_get_usec ();
@@ -391,7 +393,6 @@ int mca_btl_uct_endpoint_connect(mca_btl_uct_module_t *uct_btl, mca_btl_uct_endp
391
393
mca_btl_uct_device_context_t * tl_context
392
394
= mca_btl_uct_module_get_tl_context_specific (uct_btl , tl , context_id );
393
395
uint8_t * rdma_tl_data = NULL , * conn_tl_data = NULL , * am_tl_data = NULL , * tl_data ;
394
- mca_btl_uct_connection_ep_t * conn_ep = NULL ;
395
396
mca_btl_uct_modex_t * modex ;
396
397
uint8_t * modex_data ;
397
398
size_t msg_size ;
@@ -474,19 +475,8 @@ int mca_btl_uct_endpoint_connect(mca_btl_uct_module_t *uct_btl, mca_btl_uct_endp
474
475
475
476
} while (0 );
476
477
477
- /* to avoid a possible hold-and wait deadlock. destroy the endpoint after dropping the endpoint
478
- * lock. */
479
- if (endpoint -> conn_ep && 1 == endpoint -> conn_ep -> super .obj_reference_count ) {
480
- conn_ep = endpoint -> conn_ep ;
481
- endpoint -> conn_ep = NULL ;
482
- }
483
-
484
478
opal_mutex_unlock (& endpoint -> ep_lock );
485
479
486
- if (conn_ep ) {
487
- OBJ_RELEASE (conn_ep );
488
- }
489
-
490
480
BTL_VERBOSE (("endpoint%s ready for use" , (OPAL_ERR_OUT_OF_RESOURCE != rc ) ? "" : " not yet" ));
491
481
492
482
return rc ;
0 commit comments