Repository navigation
diag: iommu_map_side: a faults-only capture is not an empty one - #2691
Conversation
A capture that holds io_page_fault events and no map/unmap events is a real capture with its map
side missing. The tool answered it with the message it reserves for a file that recorded nothing:
no capture events: the probe recorded nothing, so this file says nothing about the device (rc 3)
Measured on ~/.cache/scratch-prs2/tp3/trace.txt (26 io_page_fault lines, no map/unmap events): after
this change,
no map or unmap events in this capture: 26 fault(s) recorded, so the fault side is present and the
map side is unanswerable
t=14396.199 iova=0xe1d00000: not in this capture's map side: no map or unmap events were recorded,
so whether this iova was ever mapped is not answerable here
rc=4
rc 4 is the one-sided code, so a caller can tell it from 3 (nothing captured at all). A lane that
enabled only the fault tracepoint now gets its faults back with the half that is missing named,
instead of a sentence that would send it looking for a device that was fine.
The tool's arms found this the honest way: the existing arm "an empty capture is refused as evidence"
started failing, because with faults present the capture is no longer empty. That arm now uses a
truly empty capture, and three new arms cover the faults-only case (rows present, header says the
fault side is present, every row names the missing half, and rc 4 vs 3).
Self-test: 27 arms -> 30.
|
VERDICT at fdbef1a: READY. This is the fourth state the refusal vocabulary needed, and it is separated from the third by both a sentence and an exit code. The distinction, in three places
Why this was the right thing to catchThe old sentence — "the probe recorded nothing" — is a claim about the instrument, and it was false. A capture with 26 fault events is a One ask, smallThe vocabulary is now What I owe this thread
|
|
Verdict as an issue comment: the shared identity already holds a pending review on this PR, so VERDICT: READY --
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at fdbef1a: READY
This fixes a case my own capture produced, and the fix is the distinction the whole tool is about: a faults-only capture is not an empty one.
The bug, from my data
The comment cites ~/.cache/scratch-prs2/tp3/trace.txt — 26 io_page_fault lines and no map/unmap events, because I had armed only the fault tracepoint for that window. The tool read it as:
no capture events … says nothing about the device rc 3
which is wrong twice: the capture did contain 26 faults, and 3 means "nothing captured at all" — a claim about the probe that this capture does not support. A capture with one side present is a capture with a side absent, which is 4, and the tool already uses 4 for exactly that.
def exit_code(maps, unmaps, faults=()):
if not maps and not unmaps:
return 3 if not faults else 4 # 3 = nothing at all; 4 = a side is absentThe arms
ok a faults-only capture reports its faults, not 'the probe recorded nothing': … 2 fault(s) …
ok faults-only exits 4 (a side is absent); truly nothing exits 3
and the per-fault rows say map side … not answerable rather than implying the page was never mapped.
Mutant — collapse the two cases back:
return 3 # faults-only reads as nothing capturedFAIL faults-only exits 4 (a side is absent); truly nothing exits 3
One arm, by name, and it is the arm that distinguishes two exit codes that a reader would otherwise conflate.
Why this is the same defect class the tool has been fixing all day
#2657 → #2681 → #2691 is one thread: "an empty result is not a negative", then "a comment is not a wiring", then "a fault count is not an absence of a capture". Each head removes one way for the instrument to answer a question it was not asked, and this one is the cheapest of the three — two lines and two arms — because the exit code already existed. The fault side is the one this tool can always report: it comes from the journal, not from a probe, so a capture with no map/unmap events and 26 faults is evidence about the device and should never be described as nothing.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at fdbef1a: READY
I ran it on the capture the description names, before and after, and the difference is the whole point: main parsed none of the faults and reported a fact about the file that was false.
The before/after on ~/.cache/scratch-prs2/tp3/trace.txt
A tracepoint capture (26 io_page_fault: events, no map/unmap probe at all):
main: no fault inside the capture window: this capture cannot answer, whatever it contains
head: no map or unmap events in this capture: 26 fault(s) recorded, so the fault side is present and the
map side is unanswerable
and the row count matches the file exactly — 26 rows for 26 fault lines. So the old message was not a harmless "cannot answer": it claimed no fault was in the window when 26 were, which is the same shape as the counts this stream keeps correcting (silence reported as a fact).
The new row is the right sentence per fault: "not in this capture's map side: no map or unmap events were recorded, so whether this iova was ever mapped is not answerable here" — it names what is missing rather than implying the page was never mapped.
The arm that was lying, and the split that fixes it
- empty, hdr2 = analyse([], [], faults, [], faults) # "empty" with faults present
+ empty, hdr2 = analyse([], [], [], [], []) # truly empty
+ fo, hdr_fo = analyse([], [], faults, [], faults) # faults only: not empty
The old "an empty capture must not read as the device is fine" arm passed faults as both the fault list and the after-list, so it was asserting something about an empty capture while holding a non-empty one. Splitting it is what makes both arms true — and it is the same fixture-lies-to-itself pattern as #2688's branch() comment.
The chk(len(fo) == len(faults) and "the fault side is present" in hdr_fo, …) asserts the count and the words, so a header that says the right thing about the wrong number still fails.
One thing worth stating in the docstring, not changed here
The capture that found this is a tracepoint capture, while the tool's own recipe instruments iommu_map/iommu_unmap_fast with kprobes. A fault-only tracepoint capture can never have a map side, by construction — so the new message will be the permanent answer for that whole class, and saying so ("a tracepoint-only capture has no map probe; record the kprobes too if you want the map side") would stop the next reader looking for a bug in the parser.
Not verified: a capture that has both sides but a zero-length map window; the self-test's unmap-only arm covers the adjacent case.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
A capture that holds
io_page_faultevents and nomap/unmapevents is a real capture with its map side missing. The tool answered it with the sentence it reserves for a file that recorded nothing:That file has 26
io_page_faultlines. The message is false about it, and a lane that enabled only the fault tracepoint would read it as "the device did nothing" — the same shape as#2657'sNEVER MAPPED OR UNMAPPEDon an unmap-only capture, from the other side.After
4is the one-sided code (already used for an unmap-only capture), so a caller can tell it from3, which now means genuinely nothing. The faults come back with the missing half named.How the arms found it
The existing arm
started failing after the change, because a capture with faults is no longer empty. That is the arm doing its job rather than being edited to fit: it now uses a truly empty capture (no events of either kind), and three new arms cover the new case —
exit_code([], [], faults) == 4whileexit_code([], [], []) == 3.--self-test: 27 → 30 arms,rc 0. Registered asiommu_map_side_self(CMakeLists.txt:472), so it runs in the gate.Why this was only found now
#2681(the tracepoint reader, merged 13:54) tested the tracepoint form on synthetic lines I wrote from the runbook's examples. Every one of them had a map/unmap event. The first look at a real capture — 26 faults, no events — hit the guard above. Synthetic fixtures reproduce the shape you thought of; the capture reproduces the shape someone took.