Skip to content

Fixes for iodemo and listener destroy flow - #5982

Merged
yosefe merged 2 commits into
openucx:masterfrom
yosefe:topic/fix-iodemo-dtors
Dec 9, 2020
Merged

yosefe merged 2 commits into
openucx:masterfrom
yosefe:topic/fix-iodemo-dtors

Conversation

@yosefe

@yosefe yosefe commented Dec 3, 2020 •

Copy link
Copy Markdown
Member

Why

Fix IODEMO server exit and destructors flow

If a listener is destroyed while it has a pending connect request which
has not been dispatched yet, we must release it. Otherwise,
rdma_destroy_id() will hang while waiting for all events to be released.
@yosefe

yosefe commented Dec 4, 2020

Copy link
Copy Markdown
Member Author

@evgeny-leksikov @alinask pls take a look

ucs_trace("listener %p: destroying", listener);

UCS_ASYNC_BLOCK(&listener->worker->async);
ucs_callbackq_remove_if(&listener->worker->uct->progress_q,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i must be missing something here, where is this function added to the queue?
ucp_cm_server_conn_request_progress_cb_pred()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU ucp_cm_server_conn_request_progress_cb_pred is a predicate callback to remove ucp_cm_server_conn_request_progress from the queue and reject conn request

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alinask it's added in ucp_cm_server_conn_request_cb but not removed in ucp_listener_destroy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yosefe can you please point to where it's added in ucp_cm_server_conn_request_cb?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ucp_cm_server_conn_request_progress,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks but meant where ucp_cm_server_conn_request_progress_cb_pred() is added.
it's kind of an 'extension' of ucp_cm_server_conn_request_progress?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ucp_cm_server_conn_request_progress_cb_pred is not added, it's just helper function for ucs_callbackq_remove_if

delete iter->second;
UCX_LOG << "destroy_connections";
while (!_conns.empty()) {
delete _conns.begin()->second;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like "double free", this way clean up needs pop_front/erase here and _conns.clear() below is redundant
this can re-balance the map on erase, so old code is better

@yosefe yosefe Dec 7, 2020 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed clear()
agree that it can cause redundant rebalance, but IMO it's simpler (than to move all connections to tmp list), and this code part is exit cleanup so perf (up to logn) should not be important

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok on rebalance impact but I still don't understand how does it work:
delete _conns.begin()->second; deletes the second object but doesn't erase begin() element from the map, so while (!_conns.empty()) { is infinite loop which should cause multiple destruction/free of the same object

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the destructor of UcxConnection removes itself from the map
i'll add comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 so that means the old code was actually incorrect

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it was incorrect

ucs_trace("listener %p: destroying", listener);

UCS_ASYNC_BLOCK(&listener->worker->async);
ucs_callbackq_remove_if(&listener->worker->uct->progress_q,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU ucp_cm_server_conn_request_progress_cb_pred is a predicate callback to remove ucp_cm_server_conn_request_progress from the queue and reject conn request

@yosefe
yosefe force-pushed the topic/fix-iodemo-dtors branch from 3d5c076 to ca8ed8d Compare December 7, 2020 20:19
- Destroy all connections to flush requests before destroying memory
  pools
- Avoid removing elements from connections map while iterating over it
@yosefe
yosefe force-pushed the topic/fix-iodemo-dtors branch from ca8ed8d to 3fd1a31 Compare December 8, 2020 12:16
@yosefe
yosefe merged commit f9c253a into openucx:master Dec 9, 2020
@yosefe
yosefe deleted the topic/fix-iodemo-dtors branch December 9, 2020 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants