fix(client): Avoid missing final send CQE - #133
Open
nchild-cornelis-networks wants to merge 1 commit into
Open
nchild-cornelis-networks wants to merge 1 commit into
nchild-cornelis-networks wants to merge 1 commit into
Conversation
Swap the order of the atomic_inc and the ib_req_notify_cq when in a send CQ notify callback. Otherwise, there is a possible race with polling the last CQE and re-arming the IB_CQ_NEXT_COMP flag. For example, previously the following series of events was possible: 1. In polling thread, CQE X is polled off the queue 2. In the notify callback thread, the notify for X arrives, it increments the atomic 3. In polling thread: capture atomic, do empty poll, start waiting 4. In RDMA provider thread: Enqueue CQE Y, IB_CQ_NEXT_COMP is not yet set, so don't issue a notify callback 5. In X's notify callback thread, we issue ib_req_notify_cq and wake 6. In poll thread; Is awoken but the waiter's predicate is false, sendCompEventCount is unchanged from step 3, so it sleeps again. 7. Wait with notify armed and and an entry waiting to be polled in the CQE. Eventually timeout. This is a very tight race window but is rather common if the RDMA provider serializes the CQ enqueue, poll, and notify operations (which OPA does). The alternative and proper fix is to implement IB_CQ_REPORT_MISSED_EVENTS, but that would require a larger code overhaul. Signed-off-by: Nick Child <nchild@cornelisnetworks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey all!
So we kept hitting odd timeouts on our small RDMA deployment. We would run elbencho to get a filesystem benchmark and every 50 or so runs the ~10s test would take 5 minutes and eventually result in some messages like:
After much bpftracing, the finding was that there was a CQE just waiting in the CQ with no one polling it for the full timeout window. At the time the CQE was enqueued,
IB_CQ_NEXT_COMPwas not set but it was set sometime after the enqueue..From RDMA providers perspective everything is valid. This is the exact race that
IB_CQ_REPORT_MISSED_EVENTSwas added to catch. Beegfs does not useIB_CQ_REPORT_MISSED_EVENTSso this is not caught.Option 1 is to add beegfs support for
IB_CQ_REPORT_MISSED_EVENTS. I chose not to do this because I do not know if other vendors support this and that would require more code overhaul than just the simple two line change.In the end I could avoid the issue by swapping the ordering of the atomic inc and the req_notify call. This makes sense to me because we don't want to notify about a new CQE UNTIL we are re-armed to capture the next CQE, otherwise there IS a race window and we may miss the next CQE, perhaps I explain this better in the commit message. But essentially, the pseudocode of previous implementation and order of execution was the following: