Skip to content

Commit 5fa6593

Browse files
committed
cleanup: [ubufs] Log failure to allocate memreg
This can happen when the system does not have enough hugepages. To recognise this mistake sooner, it is useful to have a log for this failure.
1 parent 0738e56 commit 5fa6593

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/lib/ciul/efct_ubufs.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ static int efct_ubufs_local_attach(ef_vi* vi, int qid, int fd,
342342
map, map_bytes, 0);
343343
if( rc < 0 ) {
344344
munmap(map, map_bytes);
345+
LOG(ef_log("%s: Unable to alloc buffers (%d). Are sufficient hugepages available?",
346+
__FUNCTION__, rc));
345347
return rc;
346348
}
347349

@@ -421,14 +423,15 @@ int efct_ubufs_shared_attach_internal(ef_vi* vi, int ix, int qid, void* superbuf
421423
EF_VI_ASSERT(ubufs->shrub_controller_id >= 0);
422424
EF_VI_ASSERT(ubufs->shrub_token_id >= 0);
423425

424-
memset( attach_path, 0, sizeof( attach_path ) );
425-
rc = snprintf( attach_path, sizeof( attach_path ), EF_SHRUB_CONTROLLER_PATH_FORMAT
426-
EF_SHRUB_SHRUB_FORMAT, EF_SHRUB_SOCK_DIR_PATH, ubufs->shrub_controller_id,
427-
ubufs->shrub_token_id );
428-
if ( rc < 0 || rc >= sizeof( attach_path ) )
426+
memset(attach_path, 0, sizeof(attach_path));
427+
rc = snprintf(attach_path, sizeof(attach_path),
428+
EF_SHRUB_CONTROLLER_PATH_FORMAT EF_SHRUB_SHRUB_FORMAT,
429+
EF_SHRUB_SOCK_DIR_PATH, ubufs->shrub_controller_id,
430+
ubufs->shrub_token_id);
431+
if ( rc < 0 || rc >= sizeof(attach_path) )
429432
return -EINVAL;
430433

431-
attach_path[sizeof( attach_path ) - 1] = '\0';
434+
attach_path[sizeof(attach_path) - 1] = '\0';
432435

433436
rc = ef_shrub_client_open(client, superbuf, attach_path, qid);
434437
if ( rc < 0 ) {
@@ -443,7 +446,8 @@ int efct_ubufs_shared_attach_internal(ef_vi* vi, int ix, int qid, void* superbuf
443446

444447
rc = efct_vi_sync_rxq(vi, ix, qid);
445448
if ( rc < 0 ) {
446-
LOG(ef_log("%s: ERROR syncing shrub_client to rxq! rc=%d", __FUNCTION__, rc));
449+
LOG(ef_log("%s: ERROR syncing shrub_client to rxq! rc=%d", __FUNCTION__,
450+
rc));
447451
return rc;
448452
}
449453
return ix;
@@ -465,13 +469,14 @@ static int efct_ubufs_pre_attach(ef_vi* vi, bool shared_mode)
465469

466470
ubufs = get_ubufs(vi);
467471
if( !ubufs->is_shrub_token_set ) {
468-
memset( attach_path, 0, sizeof( attach_path ) );
469-
rc = snprintf( attach_path, sizeof( attach_path ), EF_SHRUB_CONTROLLER_PATH_FORMAT
470-
EF_SHRUB_SHRUB_FORMAT, EF_SHRUB_SOCK_DIR_PATH, ubufs->shrub_controller_id,
471-
ubufs->shrub_token_id );
472-
if ( rc < 0 || rc >= sizeof( attach_path ) )
472+
memset(attach_path, 0, sizeof(attach_path));
473+
rc = snprintf(attach_path, sizeof(attach_path),
474+
EF_SHRUB_CONTROLLER_PATH_FORMAT EF_SHRUB_SHRUB_FORMAT,
475+
EF_SHRUB_SOCK_DIR_PATH, ubufs->shrub_controller_id,
476+
ubufs->shrub_token_id);
477+
if ( rc < 0 || rc >= sizeof(attach_path) )
473478
return -EINVAL;
474-
attach_path[sizeof( attach_path ) - 1] = '\0';
479+
attach_path[sizeof(attach_path) - 1] = '\0';
475480

476481
rc = ef_shrub_client_request_token(attach_path, &response);
477482
if( rc )

0 commit comments

Comments
 (0)