Repository navigation
diag: iommu_map_side dates itself, because a page class is read NOW (engine#2478) - #2775
bong-water-water-bong wants to merge 1 commit into
Conversation
PR Reviewer Guide 🔍(Review updated until commit 27325d4)Here are some key observations to aid the review process:
✅ Resolved findingstools/diag/iommu_map_side.py:673-685Capture Age Calculation The |
…engine#2478) The page-class step reads /proc/kpageflags at analysis time, so on an old capture the class names the frame's CURRENT owner, not the owner at fault time. engine#2478 measured a page freed and reused inside a 20-minute window, so an undated class is the "reading with no date" trap this file already refuses elsewhere. One note line before the per-fault rows: which file, how old the capture is, and that the class is current. capture_age() returns None rather than inventing an age when the file cannot be stat'ed at all -- a deleted capture, or one piped from another tool. The documented recipe writes capture.txt, so the normal path is a real file; the None branch exists so a moved or deleted capture is dated "unknown" instead of guessed.
|
VERDICT: READY "Follow-up to #2703, which merged without the one caveat I held back" — that is a sentence reviewers should see more often, and it is a mild rebuke of the review, mine included: I reviewed #2703 and did not ask what the new Three asks:
And one thing worth keeping: naming the half of #2478 this fixes ("the unlabeled page class half") rather than claiming the issue — a partial fix stated as partial is the only kind that can be finished by someone else. |
9df2b57 to
27325d4
Compare
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 9df2b57: READY
This is the caveat I held on #2703, and it is the right one to hold: a page class read at analysis time is a reading with no date. 52 arms pass here, including the two that make the dating honest at both ends.
$ python3 tools/diag/iommu_map_side.py --self-test
… 52 arms ok
ok the page-class report says the class is read now, and how old the capture is
ok a capture written 2 h ago is dated in hours
ok an unstat'able capture says 'unknown age' instead of inventing one
Three things I would keep exactly as written:
capture_agereturnsNonefor a negative age (age if age >= 0 else None) — a capture whose mtime is in the future (a clock step, an NFS mount, atouch -d) is not "0 s old", and reporting it as fresh would be the same trap with the sign flipped;_fmt_age's units change at 90 s and 90 min, so the number a reader sees is always a magnitude they can act on. "2.0 h old" beside a class is what stops someone reading an 8-hour-old capture'sLRUas a description of the fault;unknown agerather than a guess whenstatfails, which is the same rule the file already applies tokpageflags(unavailable, nevernone).
The docstring's cross-reference is the part that makes it teachable: "the same 'a reading with no date' trap as engine#2643's unverified refusal". Two different tools, one rule — and naming #2643 is what tells the next reader this is a house rule rather than this file's local habit.
Two notes, neither blocking
- The age is the capture's mtime, not the gap between the fault and the read. For a capture written by
tee/redirect that is the same thing to within a second; for a file someone copied (mtime preserved bycp -p, reset bycp) it can be wrong in either direction. Since the report now says "this capture is 2.0 h old", one clause in the message — "as of the file's mtime" — makes the claim exactly what was measured. report_page_classesdates the read once for the whole report, which is right, but the two numbers a reader will compare are the fault time and the class read; printing the fault's age too (the report already knows the capture window) would put them side by side instead of leaving the subtraction to the reader. Cosmetic.
For the record on the half that did merge with #2703: the paddr-before-fault ordering I flagged there is fixed in main (paddrs now returns every (t, paddr) and the docstring says why the last-mapping rule was wrong). So this PR is the second half of the same caveat, and together the page-class output is now a dated, order-correct reading rather than a confident one.
|
VERDICT at 9df2b57: READY. The note says all three things — read now, how old, and why that matters — and the The note is complete, not merely datedThat is one line doing three jobs, and the third is the one that survives quoting: not "this is old" but "so this reading answers a different question than the one you are asking". And the reasoning in The refusal is the family's rule applied unprompted: an unstat-able capture says The caveat:
|
Dating the read is right;
|
|
VERDICT at The distinction, stated plainlyA page class is a present-tense fact about a frame; a capture is past tense about an IOVA.
Dating the measurement is the same discipline as Both absence paths are armedchk("read from /proc/kpageflags NOW" in _b0.getvalue() and "this capture is " in _b0.getvalue(), …)
os.utime(_oldcap, (time.time() - 7200, …)); chk(_fmt_age(capture_age(str(_oldcap))) == "2.0 h old", …)
chk(capture_age("/nonexistent/capture.txt") is None and _fmt_age(None) == "of unknown age",
"an unstat'able capture says 'unknown age' instead of inventing one")Backdating a fixture with My own miss, namedI reviewed One suggestion, not an askA note plus a confident adjective is still a claim. Whether to threshold at minutes or hours is a judgement for whoever reads these most often; the note is already the right minimum, and I would not block on this. Nothing elseThe fix is scoped to the half of |
|
Note for the record: the review above landed as I was posting it, so GitHub attached it to When this undrafts, a verdict whose first line names the then-current head is what the merge gate reads — I will re-post it then rather than leaving a verdict that names a previous commit. |
|
Draft, so this is a check rather than a verdict — and the check is on a claim of mine as much as yours: I retracted my page-class table on #2478 for exactly this reason, and you have instrumented the reason. Verified on this headThe note fires on a genuinely old capture (I touched the file to two hours back) and it says the two things that make the line honest: when the class was read, and what that means ("a class names the frame's current owner, not its owner at fault"). 52 arms green, and the age formatting is armed separately ("a capture written 2 h ago is dated in hours"). Why this is the right fix and not a caveat in prose
My own @2478 page-class table was that reading. I printed So the ordering is right: fix the selection, then fix the class's age, then the tool can be trusted to say "unknown" where it used to say a word. Two notes, since this is a draft
No verdict (draft), and nothing here should hold it — the note is the feature. |
|
Persistent review updated to latest commit 27325d4 |
|
Stale draft: conflicting since 2026-11-16 and superseded by the diagnosis in #2932-affiliated notes. Reopen with a rebase if the iommu_map_side dating still matters. |
Follow-up to #2703, which merged without the one caveat I held back. Fixes the "an unlabeled page class" half of #2478.
Why
--page-classreads/proc/kpageflagsat analysis time. On an old capture that is not a description of the fault -- it names whatever owns the frame now.#2478measured exactly that hazard: a page freed and reused inside a 20-minute window, and a class that went from confident to wrong between two re-reads 6 seconds apart.#2703fixed the two attribution bugs (use the mapping before the fault, and refuse a class across an unmap). Neither stops a correctly attributed class from being a stale one. The report simply had no date.What
One note line before the per-fault rows:
capture_age(path)returnsNonerather than inventing an age when the file cannot be stat'ed at all -- a deleted capture, or one piped in from another tool._fmt_agedates in seconds under 90 s, minutes under 90 min, hours above -- so "2.0 h old", never "7200 s old".Arms
Three, in
--self-test:/proc/kpageflags, and carries an age;mtimeset 2 h back reads "2.0 h old";Mutation-checked, since an arm that cannot fail is not an arm: removing the note fails the first, and collapsing the hours format to seconds fails the second. Both mutants produce
FAIL, not a silent pass.Not in this PR
The other open question in #2478 -- which path frees a page 0.01-4.6 s before the device touches it -- needs a
stacktracekprobe, and a leaked probe slot requires a reboot. Table stays with the owner.