From 8fe4a7924a33759137dd9a1169bc60ecc201598d Mon Sep 17 00:00:00 2001 From: "Cabrera, Jorge" Date: Fri, 28 Jun 2024 14:22:28 -0700 Subject: [PATCH] [v1.21.x] prov/shm: Touch all buffer pages after DSA page fault 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 (cherry picked from commit a5d92f8e5805b5c76e9f7e7f79389f662bf18da1) --- man/fi_shm.7.md | 6 ------ man/man7/fi_shm.7 | 7 ------- prov/shm/src/smr_dsa.c | 27 +-------------------------- prov/shm/src/smr_init.c | 4 ---- 4 files changed, 1 insertion(+), 43 deletions(-) diff --git a/man/fi_shm.7.md b/man/fi_shm.7.md index a0ebfa154c7..0fc9bacdfd6 100644 --- a/man/fi_shm.7.md +++ b/man/fi_shm.7.md @@ -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 diff --git a/man/man7/fi_shm.7 b/man/man7/fi_shm.7 index 0775f687f09..6353533c667 100644 --- a/man/man7/fi_shm.7 +++ b/man/man7/fi_shm.7 @@ -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 diff --git a/prov/shm/src/smr_dsa.c b/prov/shm/src/smr_dsa.c index 35491ca2858..5b82b2aed2a 100644 --- a/prov/shm/src/smr_dsa.c +++ b/prov/shm/src/smr_dsa.c @@ -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]; @@ -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, @@ -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 @@ -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); } @@ -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); @@ -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); @@ -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); diff --git a/prov/shm/src/smr_init.c b/prov/shm/src/smr_init.c index b665b94ff75..3f2c6656637 100644 --- a/prov/shm/src/smr_init.c +++ b/prov/shm/src/smr_init.c @@ -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)");