Skip to content

Commit a1bd92a

Browse files
committed
new config setting - margo.server_address
Allows users to explicity set the Mercury address to use for server-to-server communication. Useful when there are multiple interfaces that support the ofi+tcp protocol, or to use a different protocol. TEST_CHECKPATCH_SKIP_FILES=common/src/unifyfs_configurator.h,docs/configuration.rst
1 parent 8a08146 commit a1bd92a

File tree

5 files changed

+41
-23
lines changed

5 files changed

+41
-23
lines changed

common/src/unifyfs_configurator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
UNIFYFS_CFG(margo, client_pool_size, INT, UNIFYFS_MARGO_POOL_SZ, "size of server's ULT pool for client-server RPCs", NULL) \
9191
UNIFYFS_CFG(margo, client_timeout, INT, UNIFYFS_MARGO_CLIENT_SERVER_TIMEOUT_MSEC, "timeout in milliseconds for client-server RPCs", NULL) \
9292
UNIFYFS_CFG(margo, lazy_connect, BOOL, on, "wait until first communication with server to resolve its connection address", NULL) \
93+
UNIFYFS_CFG(margo, server_address, STRING, NULLSTRING, "Mercury address string to use for Margo init of server-server communication", NULL) \
9394
UNIFYFS_CFG(margo, server_pool_size, INT, UNIFYFS_MARGO_POOL_SZ, "size of server's ULT pool for server-server RPCs", NULL) \
9495
UNIFYFS_CFG(margo, server_timeout, INT, UNIFYFS_MARGO_SERVER_SERVER_TIMEOUT_MSEC, "timeout in milliseconds for server-server RPCs", NULL) \
9596
UNIFYFS_CFG(margo, tcp, BOOL, on, "use TCP for server-to-server margo RPCs", NULL) \

docs/configuration.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,14 @@ files.
128128
.. table:: ``[margo]`` section - margo server NA settings
129129
:widths: auto
130130

131-
============== ==== =================================================================================
132-
Key Type Description
133-
============== ==== =================================================================================
134-
tcp BOOL Use TCP for server-to-server rpcs (default: on, turn off to enable libfabric RMA)
135-
client_timeout INT timeout in milliseconds for rpcs between client and server (default: 5000)
136-
server_timeout INT timeout in milliseconds for rpcs between servers (default: 15000)
137-
============== ==== =================================================================================
131+
============== ====== ====================================================================================
132+
Key Type Description
133+
============== ====== ====================================================================================
134+
tcp BOOL Use TCP for server-to-server rpcs (default: on, turn off to enable libfabric RMA)
135+
client_timeout INT timeout in milliseconds for rpcs between client and server (default: 5000)
136+
server_timeout INT timeout in milliseconds for rpcs between servers (default: 15000)
137+
server_address STRING Mercury address string to use for Margo initialization of inter-server communication
138+
============== ====== ====================================================================================
138139

139140

140141
-----------

server/src/margo_server.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
// global variables
2828
ServerRpcContext_t* unifyfsd_rpc_context;
29+
char* margo_init_address; // = NULL
30+
bool margo_use_address; // = false
2931
bool margo_use_tcp = true;
3032
bool margo_lazy_connect; // = false
3133
int margo_client_server_pool_sz = UNIFYFS_MARGO_POOL_SZ;
@@ -99,31 +101,37 @@ static char* get_margo_addr_str(margo_instance_id mid)
99101
/* setup_remote_target - Initializes the server-server margo target */
100102
static margo_instance_id setup_remote_target(void)
101103
{
102-
/* by default we try to use ofi */
103-
const char* margo_protocol = margo_use_tcp ?
104+
const char* server_addr = NULL;
105+
106+
if (margo_use_address) {
107+
server_addr = margo_init_address;
108+
} else {
109+
/* by default we try to use ofi */
110+
server_addr = margo_use_tcp ?
104111
PROTOCOL_MARGO_OFI_TCP : PROTOCOL_MARGO_OFI_RMA;
105-
if (!margo_protocol) {
106-
/* when ofi is not available, fallback to using bmi */
107-
LOGWARN("OFI is not available, using BMI for margo rpc");
108-
margo_protocol = PROTOCOL_MARGO_BMI_TCP;
112+
if (!server_addr) {
113+
/* when ofi is not available, fallback to using bmi */
114+
LOGWARN("OFI is not available, using BMI for margo rpc");
115+
server_addr = PROTOCOL_MARGO_BMI_TCP;
116+
}
109117
}
110118

111119
/* initialize margo */
112-
margo_instance_id mid = margo_init(margo_protocol, MARGO_SERVER_MODE,
120+
margo_instance_id mid = margo_init(server_addr, MARGO_SERVER_MODE,
113121
margo_use_progress_thread, margo_server_server_pool_sz);
114122
if (mid == MARGO_INSTANCE_NULL) {
115123
LOGERR("margo_init(%s, SERVER_MODE, %d, %d) failed",
116-
margo_protocol, margo_use_progress_thread,
124+
server_addr, margo_use_progress_thread,
117125
margo_server_server_pool_sz);
118-
if (margo_protocol == PROTOCOL_MARGO_OFI_TCP) {
126+
if (server_addr == PROTOCOL_MARGO_OFI_TCP) {
119127
/* try "ofi+sockets" instead */
120-
margo_protocol = PROTOCOL_MARGO_OFI_SOCKETS;
121-
mid = margo_init(margo_protocol, MARGO_SERVER_MODE,
128+
server_addr = PROTOCOL_MARGO_OFI_SOCKETS;
129+
mid = margo_init(server_addr, MARGO_SERVER_MODE,
122130
margo_use_progress_thread,
123131
margo_server_server_pool_sz);
124132
if (mid == MARGO_INSTANCE_NULL) {
125133
LOGERR("margo_init(%s, SERVER_MODE, %d, %d) failed",
126-
margo_protocol, margo_use_progress_thread,
134+
server_addr, margo_use_progress_thread,
127135
margo_server_server_pool_sz);
128136
return mid;
129137
}

server/src/margo_server.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ typedef struct ServerRpcContext {
6868
} ServerRpcContext_t;
6969

7070
extern ServerRpcContext_t* unifyfsd_rpc_context;
71-
71+
extern char* margo_init_address;
72+
extern bool margo_use_address;
7273
extern bool margo_use_tcp;
7374
extern bool margo_lazy_connect;
7475
extern int margo_client_server_pool_sz;

server/src/unifyfs_server.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,16 @@ int main(int argc, char* argv[])
427427
margo_lazy_connect = b;
428428
}
429429

430-
rc = configurator_bool_val(server_cfg.margo_tcp, &b);
431-
if (0 == rc) {
432-
margo_use_tcp = b;
430+
if (server_cfg.margo_server_address != NULL) {
431+
margo_use_address = true;
432+
margo_init_address = strdup(server_cfg.margo_server_address);
433+
}
434+
435+
if (!margo_use_address) {
436+
rc = configurator_bool_val(server_cfg.margo_tcp, &b);
437+
if (0 == rc) {
438+
margo_use_tcp = b;
439+
}
433440
}
434441

435442
rc = margo_server_rpc_init();

0 commit comments

Comments
 (0)