-
Notifications
You must be signed in to change notification settings - Fork 436
feat: add PCIe Relaxed Ordering (RO) support and RDMA traffic class (… #1076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,8 @@ | |||||||||||||||||||||||||||
| #include <set> | ||||||||||||||||||||||||||||
| #include <thread> | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #include <dlfcn.h> | ||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure these two files are common-used in all types RDMA lib
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dlfcn.h is a POSIX standard header that provides dynamic loading functions (dlopen, dlsym, etc.). Also, the previous #include <infiniband/verbs.h> has been removed in the latest revision. |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #include "common.h" | ||||||||||||||||||||||||||||
| #include "config.h" | ||||||||||||||||||||||||||||
| #include "memory_location.h" | ||||||||||||||||||||||||||||
|
|
@@ -32,7 +34,56 @@ | |||||||||||||||||||||||||||
| #include "transport/rdma_transport/rdma_endpoint.h" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| namespace mooncake { | ||||||||||||||||||||||||||||
| RdmaTransport::RdmaTransport() {} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| static bool MCIbRelaxedOrderingEnabled = false; | ||||||||||||||||||||||||||||
| static int MCIbRelaxedOrderingMode = 2; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Mode definition for MC_IB_PCI_RELAXED_ORDERING env. | ||||||||||||||||||||||||||||
| // 0 - disabled, 1 - enabled if supported, 2 - auto (default, same as 1 today). | ||||||||||||||||||||||||||||
| static int getIbRelaxedOrderingMode() { | ||||||||||||||||||||||||||||
| int val = globalConfig().ib_pci_relaxed_ordering_mode; | ||||||||||||||||||||||||||||
| if (val < 0 || val > 2) { | ||||||||||||||||||||||||||||
| return 2; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| return val; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Determine whether RELAXED_ORDERING is enabled and possible | ||||||||||||||||||||||||||||
| // This function checks for ibv_reg_mr_iova2 symbol which is available | ||||||||||||||||||||||||||||
| // in IBVERBS_1.8 and above. The feature is only supported in IBVERBS_1.8+. | ||||||||||||||||||||||||||||
| bool has_ibv_reg_mr_iova2(void) { | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This helper function
Suggested change
|
||||||||||||||||||||||||||||
| void *handle = dlopen("libibverbs.so", RTLD_NOW); | ||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is too tricky for detecting the status.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR introduces Relaxed Ordering (RO) support with two mechanisms: 1. Capability detection This approach is lightweight, reliable for our dynamic-linking model, and consistent with industry practice. |
||||||||||||||||||||||||||||
| if (!handle) { | ||||||||||||||||||||||||||||
| handle = dlopen("libibverbs.so.1", RTLD_NOW); | ||||||||||||||||||||||||||||
| if (!handle) return false; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| void *sym = dlsym(handle, "ibv_reg_mr_iova2"); | ||||||||||||||||||||||||||||
| dlclose(handle); | ||||||||||||||||||||||||||||
| return sym != NULL; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| RdmaTransport::RdmaTransport() { | ||||||||||||||||||||||||||||
| MCIbRelaxedOrderingMode = getIbRelaxedOrderingMode(); | ||||||||||||||||||||||||||||
| if (MCIbRelaxedOrderingMode == 0) { | ||||||||||||||||||||||||||||
| LOG(INFO) << "[RDMA] Relaxed ordering disabled via " | ||||||||||||||||||||||||||||
| << "MC_IB_PCI_RELAXED_ORDERING=0. " | ||||||||||||||||||||||||||||
| << "Falling back to strict ordering."; | ||||||||||||||||||||||||||||
| MCIbRelaxedOrderingEnabled = false; | ||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| MCIbRelaxedOrderingEnabled = has_ibv_reg_mr_iova2(); | ||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use this implementation as a reference? |
||||||||||||||||||||||||||||
| if (MCIbRelaxedOrderingEnabled) { | ||||||||||||||||||||||||||||
| LOG(INFO) << "[RDMA] Relaxed ordering is supported on this host; " | ||||||||||||||||||||||||||||
| "IBV_ACCESS_RELAXED_ORDERING will be requested for " | ||||||||||||||||||||||||||||
| "registered memory regions."; | ||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||
| LOG(INFO) << "[RDMA] Relaxed ordering is NOT supported (" | ||||||||||||||||||||||||||||
| << "ibv_reg_mr_iova2 missing or unavailable). " | ||||||||||||||||||||||||||||
| << "Falling back to strict ordering."; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| RdmaTransport::~RdmaTransport() { | ||||||||||||||||||||||||||||
| #ifdef CONFIG_USE_BATCH_DESC_SET | ||||||||||||||||||||||||||||
|
|
@@ -132,10 +183,17 @@ int RdmaTransport::registerLocalMemory(void *addr, size_t length, | |||||||||||||||||||||||||||
| bool update_metadata) { | ||||||||||||||||||||||||||||
| (void)remote_accessible; | ||||||||||||||||||||||||||||
| BufferDesc buffer_desc; | ||||||||||||||||||||||||||||
| const static int access_rights = IBV_ACCESS_LOCAL_WRITE | | ||||||||||||||||||||||||||||
| IBV_ACCESS_REMOTE_WRITE | | ||||||||||||||||||||||||||||
| IBV_ACCESS_REMOTE_READ; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const int kBaseAccessRights = IBV_ACCESS_LOCAL_WRITE | | ||||||||||||||||||||||||||||
| IBV_ACCESS_REMOTE_WRITE | | ||||||||||||||||||||||||||||
| IBV_ACCESS_REMOTE_READ; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| static int access_rights = 0; | ||||||||||||||||||||||||||||
| if (access_rights == 0) { | ||||||||||||||||||||||||||||
| access_rights = kBaseAccessRights; | ||||||||||||||||||||||||||||
| if (MCIbRelaxedOrderingEnabled) { | ||||||||||||||||||||||||||||
| access_rights |= IBV_ACCESS_RELAXED_ORDERING; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+191
to
+196
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The one-time initialization of
Suggested change
|
||||||||||||||||||||||||||||
| bool do_pre_touch = context_list_.size() > 0 && | ||||||||||||||||||||||||||||
| std::thread::hardware_concurrency() >= 4 && | ||||||||||||||||||||||||||||
| length >= (size_t)4 * 1024 * 1024 * 1024; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the recommended setting for this value?