Skip to content

Commit

Permalink
prov/efa: post internal rx pkts uniformly
Browse files Browse the repository at this point in the history
With user recv pkts posted to separate QP, we don't
need to worry about zero copy recv when posting
internal rx pkts.

Signed-off-by: Shi Jin <[email protected]>
  • Loading branch information
shijin-aws committed Jun 25, 2024
1 parent fb27ec1 commit 78c2b34
Showing 1 changed file with 33 additions and 57 deletions.
90 changes: 33 additions & 57 deletions prov/efa/src/rdm/efa_rdm_ep_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,68 +874,44 @@ void efa_rdm_ep_post_internal_rx_pkts(struct efa_rdm_ep *ep)
{
int err;

if (ep->use_zcpy_rx) {
/*
* In zero copy receive mode,
if (ep->efa_rx_pkts_posted == 0 && ep->efa_rx_pkts_to_post == 0 && ep->efa_rx_pkts_held == 0) {
/* All of efa_rx_pkts_posted, efa_rx_pkts_to_post and
* efa_rx_pkts_held equal to 0 means
* this is the first call of the progress engine on this endpoint.
*
* In this case, we explictly allocate the 1st chunk of memory
* for unexp/ooo/readcopy RX packet pool.
*
* The reason to explicitly allocate the memory for RX packet
* pool is to improve efficiency.
*
* If application did not post any receive buffer,
* we post one internal buffer so endpoint can
* receive control packets such as handshake.
* Without explicit memory allocation, a pkt pools's memory
* is allocated when 1st packet is allocated from it.
* During the computation, different processes got their 1st
* unexp/ooo/read-copy packet at different time. Therefore,
* if we do not explicitly allocate memory at the beginning,
* memory will be allocated at different time.
*
* If buffers have posted to the device, we do NOT
* repost internal buffers to maximize the chance
* user buffer is used to receive data.
* When one process is allocating memory, other processes
* have to wait. When each process allocate memory at different
* time, the accumulated waiting time became significant.
*
* By explicitly allocating memory at ep initialization
* engine, the memory allocation is parallelized.
* (This assumes the ep initialization on
* all processes happen at roughly the same time, which
* is a valid assumption according to our knowledge of
* the workflow of most application)
*/
if (ep->efa_rx_pkts_posted == 0 && ep->efa_rx_pkts_to_post == 0) {
ep->efa_rx_pkts_to_post = 1;
} else if (ep->efa_rx_pkts_posted > 0){
ep->efa_rx_pkts_to_post = 0;
}
} else {
if (ep->efa_rx_pkts_posted == 0 && ep->efa_rx_pkts_to_post == 0 && ep->efa_rx_pkts_held == 0) {
/* All of efa_rx_pkts_posted, efa_rx_pkts_to_post and
* efa_rx_pkts_held equal to 0 means
* this is the first call of the progress engine on this endpoint.
*
* In this case, we explictly allocate the 1st chunk of memory
* for unexp/ooo/readcopy RX packet pool.
*
* The reason to explicitly allocate the memory for RX packet
* pool is to improve efficiency.
*
* Without explicit memory allocation, a pkt pools's memory
* is allocated when 1st packet is allocated from it.
* During the computation, different processes got their 1st
* unexp/ooo/read-copy packet at different time. Therefore,
* if we do not explicitly allocate memory at the beginning,
* memory will be allocated at different time.
*
* When one process is allocating memory, other processes
* have to wait. When each process allocate memory at different
* time, the accumulated waiting time became significant.
*
* By explicitly allocating memory at 1st call to progress
* engine, the memory allocation is parallelized.
* (This assumes the 1st call to the progress engine on
* all processes happen at roughly the same time, which
* is a valid assumption according to our knowledge of
* the workflow of most application)
*
* The memory was not allocated during endpoint initialization
* because some applications will initialize some endpoints
* but never uses it, thus allocating memory initialization
* causes waste.
*/
err = efa_rdm_ep_grow_rx_pools(ep);
if (err)
goto err_exit;

ep->efa_rx_pkts_to_post = efa_rdm_ep_get_rx_pool_size(ep);
}
/* only valid for non-zero copy */
assert(ep->efa_rx_pkts_to_post + ep->efa_rx_pkts_posted + ep->efa_rx_pkts_held == efa_rdm_ep_get_rx_pool_size(ep));
err = efa_rdm_ep_grow_rx_pools(ep);
if (err)
goto err_exit;

ep->efa_rx_pkts_to_post = efa_rdm_ep_get_rx_pool_size(ep);
}

assert(ep->efa_rx_pkts_to_post + ep->efa_rx_pkts_posted + ep->efa_rx_pkts_held == efa_rdm_ep_get_rx_pool_size(ep));

err = efa_rdm_ep_bulk_post_internal_rx_pkts(ep);
if (err)
goto err_exit;
Expand Down

0 comments on commit 78c2b34

Please sign in to comment.