Repository navigation
UCP/RKEY: Keep configurations at stable addresses - v1.23.x #12043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2291,9 +2291,8 @@ ucs_status_t ucp_worker_get_ep_config(ucp_worker_h worker, | |||||||||||||||
| return UCS_OK; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| static void | ||||||||||||||||
| ucp_worker_dump_rkey_config_key(ucs_string_buffer_t *log_strb, | ||||||||||||||||
| ucp_rkey_config_key_t *key) | ||||||||||||||||
| static void ucp_worker_dump_rkey_config_key(ucs_string_buffer_t *log_strb, | ||||||||||||||||
| const ucp_rkey_config_key_t *key) | ||||||||||||||||
| { | ||||||||||||||||
| ucs_string_buffer_appendf( | ||||||||||||||||
| log_strb, | ||||||||||||||||
|
|
@@ -2312,6 +2311,8 @@ ucp_worker_add_rkey_config(ucp_worker_h worker, | |||||||||||||||
| const ucp_ep_config_t *ep_config = &ucs_array_elem(&worker->ep_config, | ||||||||||||||||
| key->ep_cfg_index); | ||||||||||||||||
| ucp_worker_cfg_index_t rkey_cfg_index; | ||||||||||||||||
| ucp_rkey_config_t **rkey_config_p; | ||||||||||||||||
| unsigned dump_idx; | ||||||||||||||||
| ucp_rkey_config_t *rkey_config; | ||||||||||||||||
| ucp_lane_index_t lane; | ||||||||||||||||
| ucs_status_t status; | ||||||||||||||||
|
|
@@ -2330,15 +2331,14 @@ ucp_worker_add_rkey_config(ucp_worker_h worker, | |||||||||||||||
| /* Dump all rkey config keys */ | ||||||||||||||||
| ucs_string_buffer_init(&log_strb); | ||||||||||||||||
|
|
||||||||||||||||
| ucs_array_for_each(rkey_config, &worker->rkey_config) { | ||||||||||||||||
| ucs_string_buffer_appendf( | ||||||||||||||||
| &log_strb, "rkey [%ld]: ", | ||||||||||||||||
| rkey_config - ucs_array_begin(&worker->rkey_config)); | ||||||||||||||||
| ucp_worker_dump_rkey_config_key(&log_strb, &rkey_config->key); | ||||||||||||||||
| ucs_array_for_each_index(rkey_config_p, dump_idx, | ||||||||||||||||
| &worker->rkey_config) { | ||||||||||||||||
| ucs_string_buffer_appendf(&log_strb, "rkey [%u]: ", dump_idx); | ||||||||||||||||
| ucp_worker_dump_rkey_config_key(&log_strb, &(*rkey_config_p)->key); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| ucs_string_buffer_appendf(&log_strb, "rkey key new: "); | ||||||||||||||||
| ucp_worker_dump_rkey_config_key(&log_strb, &rkey_config->key); | ||||||||||||||||
| ucp_worker_dump_rkey_config_key(&log_strb, key); | ||||||||||||||||
|
|
||||||||||||||||
| ucs_debug("%s", ucs_string_buffer_cstr(&log_strb)); | ||||||||||||||||
| ucs_string_buffer_cleanup(&log_strb); | ||||||||||||||||
|
|
@@ -2351,11 +2351,12 @@ ucp_worker_add_rkey_config(ucp_worker_h worker, | |||||||||||||||
| (lanes_distance != NULL)); | ||||||||||||||||
|
|
||||||||||||||||
| /* Initialize rkey configuration */ | ||||||||||||||||
| rkey_cfg_index = ucs_array_length(&worker->rkey_config); | ||||||||||||||||
| rkey_config = ucp_worker_config_array_append( | ||||||||||||||||
| worker, &worker->rkey_config, | ||||||||||||||||
| status = UCS_ERR_NO_MEMORY; | ||||||||||||||||
| goto err;); | ||||||||||||||||
| rkey_cfg_index = ucs_array_length(&worker->rkey_config); | ||||||||||||||||
| rkey_config = ucs_malloc(sizeof(*rkey_config), "rkey_config"); | ||||||||||||||||
| if (rkey_config == NULL) { | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls log the allocation failure, like the other allocations in this file (ucs_error("failed to allocate worker ifaces") etc.); previously ucs_array_grow() printed it for us.
Suggested change
|
||||||||||||||||
| status = UCS_ERR_NO_MEMORY; | ||||||||||||||||
| goto err; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| rkey_config->key = *key; | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -2371,6 +2372,11 @@ ucp_worker_add_rkey_config(ucp_worker_h worker, | |||||||||||||||
| sizeof(buf))); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| rkey_config_p = ucp_worker_config_array_append(worker, &worker->rkey_config, | ||||||||||||||||
| status = UCS_ERR_NO_MEMORY; | ||||||||||||||||
| goto err_free_rkey_config;); | ||||||||||||||||
| *rkey_config_p = rkey_config; | ||||||||||||||||
|
|
||||||||||||||||
| /* Save key-to-index lookup */ | ||||||||||||||||
| khiter = kh_put(ucp_worker_rkey_config, &worker->rkey_config_hash, *key, | ||||||||||||||||
| &khret); | ||||||||||||||||
|
|
@@ -2407,6 +2413,8 @@ ucp_worker_add_rkey_config(ucp_worker_h worker, | |||||||||||||||
| kh_del(ucp_worker_rkey_config, &worker->rkey_config_hash, khiter); | ||||||||||||||||
| err_pop_rkey_config: | ||||||||||||||||
| ucs_array_pop_back(&worker->rkey_config); | ||||||||||||||||
| err_free_rkey_config: | ||||||||||||||||
| ucs_free(rkey_config); | ||||||||||||||||
| err: | ||||||||||||||||
| return status; | ||||||||||||||||
| } | ||||||||||||||||
|
|
@@ -2425,29 +2433,30 @@ static void ucp_worker_keepalive_reset(ucp_worker_h worker) | |||||||||||||||
| static void ucp_worker_trace_configs(ucp_worker_h worker) | ||||||||||||||||
| { | ||||||||||||||||
| ucp_ep_config_t *ep_config; | ||||||||||||||||
| ucp_rkey_config_t *rkey_config; | ||||||||||||||||
| ucp_rkey_config_t **rkey_config_p; | ||||||||||||||||
|
|
||||||||||||||||
| ucs_array_for_each(ep_config, &worker->ep_config) { | ||||||||||||||||
| ucp_proto_select_trace(worker, &ep_config->proto_select); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| ucs_array_for_each(rkey_config, &worker->rkey_config) { | ||||||||||||||||
| ucp_proto_select_trace(worker, &rkey_config->proto_select); | ||||||||||||||||
| ucs_array_for_each(rkey_config_p, &worker->rkey_config) { | ||||||||||||||||
| ucp_proto_select_trace(worker, &(*rkey_config_p)->proto_select); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| static void ucp_worker_destroy_configs(ucp_worker_h worker) | ||||||||||||||||
| { | ||||||||||||||||
| ucp_ep_config_t *ep_config; | ||||||||||||||||
| ucp_rkey_config_t *rkey_config; | ||||||||||||||||
| ucp_rkey_config_t **rkey_config_p; | ||||||||||||||||
|
|
||||||||||||||||
| ucs_array_for_each(ep_config, &worker->ep_config) { | ||||||||||||||||
| ucp_ep_config_cleanup(worker, ep_config); | ||||||||||||||||
| } | ||||||||||||||||
| ucs_array_cleanup_dynamic(&worker->ep_config); | ||||||||||||||||
|
|
||||||||||||||||
| ucs_array_for_each(rkey_config, &worker->rkey_config) { | ||||||||||||||||
| ucp_proto_select_cleanup(&rkey_config->proto_select); | ||||||||||||||||
| ucs_array_for_each(rkey_config_p, &worker->rkey_config) { | ||||||||||||||||
| ucp_proto_select_cleanup(&(*rkey_config_p)->proto_select); | ||||||||||||||||
| ucs_free(*rkey_config_p); | ||||||||||||||||
| } | ||||||||||||||||
| ucs_array_cleanup_dynamic(&worker->rkey_config); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,7 +298,7 @@ UCS_PTR_MAP_TYPE(ep, 1); | |
| UCS_PTR_MAP_TYPE(request, 0); | ||
|
|
||
| /* rkey configuration storage */ | ||
| UCS_ARRAY_DECLARE_TYPE(ucp_rkey_config_arr_t, unsigned, ucp_rkey_config_t); | ||
| UCS_ARRAY_DECLARE_TYPE(ucp_rkey_config_arr_t, unsigned, ucp_rkey_config_t*); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this adds an extra pointer dereference to ucp_rkey_config() in the put_short/amo fast path; did you check there is no message-rate impact? |
||
|
|
||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,11 +59,11 @@ class test_ucp_proto : public ucp_test { | |
| static size_t count_rkey_configs_with_flag(ucp_worker_h worker, | ||
| uint8_t flag) | ||
| { | ||
| ucp_rkey_config_t **rkey_config_p; | ||
| size_t count = 0; | ||
| ucp_rkey_config_t *rkey_config; | ||
|
|
||
| ucs_array_for_each(rkey_config, &worker->rkey_config) { | ||
| count += !!(rkey_config->key.flags & flag); | ||
| ucs_array_for_each(rkey_config_p, &worker->rkey_config) { | ||
| count += !!((*rkey_config_p)->key.flags & flag); | ||
| } | ||
|
|
||
| return count; | ||
|
|
@@ -176,7 +176,7 @@ class test_ucp_proto : public ucp_test { | |
| return nullptr; | ||
| } | ||
| auto proto_select = | ||
| &ucs_array_elem(&worker()->rkey_config, rkey_cfg_index).proto_select; | ||
| &ucp_worker_rkey_config(worker(), rkey_cfg_index)->proto_select; | ||
|
|
||
| ucp_proto_select_param_init( | ||
| &select_param, UCP_OP_ID_RNDV_RECV, 0, | ||
|
|
@@ -244,8 +244,8 @@ class test_ucp_proto : public ucp_test { | |
| return nullptr; | ||
| } | ||
|
|
||
| proto_select = &ucs_array_elem(&worker()->rkey_config, | ||
| rkey_cfg_index).proto_select; | ||
| proto_select = | ||
| &ucp_worker_rkey_config(worker(), rkey_cfg_index)->proto_select; | ||
| ucp_proto_select_param_init(&select_param, UCP_OP_ID_RNDV_SEND, 0, | ||
| rndv_op_flag, UCP_DATATYPE_CONTIG, | ||
| &mem_info, 1); | ||
|
|
@@ -343,7 +343,7 @@ class test_ucp_proto_rma_rndv : public test_ucp_proto { | |
| return nullptr; | ||
| } | ||
| proto_select = | ||
| &ucs_array_elem(&worker()->rkey_config, rkey_cfg_index).proto_select; | ||
| &ucp_worker_rkey_config(worker(), rkey_cfg_index)->proto_select; | ||
| ucp_proto_select_param_init(&select_param, op_id, 0, 0, | ||
| UCP_DATATYPE_CONTIG, &mem_info, 1); | ||
| select_elem = ucp_proto_select_lookup_slow( | ||
|
|
@@ -386,8 +386,9 @@ class test_ucp_proto_rma_rndv : public test_ucp_proto { | |
| } | ||
|
|
||
| key.param = remote_proto_config->select_param; | ||
| proto_select = &ucs_array_elem(&worker()->rkey_config, | ||
| remote_proto_config->rkey_cfg_index).proto_select; | ||
| proto_select = &ucp_worker_rkey_config( | ||
| worker(), remote_proto_config->rkey_cfg_index) | ||
| ->proto_select; | ||
| EXPECT_NE(kh_end(proto_select->hash), | ||
| kh_get(ucp_proto_select_hash, proto_select->hash, key.u64)); | ||
| } | ||
|
|
@@ -526,6 +527,29 @@ test_ucp_proto::create_rkey_config_key(ucp_md_map_t md_map) | |
| return rkey_config_key; | ||
| } | ||
|
|
||
| UCS_TEST_P(test_ucp_proto, rkey_config_stable_after_growth) | ||
| { | ||
| ucp_rkey_config_key_t key = create_rkey_config_key(0); | ||
| ucp_worker_cfg_index_t first_index, cfg_index; | ||
| ucp_rkey_config_t **old_buffer; | ||
| ucp_rkey_config_t *first_config; | ||
|
|
||
| key.ep_cfg_index = sender().ep()->cfg_index; | ||
| ASSERT_UCS_OK( | ||
| ucp_worker_rkey_config_get(worker(), &key, NULL, &first_index)); | ||
| first_config = ucp_worker_rkey_config(worker(), first_index); | ||
| old_buffer = ucs_array_begin(&worker()->rkey_config); | ||
|
|
||
| /* Grow past the initial reserve using the production path only */ | ||
| for (key.md_map = 1; key.md_map <= 64; ++key.md_map) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the bound 64 silently depends on the ucs_array_reserve(&worker->rkey_config, 32) in ucp_worker_create(); can we derive it from the initial ucs_array_capacity(&worker()->rkey_config) so ASSERT_NE(old_buffer, ...) does not become a no-op if the reserve changes? |
||
| ASSERT_UCS_OK( | ||
| ucp_worker_rkey_config_get(worker(), &key, NULL, &cfg_index)); | ||
| } | ||
|
|
||
| ASSERT_NE(old_buffer, ucs_array_begin(&worker()->rkey_config)); | ||
| EXPECT_EQ(first_config, ucp_worker_rkey_config(worker(), first_index)); | ||
| } | ||
|
|
||
| UCS_TEST_P(test_ucp_proto, dump_protocols) { | ||
| ucp_proto_select_param_t select_param; | ||
| ucs_string_buffer_t strb; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use UCS_F_ALWAYS_INLINE, since ucp_rkey_config() is on the RMA short path (ucp_put_send_short, amo_send).