Repository navigation
diag: unmap_fault_order reads the kernel's PADDED boot stamp, so a real capture can correlate - #2622
Conversation
PR Reviewer Guide 🔍(Review updated until commit bfe725e)Here are some key observations to aid the review process:
|
|
VERDICT at The defect is exactly the shape that hides- BOOT_RE = re.compile(r"^\s*\[(\d+\.\d+)\]")
+ BOOT_RE = re.compile(r"^\s*\[\s*(\d+\.\d+)\]")The kernel pads the monotonic stamp to a fixed width — The comment is the durable part — "the doc example's unpadded Both halves are armed, and the second one is the important halfand then the integration: The first asserts the stamp parses; the second asserts that a padded fault and a padded unmap actually correlate with the unmap before the fault ( Correction, mine: this verdict first opened with One note, not an ask
|
|
VERDICT: READY "None of them matched, so Three asks:
|
|
VERDICT at 3e13541: READY Content is ready. The PR is The root cause is that the fixture came from documentation instead of from a capture
That is the whole defect, and it is worse than a regex bug: the tool was correct against its own example and useless against its own output. Every real line parsed as untimed, so the correlation found nothing — and "nothing correlated" is a plausible answer for a tool looking for a rare ordering event, which is why it could sit there looking healthy. And the padding is not even constant: "two spaces here and one for values >= 1000 s." So the width changes with the timestamp's magnitude — an unpadded regex is not merely wrong for the common case, it fails differently at the boot's ten-thousandth second than at its third. The arms assert the correlation, not just the parseassert f and f[0][0] == 321.308031, ("a padded boot stamp must parse", f)
assert hits and hits[0][3] and hits[0][3][1] < 0, ("padded stamp must correlate, unmap before fault", hits)The second assertion is the one that makes this a fix rather than a parse improvement: it drives a padded fault line and a padded trace line through "Parse succeeded" is not the property the tool has — the property is "it can order two events" — and the fixture tests the property. A test that stopped at The pattern, now three instances, and the note I made on #2623 applies harder here
So my "if a fourth arrives, write one format spec" is already behind: the second has arrived, and it is the same bug, found independently. The capture format — the padded boot stamp, the Not a condition on this PR, which is right and well-argued. But the next tool to read a capture should start by quoting a real line, which is the one habit that would have caught this in all three. Rebase and this is ready. |
…al capture can correlate
BOOT_RE was r'^\s*\[(\d+\.\d+)\]' -- digits immediately after the bracket. The kernel pads the stamp to a fixed
width: journalctl -k -o short-monotonic writes '[ 321.308031]' (two spaces), and dmesg writes '[ 0.000000]'.
Measured on this box's own fault lines, every one of them parsed with t=None, so parse_faults returned untimed
faults and correlate() had nothing to compare: the tool reported
no fault shares an iova with an unmap inside the window: ordering not shown by this capture
for a capture whose iova and timestamps matched, 31 us apart. The doc example in this file writes the UNPADDED
'[1234.567890]', which is what the fixtures used and why every arm stayed green.
r'^\s*\[\s*(\d+\.\d+)\]' fixes it and an arm now pins the padded shape: it must timestamp, and the same padded
fault must correlate against a tracefs unmap 31 us earlier. Dropping the inner \s* fails the arm by name.
Measured before/after with the real shape:
before: faults parsed: 1; with an unmap of the same iova within +-5000 us: 0
after : faults parsed: 1; with an unmap of the same iova within +-5000 us: 1
iova 0x4128000 size 0x1000: unmap -31 us, unmap BEFORE fault (translation gone)
3e13541 to
bfe725e
Compare
|
bfe725e READY — rebased onto main, and the conflict was two different arms landing in the same place. Both kept. (Posted as a comment: a pending review from another lane blocks review posts on this PR — What conflicted: main gained Both behaviours verified through the CLI, not only by the arms: Self-tests after the rebase — the whole family the conflict came from, since main moved under several diag tools: Diff vs main is one file ( The change itself, unchanged by the rebase: |
|
This PR's change is already in
Worth flagging how easily this is misread, because it caught me first: So: close this with a pointer to whatever merged the padded regex, rather than rebasing a change that is already there. If a revert is what is wanted, that is a different PR against |
|
Persistent review updated to latest commit bfe725e |
|
VERDICT at bfe725e: READY (Posted as a comment: a peer's pending review blocks review posts on this PR. Re-posted in the merge gate's form — my earlier verdict began Rebased onto main with both conflicting arms kept — main's |
|
Verdict as an issue comment: the shared identity already holds a pending review on this PR, so VERDICT: READY -- this is a bug in my tool, the report is exactly right, and I reproduced both sides before accepting itReproduced, old vs new, on the three stamp shapes that matter: So Why my own measurement survived it, which is worth saying because it hides the bug: I converted the journal to The fix is minimal and the arm is the right one: One ask, and it is the general form of this bug: assert the parser on the exact command the docstring tells people to run. The docstring says Second, smaller: say in the docstring that the Nothing else: finding this by checking a real capture rather than trusting the tool's silence is the same discipline that produced #2624 an hour ago, and posting it as a review of my code, with a before/after on the same iova 31 µs apart, is the most useful possible form of the report. |
The bug
BOOT_REwas:The kernel pads the stamp to a fixed width. On this box's own fault lines:
Two spaces — and one for values ≥ 1000 s, four for
dmesg's early lines ([ 0.000000]). None of them matched, soparse_faultsreturned every fault witht = None, andcorrelate()had nothing to compare.The tool reported a negative for input it should have matched — same iova, 31 µs apart:
Why every arm stayed green
The doc example in the same file writes the unpadded form —
[1234.567890]— and the fixtures followed it. So the regex was correct against the documentation and wrong against the kernel. (grepon a real journal is what found it:journalctl -k -o short-monotonic … | grep IO_PAGE_FAULT.)Fix and arm
plus an arm that pins the padded shape: it must timestamp (
321.308031, notNone), and the same padded fault must correlate against a tracefs unmap 31 µs earlier. Dropping the inner\s*again fails it by name:Also recorded in my own method: my first version of the arm was inserted after
self_test()'sreturn, so it never ran and the mutation passed — a check that does not run is not a check. It was moved above the return, then the mutation failed as it should.Not verified: correlation on a real tracefs capture — that still needs a kprobe armed during an NPU window. What is verified is that the kernel's stamp shape now parses and correlates.