Conversation
Assigning a packet into its ring buffer slot pulls that slot's cache line in for ownership and dirties it, which buys nothing: the packet processor is the only other reader and it fetches the slot over the fabric anyway. Copy the 60 body bytes with non-temporal stores instead, so they land straight in the write-combining buffer, and keep publishing the header with the existing release store once an sfence has drained that buffer. The header dword stays out of the copy, so the slot holds the invalid header the packet processor left behind until the body has arrived. Covers kernel dispatch, barrier-AND and barrier-value packet submission.
saleelk
requested review from
chrispaquot,
mangupta and
rakesroy
as code owners
September 2, 2026 05:48
MOVDIR64B stores all 64 bytes of a packet as one atomic write, so the packet processor can only observe the slot's old invalid header or the complete new packet -- there is no window where a valid header sits over a body that has not landed yet. It also collapses the non-temporal path's body copy, sfence and separate header store into a single instruction. Detect it from CPUID leaf 7 sub-leaf 0 (ECX bit 28), cache the result, and take that path whenever DEBUG_CLR_USE_MOVDIR64B is non-zero, which it is by default. Hosts without the instruction keep the non-temporal stores. Neither path needs a fence before the doorbell, since ROCr sfences before it writes the hardware doorbell.
lmoriche
reviewed
Sep 15, 2026
lmoriche
reviewed
Sep 15, 2026
| // ================================================================================================ | ||
| static inline bool useMovdir64b() { | ||
| #if defined(ATI_ARCH_X86) && defined(_LP64) | ||
| static const bool enabled = DEBUG_CLR_USE_MOVDIR64B != 0 && Os::hasMovdir64b(); |
Contributor
There was a problem hiding this comment.
Might be good to add a log info so we know what was detected by the runtime.
static auto enabled = []() {
auto flag = DEBUG_CLR_USE_MOVDIR64B != 0 && Os::hasMovdir64b();
LOG_INFO ...
return flag;
}();
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.
Assigning a packet into its ring buffer slot pulls that slot's cache line in for ownership and dirties it, which buys nothing: the packet processor is the only other reader and it fetches the slot over the fabric anyway.
Copy the 60 body bytes with non-temporal stores instead, so they land straight in the write-combining buffer, and keep publishing the header with the existing release store once an sfence has drained that buffer. The header dword stays out of the copy, so the slot holds the invalid header the packet processor left behind until the body has arrived. Covers kernel dispatch, barrier-AND and barrier-value packet submission.
Associated JIRA ticket number/Github issue number
What type of PR is this? (check all applicable)
What were the changes?
Why are these changes needed?
Updated CHANGELOG?
Added/Updated documentation?
Additional Checks