Repository navigation
Fix SRAT entry layout and SLIT distance lookup - #381
Merged
Merged
Conversation
An SRAT affinity structure starts with a one-byte type and a one-byte length; `EntryHeader::length` was a `u16`, which shifted every field after it and broke iteration. `MemoryAffinity::length` read its high half from the base address. `Slit::matrix_raw` required N^4 bytes for an N x N matrix, so any multi-locality table came back empty, and `DistanceMatrix::distance` indexed the transpose and accepted an out-of-range locality.
martin-hughes
requested changes
Nov 11, 2026
martin-hughes
left a comment
Contributor
There was a problem hiding this comment.
Thank you for this @lexoliu!
Good spot, and nice tests.
One minor change please as in the comments. (I do like that you check the structure sizes, it helps stop minor mistakes &/or errors in packing)
martin-hughes
approved these changes
Nov 13, 2026
Contributor
|
Thank you again @lexoliu BTW, I've greatly enjoyed your personal website 😍 |
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.
SRAT and SLIT don't parse correctly at the moment. Four things, all small:
srat::EntryHeader::lengthis au16, but an affinity structure's header is a one-byte type and a one-byte length. Every entry struct came out one byte too large, so each field after the header was read one byte late and the iterator stepped bylength | next_byte << 8. This changes the field's type tou8, and adds size assertions for the six structures (16/40/24/18/12/32 bytes).MemoryAffinity::length()took its high half frombase_address_high.Slit::matrix_raw()checked the table againstN⁴bytes rather thanN², so any SLIT with more than one locality was reported as too short and came back empty (NumaInforeads the matrix through it).DistanceMatrix::distance(i, j)indexedi + j*N, the transpose of the documentedi*N + j, and leti == Nthrough.The tests build a small SRAT and SLIT byte by byte from the spec's layouts; the SLIT uses different distances in each direction so a transposed lookup shows.