Skip to content

Commit

Permalink
[v1.21.x] prov/shm: Touch all buffer pages after DSA page fault
Browse files Browse the repository at this point in the history
Previously, it was up to user to set the optional FI_SHM_ENABLE_DSA_PAGE_TOUCH
flag to enable optimization that reduces DSA page faults. If not set,
performance may take a hit for workloads with high page fault counts. We now
always enable this optimization, and thus remove the flag. Workloads with no
page faults are not affected.

DSA page faults will now always trigger touching all of the pages in the
descriptor buffer (as it is done in dsa_touch_buffer_pages()), instead of just
one individual faulting page at a time (as was done in
dsa_handle_page_fault()).

Signed-off-by: Jorge Cabrera <[email protected]>
(cherry picked from commit a5d92f8)
  • Loading branch information
jcabr020 authored and j-xiong committed Jul 19, 2024
1 parent ce2690e commit 8fe4a79
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 43 deletions.
6 changes: 0 additions & 6 deletions man/fi_shm.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@ The *shm* provider checks for the following environment variables:
*FI_SHM_USE_DSA_SAR*
: Enables memory copy offload to Intel DSA in SAR protocol. Default false

*FI_SHM_ENABLE_DSA_PAGE_TOUCH*
: Enables CPU touching of memory pages in a DSA command descriptor when the
page fault is reported, so that there is valid address translation for the
remaining addresses in the command. This minimizes DSA page faults. Default
false

*FI_SHM_USE_XPMEM*
: SHM can use SAR, CMA or XPMEM for host memory transfer. If
FI_SHM_USE_XPMEM is set to 1, the provider will select XPMEM over CMA if
Expand Down
7 changes: 0 additions & 7 deletions man/man7/fi_shm.7
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@ Default false
Enables memory copy offload to Intel DSA in SAR protocol.
Default false
.TP
\f[I]FI_SHM_ENABLE_DSA_PAGE_TOUCH\f[R]
Enables CPU touching of memory pages in a DSA command descriptor when
the page fault is reported, so that there is valid address translation
for the remaining addresses in the command.
This minimizes DSA page faults.
Default false
.TP
\f[I]FI_SHM_USE_XPMEM\f[R]
SHM can use SAR, CMA or XPMEM for host memory transfer.
If FI_SHM_USE_XPMEM is set to 1, the provider will select XPMEM over CMA
Expand Down
27 changes: 1 addition & 26 deletions prov/shm/src/smr_dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ struct smr_dsa_context {
void *wq_portal[MAX_WQS_PER_EP];
int wq_count;
int next_wq;
int enable_dsa_page_touch;

unsigned long copy_type_stats[2];
unsigned long page_fault_stats[2];
Expand Down Expand Up @@ -514,22 +513,6 @@ static void smr_dsa_copy_sar(struct smr_freestack *sar_pool,
dsa_cmd_context->op = cmd->msg.hdr.op;
}

static void dsa_handle_page_fault(struct dsa_completion_record *comp)
{
volatile char *fault_addr;

if (comp->status & DSA_COMP_PAGE_FAULT_NOBOF) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-value"
fault_addr = (char *)comp->fault_addr;

if (comp->status & DSA_COMP_STATUS_WRITE)
*fault_addr = *fault_addr;
else
*fault_addr;
#pragma GCC diagnostic pop
}
}

static void
dsa_process_partially_completed_desc(struct smr_dsa_context *dsa_context,
Expand All @@ -542,8 +525,6 @@ dsa_process_partially_completed_desc(struct smr_dsa_context *dsa_context,
struct dsa_completion_record *comp =
(struct dsa_completion_record *)dsa_descriptor->completion_addr;

dsa_handle_page_fault(comp);

bytes_completed = comp->bytes_completed;

// Update descriptor src & dst buffer based on copy direction; see 8.3.4
Expand All @@ -562,8 +543,7 @@ dsa_process_partially_completed_desc(struct smr_dsa_context *dsa_context,
dsa_prepare_copy_desc(dsa_descriptor, new_xfer_size,
new_src_addr, new_dst_addr);

if (dsa_context->enable_dsa_page_touch)
dsa_touch_buffer_pages(dsa_descriptor);
dsa_touch_buffer_pages(dsa_descriptor);

dsa_desc_submit(dsa_context, dsa_descriptor);
}
Expand Down Expand Up @@ -834,7 +814,6 @@ void smr_dsa_context_init(struct smr_ep *ep)
int wq_count;
struct smr_dsa_context *dsa_context;
unsigned int numa_node;
int enable_dsa_page_touch = 0;

cpu = sched_getcpu();
numa_node = numa_node_of_cpu(cpu);
Expand All @@ -851,9 +830,6 @@ void smr_dsa_context_init(struct smr_ep *ep)
dsa_context = ep->dsa_context;
memset(dsa_context, 0, sizeof(*dsa_context));

fi_param_get_bool(&smr_prov, "enable_dsa_page_touch",
&enable_dsa_page_touch);

wq_count = dsa_idxd_init_wq_array(1, numa_node,
dsa_context->wq_portal);

Expand All @@ -870,7 +846,6 @@ void smr_dsa_context_init(struct smr_ep *ep)

dsa_context->next_wq = 0;
dsa_context->wq_count = wq_count;
dsa_context->enable_dsa_page_touch = enable_dsa_page_touch;

FI_DBG(&smr_prov, FI_LOG_EP_CTRL, "Numa node of endpoint CPU: %d\n",
numa_node);
Expand Down
4 changes: 0 additions & 4 deletions prov/shm/src/smr_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ SHM_INI
"Manually disables CMA. Default: false");
fi_param_define(&smr_prov, "use_dsa_sar", FI_PARAM_BOOL,
"Enable use of DSA in SAR protocol. Default: false");
fi_param_define(&smr_prov, "enable_dsa_page_touch", FI_PARAM_BOOL,
"Enable CPU touching of memory pages in DSA command \
descriptor when page fault is reported. \
Default: false");
fi_param_define(&smr_prov, "use_xpmem", FI_PARAM_BOOL,
"Enable XPMEM over CMA when possible "
"(default: false)");
Expand Down

0 comments on commit 8fe4a79

Please sign in to comment.