Skip to content

prov/efa: make the peer map a per-endpoint fi_addr-indexed array#12572

Open
charlesstoll wants to merge 1 commit into
ofiwg:mainfrom
charlesstoll:ep_peer_map_rework
Open

prov/efa: make the peer map a per-endpoint fi_addr-indexed array#12572
charlesstoll wants to merge 1 commit into
ofiwg:mainfrom
charlesstoll:ep_peer_map_rework

Conversation

@charlesstoll

Copy link
Copy Markdown
Contributor

The peer map moves from the shared efa_conn (a uthash keyed by endpoint) to efa_rdm_ep as an fi_addr-indexed ofi_dyn_arr of peer pointers. Because the array is per-endpoint and a lookup is a direct index that never mutates shared state, a peer lookup no longer contends with peer creation on another endpoint. This is a structural step toward removing the SRX lock from the fi_send/CQ-read peer lookup; the locking itself is unchanged here.

The peer map moves from shared efa_conn (a uthash keyed by endpoint)
and to efa_rdm_ep as an fi_addr-indexed ofi_dyn_arr of peer
pointers. Because the array is per-endpoint and a lookup is a direct
index that never mutates shared state, a peer lookup no longer contends
with peer creation on another endpoint. This is a structural step toward
removing the SRX lock from the fi_send/CQ-read peer lookup; the locking
itself is unchanged here.

Signed-off-by: Charles Stoll <stollcha@amazon.com>
int32_t efa_rdm_ep_get_peer_ahn(struct efa_rdm_ep *ep, fi_addr_t addr);
struct efa_rdm_peer *efa_rdm_ep_get_peer_implicit(struct efa_rdm_ep *ep, fi_addr_t addr);

void efa_rdm_peer_map_init(struct ofi_dyn_arr *arr);

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.

functions in this file need to start with efa_rdm_ep_*

{
struct efa_rdm_peer **slot;

if (addr > OFI_IDX_MAX_INDEX)

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.

Do you need this check when ofi_array_at_max have it?

if (index >= max_size || !ofi_array_chunk(arr, index))
		return NULL;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This will go away when I rebase on top of the new ofi_dyn_array changes, but one of the apis did not check properly, so I added the bound check there, and it looked weird so I just added the sanity check to all of them for consistency

"Map entries for fi_addr to peer mapping exhausted.\n");
peer = ofi_buf_alloc(ep->efa_rdm_peer_pool);
if (OFI_UNLIKELY(!peer)) {
EFA_WARN(FI_LOG_EP_DATA, "Cannot allocate peer\n");

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.

for addr %lu\n", addr

efa_conn_ep_peer_map_insert(conn, map_entry);

dlist_insert_tail(&map_entry->peer.ep_peer_list_entry, &ep->ep_peer_list);
if (efa_rdm_peer_map_insert(&ep->fi_addr_to_peer_map, addr, peer)) {

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.

EFA_WARN here

Comment thread prov/efa/src/efa_conn.c
@@ -196,13 +201,26 @@ void efa_conn_rdm_deinit(struct efa_av *av, struct efa_conn *conn)
}

assert(ofi_genlock_held(&((struct efa_rdm_domain *) av->domain)->srx_lock));

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.

remove the srx lock

Comment thread prov/efa/src/efa_conn.c
/* since an efa_conn is all connections to a specific remote ep,
* we must walk all local ep peer maps and remove the connection
* to the remote ep */
dlist_foreach_safe(&av->util_av.ep_list, entry, tmp) {

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.

ofi_genlock_lock(&av->util_av.ep_list_lock); for ep_list

@jiaxiyan
jiaxiyan requested a review from a team July 22, 2026 20:28
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.

2 participants