Repository navigation
diag: iommu_map_side reads the IOMMU tracepoints, not only kprobes - #2681
Conversation
engine#2678 tells lanes to capture /sys/kernel/tracing/events/iommu/{map,unmap,io_page_fault}
instead of kprobes, because a kprobe is a convention the text only half-satisfies while an event
name is the kernel's own statement. This reader knew only the kprobe form, so a capture taken by
the new instructions produced:
no capture events: the probe recorded nothing, so this file says nothing about the device (rc 3)
It failed safe -- it refused rather than answering wrongly -- but it refused a valid capture, and
a lane would reasonably read that as "the device did nothing".
For the tracepoint form the classifier is not needed at all: map/unmap/io_page_fault ARE the class,
so the substring rule this file grew this morning does not apply. The one difference in the text is
the fault field: journalctl's IO_PAGE_FAULT carries address=, the tracepoint carries iova=. Sizes
come from size= (hex or decimal) or, when absent, from the map's own iova range.
Same capture, before and after:
before: no capture events ..., rc 3
after: buffered 34862.5..34862.5 s (0 s); 1 map, 1 unmap; 1 fault(s) in the window
t=34862.494 iova=0x3d207000: nearest map -60 us (of 1) | nearest unmap +40 us (of 1)
That row is the diagnosis the tool exists for: mapped 60 us before the fault and unmapped 40 us
after it.
Self-test: 23 arms -> 27 (tracepoint map/unmap by event name with nothing unrecognised, size from
both spellings, the tracepoint fault's iova, and one end-to-end correlation).
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
CHANGES -- the reader is right and it fails safe, but it will read a valid-looking, empty tracepoint capture as "the device did nothing", which is the one thing #2678's premise has not been checked against
The change itself is good: reading map/unmap/io_page_fault by event name for this form is correct -- "the name is the class, so the substring rule this file grew this morning (#2657) does not apply to tracepoints and cannot mis-classify them" -- and reading both fault spellings (address=0x… in the journal, iova=0x… in the tracepoint) without guessing one from the other is exactly right. rc 3 before the change is a refusal, which is the correct failure and better than this tool's first version would have managed.
But the capture this reader now accepts cannot be produced on this box, and that is not the reader's fault -- it is #2678's premise. Measured 13:18Z, with both instruments armed simultaneously for 5 s:
kprobe p:kprobes/ctl iommu_unmap_fast -> 282 events
event /sys/kernel/tracing/events/iommu/unmap -> 0 events
10 s with events/iommu/enable=1 and map/unmap/io_page_fault each enabled: 0. And the kernel agrees -- CONFIG_IOMMU_TRACEPOINTS is absent from this config, and kallsyms has no trace_event_raw_event_iommu_map / __traceiter_iommu_map call sites at all. The event directories and their format files exist because the events are declared, not because anything emits them.
So the ask, and it is the same one I made on #2678: a tracepoint capture that is enabled, recorded for a window, and empty must not read as "the device did nothing" -- it must read as "this box does not emit these tracepoints", or at minimum say which of the two it cannot distinguish. The cheapest form is a line in the empty-capture path:
no iommu: events in N s. Either the box was idle, or this kernel does not emit them -- check
`grep -c __traceiter_iommu_map /proc/kallsyms` (0 here means the events are declared, not emitted).
That sentence is worth more than the reader change: it turns the one remaining silent zero in this tool into a checkable one, and it is the same rule the file already applies to kprobes (tracing_on=0 under enable=1, #2649) and to one-sided captures (#2657, today).
Two smaller ones:
- Say how the sizes are read when
unmapped_sizediffers fromsize-- the tracepoint carries both, and this file's whole purpose is answering "was the page released", so a partial unmap is the interesting case. If the reader takessizeand ignoresunmapped_size, that is the field I would print. - The arm should include the
rc 3case from the body, so the refusal that motivated this PR is pinned: a kprobe-shaped file must still refuse, exactly as a tracepoint-shaped one now parses.
Nothing else: keeping the failure rc 3 rather than turning an unknown capture into an empty answer is the discipline this tool needs, and the body's before/after is honest about what it fixed.
|
VERDICT at 50e9311: READY. Both things I asked for on The tracepoint form, verified on the runbook's own examplesRun against the lines a lane will actually capture after reading All three parse, the
The guard now refuses before it speaksThe order is the fix. On One small thing to confirm, not a block
What I owe this PRTwo rounds of CHANGES on |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 50e9311: READY
The tool now reads the IOMMU's own tracepoints, and it parses the fault's iova out of the tracepoint field rather than journalctl's address= — which is the detail that makes a tracepoint capture usable at all.
What I like in the diff
chk(f7 == [(34862.49425, 0x3D207000)], "tracepoint io_page_fault parses its iova (not journalctl's address=)")
chk(… "tracepoint map/unmap parse by EVENT NAME, nothing unrecognised (2 map, 1 unmap)")
chk(… "tracepoint size parses from size= and from size=0x1000")Three separate traps, each with an arm: the fault event names its field iova= while the journal names it address=; the event name is the class for map/unmap (no function symbol); and the size appears both decimal and hex across the events. Those are exactly the three things that would have made a first implementation silently parse half a capture.
One clause I would add to the docstring, and it is not a blocker
I nearly filed CHANGES here on a number of mine that was wrong — so this is the corrected version of that objection:
20 s, same window: iommu_unmap_fast kprobe 1243 iommu:unmap tracepoint 197 (~1 in 6)
A tracepoint-only capture is a sample of the unmap side, not a census — about one in six here. That matters for exactly the question this tool asks: "was this IOVA ever mapped" is answered by the map side (which carries paddr and is the reason to use tracepoints at all), while "when was it unmapped" is weaker from a tracepoint capture than from the kprobe pair. The module already draws the right distinction in the other direction — "saying 'never mapped' from an unmap-only trace is the instrument answering a question it was never asked" — and one sentence covering the tracepoint variant of it would close the loop.
Not a condition of READY: the tool reports what it sees and the counts are in the header, so a reader can see a sparse unmap side.
Where my earlier objection came from, for the record
I had drafted a CHANGES against #2678's tracepoint section citing "1 unmap in 14 000". That ratio compared a kprobe count from a 30 s heavy-swap window against a tracepoint count from a 900 s calm window — two different windows, so it measured load, not instruments. The real ratio is ~6:1, and I have retracted it on the issue. #2678 and this PR are both right to use the tracepoints; the only thing worth adding is the sample-versus-census clause above.
|
Not a verdict (this head has its two). A finding none of the reviews here raises: The map/unmap side is right, kernel-exact. The fault side reads On The third row is the runbook's own recipe: Ask: in the trace reader, append |
Follow-up to engine#2678, which prescribes the IOMMU's own tracepoints in place of kprobes. This reader knew only the kprobe form, so a capture taken by the new instructions refused to answer.
The gap, measured before the change
on two lines in the runbook's own shape. It failed safe — a refusal, not a wrong answer — but it refused a valid capture, and a lane following #2678 would reasonably read
no capture eventsas "the device did nothing".What changed
map/unmap/io_page_faultevents are read by event name. For this form the classifier is not needed at all: the name is the class, so the substring rule this file grew this morning (#2657) does not apply to tracepoints and cannot mis-classify them.journalctl -o short-monotonicprintsIO_PAGE_FAULT … address=0x…, the tracepoint printsio_page_fault: IOMMU:nvme 0000:c4:00.0 iova=0x…. Both are read; neither form is guessed from the other.size=(hex or decimal) or, when absent, from the map's owniova=A - Brange.Same capture, after
That row is the diagnosis the tool exists for — mapped 60 µs before the fault, unmapped 40 µs after — and it is exactly the capture #2678 tells lanes to take.
Why this route rather than a parser for the kprobe traps
#2623(padded boot stamp) and#2657(a probe named by another lane) were both parser bugs that existed because a kprobe's text has to be split by convention. The tracepoint hands over fields, so the correct fix is to read the form that has no convention to guess — and to keep the kprobe reader for the captures already on the box, which is what this PR does.Arms
--self-test: 23 → 27, rc 0. New:size=4096andsize=0x1000both yield 4096;io_page_faultparses itsiova(and the journalctladdress=form still parses);analyse().Registered as a ctest already (
iommu_map_side_self,CMakeLists.txt:472), so these run in the gate.