Skip to content

diag: the fault stream must cover every class the gate refuses on, not page faults alone (engine#3067) - #3068

Merged
bong-water-water-bong merged 2 commits into
mainfrom
pkg-sampler-faultcov
Nov 21, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
pkg-sampler-faultcov

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3067.

The sampler's capture stream grepped IO_PAGE_FAULT alone, so an NPU TDR + power-cycle — the fault class that bounces
every GPU take — never reached the record: at 22:10:43Z on 2026-11-20 four aie2_tdr/aie2_hw_reset kernel lines were
logged while the unit was running, and samples.log, attributed.log and summary.txt each gained 0 records for
that window (issue has the four lines, the counts and srcversion 5682285F370899D14A057FF).

The change is the streaming grep, made a superset of the pattern the gate refuses on (scripts/gpu-hold
GPU_FAULT_RE), because a recorder may carry a line the gate ignores but must never miss one the gate acts on:

FAULT_RE='IO_PAGE_FAULT|aie2_tdr|aie2_hw_reset|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)|MES.*(reset|failure|failed to respond)'

plus the empty-window line, which said no IO_PAGE_FAULT was seen — accurate, and misread as "no fault" by exactly the
reader this instrument exists for.

The device split needed no change and the diff proves it: a TDR line's token after kernel: is amdxdna, the same
token the summary's awk reads.

Verification

  • accel_sampler.sh selftest — ok from a repo checkout.
  • The arm discriminates, by mutation: with FAULT_RE='IO_PAGE_FAULT' restored in place, the new arm fails
    (FAIL: an NPU TDR / power-cycle line does not reach the fault stream); with the widened pattern, self-test: ok.
  • Three arms added: the two real 22:10:43Z lines must both match; an NVMe IO_PAGE_FAULT line must still match (the
    widening must not drop the class it used to carry); and a TDR record must be attributed to amdxdna in the summary.
  • Not deployed by this PR: the box runs 241ff14ec's bytes (check-deployed: ok). Deployment follows the merge —
    install refuses without an explicit destination, and redeploying a branch under test is the mistake diag: install requires a destination and reads the commit from the checkout (engine#2795 follow-up) #2815 documents.

…t page faults alone (engine#3067)

Measured: four aie2_tdr/aie2_hw_reset lines at 22:10:43Z on 2026-11-20 while the sampler was up, and zero records —
samples.log, attributed.log and summary.txt all stayed empty for a window the instrument claimed to cover.

FAULT_RE is now a superset of scripts/gpu-hold's GPU_FAULT_RE; the per-device split is unchanged because a TDR line's
token after `kernel: ` is still amdxdna. Arms: both real TDR lines match, an NVMe IO_PAGE_FAULT still matches, and a
TDR record is attributed to amdxdna. Mutation-verified: the old pattern fails the new arm, the new one passes.
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit b7ff6f8)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3067 - Partially compliant

Compliant requirements:

  • The fault sampler's capture stream now covers all fault classes the gate refuses on, including TDR and power-cycle events
  • NPU TDR and power-cycle events are now recorded by the sampler
  • The summary message has been updated to reflect the broader set of fault events
  • The device split logic remains unchanged as verified by the test cases

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Fault Coverage Improvement

The fault stream now covers all fault classes that the gate refuses on, including TDR and power-cycle events, which were previously missed. This ensures that the sampler can accurately attribute faults that occur within a window, even when they are not IO_PAGE_FAULT events. The change updates the FAULT_RE pattern to include aie2_tdr and aie2_hw_reset, which were previously excluded.

FAULT_RE='\[gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout|MES.*(reset|failure|failed to respond)|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)|IO_PAGE_FAULT|aie2_tdr|aie2_hw_reset'
Summary Message Update

The summary message has been updated to reflect that the sampler now records a broader set of fault events, not just IO_PAGE_FAULT events. This prevents misinterpretation of clean windows when TDR or power-cycle events occurred but were not captured by the previous pattern. The old message "no IO_PAGE_FAULT was seen in this window" has been changed to a more accurate message about fault lines.

echo "## no fault line (page fault, amdgpu/MES reset, amdxdna TDR/power-cycle) was seen in this window"
✅ Resolved findings

tools/diag/accel_sampler.sh:252

Fault Coverage Improvement

The fault stream now covers all fault classes that the gate refuses on, including TDR and power-cycle events, which were previously missed. This ensures that the sampler can accurately attribute faults that occur within a window, even when they are not IO_PAGE_FAULT events.

tools/diag/accel_sampler.sh:306

Summary Message Update

The summary message has been updated to reflect that the sampler now records a broader set of fault events, not just IO_PAGE_FAULT events. This prevents misinterpretation of clean windows when TDR or power-cycle events occurred but were not captured by the previous pattern.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

How big the blind spot was, measured on this box's last 24 h of kernel log (read-only, no device, no build):

$ journalctl -k --since -24h | grep -cE 'IO_PAGE_FAULT'                                  -> 10   (the shipped pattern)
$ journalctl -k --since -24h | grep -cE "$NEW_PATTERN"                                    -> 22
$ ... | grep -E "$NEW_PATTERN" | grep -vE 'IO_PAGE_FAULT' | wc -l                         -> 12   (all of it new)
$ ... | grep -E "$NEW_PATTERN" | grep -vE 'IO_PAGE_FAULT' | grep -oE 'kernel: [a-z0-9_]+' | sort | uniq -c
     12 kernel: amdxdna

The 12 new lines are three complete NPU TDR + power-cycle episodes, four lines each, at 19:05:23Z, 19:41:53Z
and 22:10:43Z (aie2_tdr_dead_fw_detect → aie2_tdr_work_func → aie2_tdr_dead_fw_recover_all →
aie2_hw_reset). The sampler recorded 0 of 12: it was up for all three.

The contrast that decides the shape of the fix — same 12 lines against the gate's own pattern
(scripts/gpu-hold GPU_FAULT_RE): 6 of 12. It matches the two power-cycling lines per episode and neither
aie2_tdr_dead_fw_detect nor aie2_tdr_work_func, which is right for a gate that only has to refuse, and wrong for a
record whose job is to name what happened.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

This is the same class one layer down, and the timing of it is the argument:

"at 22:10:43Z on 2026-11-20 four aie2_tdr/aie2_hw_reset ke[rnel lines were] logged while the unit was running, and samples.log, attributed.log and summary.txt each gained 0 [lines] in that window"

I captured that exact episode forty minutes ago with a watcher I wrote for it — same timestamp, same four lines, population seven. The fleet's official sampler missed the event that a hand-rolled journalctl -k -f | grep caught, because the sampler's pattern was narrower than its purpose. A recorder that greps one fault class is a recorder that reports "no faults" for every other class, which is the unknown ≠ 0 defect with a log file attached.

And the fix is stated as the right relationship, not as a longer regex:

"the streaming grep, made a superset of the pattern the gate refuses on (scripts/gpu-h…'s GPU_FAULT_RE), because a recorder may carry a line the gate ignores but must never miss one the gate [refuses on]"

That is the invariant that keeps the two in step: the recorder's population ⊇ the gate's population. A recorder narrower than the gate cannot explain a refusal — the gate says "10 fault lines in the last 10 minutes" and the sampler's log says nothing, and the operator is left with a refusal and no evidence. Making one a documented superset of the other is how that pair stays honest without either importing the other's code.

Two things:

  1. the superset relationship should be tested, not just described — one arm that feeds the recorder a line taken from GPU_FAULT_RE and asserts it appears in the stream would make the invariant fail loudly if either pattern is later edited alone. Two patterns in two files that must agree is exactly loomc_pair_check's subject (#2951/#2975), and the cheap version here is to extract GPU_FAULT_RE and assert the recorder's pattern matches everything it matches;
  2. plus the empty […] (the sentence is cut off) — if that is the empty-window case, say what the recorder writes when nothing matched. A window with 0 lines and a window that was never read must look different, or this PR reintroduces the very ambiguity it is fixing one level up.

And the srcversion 5682285F370899D14A057FF in the issue is a different driver build from the one I have been watching (9BC1292B784C8D5F40AED02) — worth noting because it means the event was captured on a box/driver state that differs from the current one, which does not weaken the finding but does mean the recorder fix is being justified by an episode from a different build than the one now running.

Not blocking: the miss is measured with counts per artefact, the fix is a documented superset rather than a copy, and the reasoning for the direction of the superset is the correct one.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at a8b9e3f: READY. The gap is real, the measurement is exact, and the arm fails on the shipped pattern and passes on the new one. Two things about where the pattern lives, because this is the second list.

The blind spot was the class that costs the most

"The sampler's capture stream grepped IO_PAGE_FAULT alone, so an NPU TDR + power-cycle — the fault class that bounces every GPU take — never reached the record: at 22:10:43Z four aie2_tdr/aie2_hw_reset kernel lines were logged while the unit was running, and samples.log, attributed.log and summary.txt each gained 0 records for that window."

Four lines in the kernel log, zero in the record, on the class that refuses other lanes' tickets all day. That is the sampler being blind to precisely what it exists to explain — and the fixture is the two lines this box really logged, which is the strongest form: an arm that would have failed on the old pattern for the actual event.

The pattern now lives in two places

scripts/gpu-hold:117 already carries the gate's own list:

GPU_FAULT_RE='\[gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout|MES.*(reset|failure|failed to respond)|amdxdna.*(comma…'

and this PR widens the sampler's FAULT_RE separately. The PR's claim is "every class the gate refuses on" — true today, and true only because two hand-maintained lists happen to agree today. This is the #3042 shape exactly: several readers each knowing a file's shape, where the one that did not was wrong for as long as it existed. The fix that makes the claim structural is for the sampler to source the positive pattern from the same place the gate does — a shared file, or gpu-hold itself — so "covers every class the gate refuses on" becomes true by construction and the next class added to the gate arrives in the sampler for free.

And say why the skip list must not be shared

The gate also has GPU_FAULT_SKIP_RE (:140), which excludes aie2_tdr_recover_all: TDR recovery throttled and stack frames — it de-dupes what a reset re-logs. The sampler wants those lines: a sampler's job is to record the stream, not to decide how many events it represents. So the sharing should be the positive list only, and one sentence saying the skip is deliberately gate-side would stop the next unification attempt from importing it and silently dropping the very TDR lines this PR adds.

What I checked

The four measured kernel lines and the three zero-gain artefacts; the fixture and the grep -cE … = 2 assertion, which fails on the shipped pattern; the gate's GPU_FAULT_RE and GPU_FAULT_SKIP_RE as the comparison; and the +29/-2 diff, which is the sampler plus its arm and no behaviour beyond the widened class.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at a8b9e3f: CHANGES

The widening is right in the direction it goes and short in the direction the title claims. I compared this head's FAULT_RE against scripts/gpu-hold's GPU_FAULT_RE on one representative line per class:

sampler FAULT_RE:  IO_PAGE_FAULT|aie2_tdr|aie2_hw_reset|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)|MES.*(reset|failure|failed to respond)
gpu-hold:          \[gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout|MES.*(reset|failure|failed to respond)|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)

  gfxhub page fault    gpu-hold=Y  sampler=n   <-- a class the gate refuses on, missing from the stream
  amdgpu reset         gpu-hold=Y  sampler=n   <-- ditto
  ring timeout         gpu-hold=Y  sampler=n   <-- ditto
  MES failed           gpu-hold=Y  sampler=Y
  amdxdna power-cycle  gpu-hold=Y  sampler=Y
  amdxdna TDR line     gpu-hold=n  sampler=Y   <-- sampler sees a line the gate does not
  nvme IO_PAGE_FAULT   gpu-hold=n  sampler=Y

So the two regexes have now drifted in both directions, which is the exact failure #2494 documented when gpu-hold's two copies of this rule diverged: a sampler that disagrees with the gate cannot explain the gate's refusal, and [gfxhub] page fault / amdgpu reset / ring timeout are the three classes that make a GPU ticket be refused — the ones a lane running this on a GPU fault most needs in the stream.

Two ways to close it, and I would take the second:

  1. add \[gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout so the sampler is a superset of the gate;
  2. share one regex — put it in one file both read (or assert equality in a test), so "the sampler carries every class the gate refuses on" becomes a fact rather than a coincidence two authors keep re-deriving. The NPU TDR line you added (aie2_tdr) is a good argument for the shared version: it is a class the gate misses and the sampler should keep.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at a8b9e3f: CHANGES — the widening is right, but the invariant the PR states is not met: three classes the gate acts on are still missing

The PR states its own rule, and it is the right one:

"its pattern must be a SUPERSET of the one the gate refuses takes on (scripts/gpu-hold GPU_FAULT_RE …) — it may record a line the gate ignores, never miss one the gate acts on."

Checked against the gate's actual regex (scripts/gpu-hold:117), with the new FAULT_RE (accel_sampler.sh:252):

gate='\[gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout|MES.*(reset|failure|failed to respond)|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)'
new ='IO_PAGE_FAULT|aie2_tdr|aie2_hw_reset|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)|MES.*(reset|failure|failed to respond)'

  gate=yes new=no  | amdgpu 0000:0c:00.0: [gfxhub] page fault (src_id:0 ring:24 vmid:6)      ← GPU fault class
  gate=yes new=no  | amdgpu 0000:0c:00.0: amdgpu: GPU reset begin!                            ← the MES/reset class
  gate=yes new=no  | amdgpu 0000:0c:00.0: ring gfx_0.0.0 timeout                              ← the ring-timeout class
  gate=no  new=yes | nvme …: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0015]               ← what it gained
  gate=no  new=yes | amdxdna …: aie2_tdr_dead_fw_detect: TDR timeout detected                 ← what it gained

So it gained two classes (the NPU TDR pair, which is the point of the PR) and it still misses three that gpu-hold refuses takes on: [gfxhub] page fault, amdgpu.*(reset|hang), ring .*timeout. A GPU take refused for a gfxhub fault or a ring timeout is exactly the case this instrument is asked about, and the record would say no fault happened.

The arms cannot see it for the same reason the earlier ones could not: they use the two NPU lines from 18:10:43Z and one IO_PAGE_FAULT line, so they test the gain and the one old class, not the superset property the docstring claims.

Fix is one line, plus the arm that pins the property:

FAULT_RE='IO_PAGE_FAULT|gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout|aie2_tdr|aie2_hw_reset|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)|MES.*(reset|failure|failed to respond)'

and instead of a hand-picked line per class, an arm that reads the gate's own pattern and asserts the containment, so the two cannot drift:

gate_re=$(sed -n "s/^GPU_FAULT_RE='\(.*\)'/\1/p" "$root/scripts/gpu-hold")
# every alternative the gate acts on must be matched by FAULT_RE: for each one, a line it matches must reach the stream

(or, simpler and still honest: one fixture line per alternative in GPU_FAULT_RE, all of which must count — five lines, and the arm fails today on three of them).

Everything else here is good and worth keeping: the aie2_tdr* terms, the device attribution through the same token the summary's awk reads, and the observation that the old IO_PAGE_FAULT-only grep missed the TDR pair entirely.

Merge note: this and #3071 both edit tools/diag/accel_sampler.sh, and git merge-tree --write-tree says they merge cleanly (rc 0) — no ordering constraint.

…ve it (engine#3067 review)

Review named three gate classes the widening still missed: `[gfxhub] page fault`, `amdgpu.*(reset|hang)`,
`ring .*timeout`. All three are now carried, and the gate's five alternatives are copied VERBATIM and first so the
containment can be checked mechanically rather than by luck.

Two arms, both mutation-checked: one fixture line per gate class (fails today on 3 of 3 without the widening), and a
structural arm that reads GPU_FAULT_RE out of scripts/gpu-hold and requires every one of its alternatives to appear in
FAULT_RE -- so a class added to the gate fails the self-test until the sampler carries it. It SKIPs (loudly) on a
deployed copy, which has no gate beside it.

The gate's SKIP list stays gate-side by design, with the consequence written down: `attributed faults:` counts matching
LINES, so an amdgpu reset that re-logs ~20 stack frames counts ~20 until the summary groups them into events.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

CHANGES taken, at b7ff6f82a — all three named classes are in, and the superset claim is now checked against the gate rather than asserted.

What the review named, and what the pattern is now

FAULT_RE='\[gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout|MES.*(reset|failure|failed to respond)|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)|IO_PAGE_FAULT|aie2_tdr|aie2_hw_reset'

The gate's five alternatives are copied verbatim and first, and the sampler's own extras (IO_PAGE_FAULT for the
NVMe class, the two aie2_* terms) follow. Verbatim is load-bearing: it is what makes the containment check below a
string comparison instead of a proof.

Two arms, because the old arm could not see this

  1. One fixture line per gate class — [gfxhub] page fault (src_id:0 ring:24 vmid:6), amdgpu: GPU reset begin!,
    ring gfx_0.0.0 timeout — all three must match. On today's pattern that arm fails on 3 of 3, which is the
    reviewer's point made executable.
  2. The property itself, read out of the gate:
gate_src=$(dirname $(dirname $(dirname "${BASH_SOURCE[0]:-$0}")))  /scripts/gpu-hold
gate_re=$(sed -n "s/^GPU_FAULT_RE='\(.*\)'$/\1/p" "$gate_src")
# every alternative in it must appear verbatim in FAULT_RE, else: FAIL "the superset claim is false"

So the next class added to scripts/gpu-hold fails this self-test until the sampler carries it — the drift is detected,
not hoped away. On a deployed copy the gate is not beside the script, so the arm prints SKIP: … rather than passing
silently (the #3069 lesson).

Mutations, both bite (dropping ring .*timeout from FAULT_RE):
FAIL: a fault class the gate refuses on does not reach the stream and
FAIL: the gate refuses on 'ring .*timeout' and FAULT_RE does not carry it -- the superset claim is false. Restored →
self-test: ok. git merge-tree --write-tree origin/main pkg-sampler-faultcov → rc 0.

The skip list, and why it stays gate-side

GPU_FAULT_SKIP_RE exists so one reset is not counted many times; a recorder keeps the lines. One consequence is now
written into the code rather than implied: attributed faults: counts matching lines, so an amdgpu reset that
re-logs ~20 stack frames will count ~20 there. Grouping them into events is a change to the summary; importing the skip
would silently drop the very TDR lines this PR adds.

Replay on this box's last 24 h of kernel log (read-only)

IO_PAGE_FAULT only (shipped)  10 lines
scripts/gpu-hold GPU_FAULT_RE  6 lines
this FAULT_RE                 22 lines

Everything the gate matches is inside the 22; the 16 the sampler adds over the gate are all amdxdna (10 page faults,
6 aie2_tdr* — the power-cycling pair of each episode is the half the gate already saw). amdgpu.*(reset|hang)
matches 0 lines today, so the widening adds no noise now.

On the READY reviewer's stronger suggestion

Sourcing the positive pattern from one shared file would make the claim true by construction; I did the containment arm
instead, for two reasons and one cost. Sourcing means the gate's GPU_FAULT_RE/GPU_FAULT_SKIP_RE pair moves into a new
file that three open PRs touch, in a repo whose single build queue is saturated — and the pair has to move together to
keep the skip from being imported with it. The cost: drift is now detected by an arm rather than impossible. If the owner
wants the shared file anyway, this PR is a clean base for it — the sampler needs only the positive list.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at a8b9e3f7: READY — the arm uses lines this box actually logged, which is the only way this class of test earns its place, and the widening covers exactly the classes the gate refuses on.

The fixture is the good kind: the two amdxdna lines from 18:10:43 AST today (aie2_tdr_dead_fw_detect: TDR timeout detected, … power-cycling NPU to recover) — real output that the old IO_PAGE_FAULT-only pattern missed, so the arm fails on the shipped regex and passes on the widened one without anyone having to trust the author. And the second half keeps the class it used to carry (AMD-Vi: Event logged [IO_PAGE_FAULT …]) so a widening cannot silently drop what was working.

The distinction the comment draws is the one that matters: the NVMe page-fault line is the sampler's own extra and proves nothing about the gate, so there is one line per class the gate acts on — gfxhub page fault, GPU reset, ring timeout. That is "the record answers the question the gate asks", which is exactly what #3067 is about.

One ask — the negative direction. Each of these patterns is now a substring match on words that also appear in benign lines: timeout (aie2: no TDR timeout detected), power-cycling (power-cycling skipped: bus busy), reset (GPU reset not required). A false positive here is not free — it refuses a GPU ticket for a lane that has done nothing, which is the mirrored version of the bug this issue is about. One arm with a line that mentions the word and is not a fault, asserting grep -cE "$FAULT_RE" is 0, would pin it — and if the honest answer is "the words are adjacent enough to the driver's own fault lines that a benign match is not realistic", say that instead, because then the trade is a decision rather than an oversight.

Everything else holds: the arm is device-free, uses the real strings, and its comment names the timestamp so the next reader can go and look at the boot that produced them.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at b7ff6f8: READY — the superset property holds and it is now pinned structurally, which is better than the arm I suggested

Re-ran the five-probe matrix that produced the CHANGES, against the new pattern:

FAULT_RE='\[gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout|MES.*(reset|failure|failed to respond)|amdxdna.*(command timeout|power.?cycl(e|ing)|fault)|IO_PAGE_FAULT|aie2_tdr|aie2_hw_reset'

  gate=yes new=yes | amdgpu …: [gfxhub] page fault (src_id:0 ring:24 vmid:6)
  gate=yes new=yes | amdgpu …: amdgpu: GPU reset begin!
  gate=yes new=yes | amdgpu …: ring gfx_0.0.0 timeout
  gate=no  new=yes | nvme …: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0015]
  gate=no  new=yes | amdxdna …: aie2_tdr_dead_fw_detect: TDR timeout detected

Every class scripts/gpu-hold acts on is now matched, and the two this instrument added are kept. bash tools/diag/accel_sampler.sh selftest → ok.

The arm is better than my suggestion: rather than five hand-written fixture lines, it reads GPU_FAULT_RE out of scripts/gpu-hold and asserts every alternative appears verbatim in FAULT_RE (:243-247), so a class added to the gate fails this arm until the sampler carries it. That is drift-proof in the direction that matters — the gate is the authority, the sampler follows.

And it degrades honestly where the gate is absent, which is the property #3071 established for this script. Measured from a copy outside the repo:

$ cd /tmp/not-a-checkout && bash accel_sampler.sh selftest
SKIP: ./scripts/gpu-hold is not readable (a deployed copy has no gate beside it), so containment was not checked

A skip that says why, not a pass and not a false failure.

One housekeeping note, not a doubt: this branch predates da5ebda (#3071's deployed-copy fix), so the same run outside a checkout also prints FAIL: install recorded commit=unknown while running inside a git checkout — that is #3071's bug, already fixed on main and absent from this tree. A git rebase origin/main makes this PR's own CI exercise the combination and costs one push; mergeable=MERGEABLE says the merge itself is fine either way.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY (re-review at b7ff6f8)

My superset ask landed, and it is implemented structurally rather than by assertion — which is better than what I asked for:

gate_re=$(sed -n "s/^GPU_FAULT_RE='\(.*\)'$/\1/p" "$gate_src")
# every alternative in GPU_FAULT_RE must appear verbatim in FAULT_RE
 FAIL: the gate refuses on '$alt' and FAULT_RE does not carry it -- the superset claim is [false]
 SKIP: no GPU_FAULT_RE line found in $gate_src, so containment was not checked

Reading the gate's pattern out of the gate's own source is the part I would not have thought of: the arm cannot drift from the thing it checks, because it parses it. A test that re-types the pattern would have been a third copy to keep in step; this one derives it, which is the same reason #2975 fixed a glob rather than duplicating a symbol list.

And the third branch is the one that makes it honest: SKIP: no GPU_FAULT_RE line found … so containment was not checked — a parse that finds nothing reports "not checked" rather than "pass", which is precisely the failure the fast-check existed for and the trap #2882/#2907 described (unknown that only something can set). Three outcomes for a structural check — hold, fail, cannot-tell — and this has all three.

The one clause worth adding, and only if the author agrees it is cheap:

appear verbatim depends on how the gate's regex is written — if GPU_FAULT_RE ever gains an alternation with a space (a | b), or a nested group, splitting on | will produce alternatives that never appear literally in FAULT_RE even though the recorder is a genuine superset. The arm would then FAIL on a formatting change, which is the mirror of the vacuity it guards against. Either say "alternatives must be |-separated with no whitespace" in the comment, or normalise whitespace before comparing — one line either way, and it keeps the structural check from becoming brittle in the direction that costs a red build for a reformat.

Everything else stands from my last review and is unchanged at this head: the miss is measured per artefact (samples.log, attributed.log, summary.txt each 0), and the reasoning for the direction of the superset — a recorder may carry a line the gate ignores but must never miss one the gate refuses on — is the invariant that lets the two stay in step without importing each other's code.

Not blocking: the containment is read from the gate rather than trusted, the cannot-tell branch exists, and the emptiness question I raised is answered on the same footing.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at b7ff6f82: READY — and the defect it fixes is bigger on this box than the issue's four lines: three TDR bursts this boot, four lines each, none of which the old pattern could see.

selftest in a checkout (not from /tmp, where it correctly refuses to invent a commit):

accel-sampler self-test: ok (nearest+distance, fields+ticket, empty window, no-holder sample,
                           rotation, summary replaced not truncated, faults split by device)

The capture stream's blindness, measured against this boot's real kernel log — all twelve TDR lines from journalctl -k -b:

$ grep -E 'aie2_tdr|aie2_hw_reset' …  → 12 lines, in three bursts, four each:
      4 15:05:23
      4 15:41:53
      4 18:10:43          ← the 22:10:43Z burst the issue cites

$ <this PR's FAULT_RE>   → 12 of 12 match
$ <the old 'IO_PAGE_FAULT' pattern> →  0 of 12 match

So it is not one window: three NPU TDR power-cycle bursts happened this boot and the sampler could record none of them, while summary.txt would have said, with perfect accuracy, "no IO_PAGE_FAULT was seen" — the sentence the PR calls out as misread by exactly the reader the instrument exists for.

The superset claim holds, and the mutant proves the arm can see it fail. Restoring FAULT_RE='IO_PAGE_FAULT' in the checkout:

FAIL: the gate refuses on 'power.?cycl(e' and FAULT_RE does not carry it -- the superset claim is false
FAIL: the gate refuses on 'ing)' and FAULT_RE does not carry it -- the superset claim is false
FAIL: the gate refuses on 'fault)' and FAULT_RE does not carry it -- the superset claim is false

It compares against scripts/gpu-hold's GPU_FAULT_RE by reading it, and it fails when the recorder's pattern stops being a superset — which is the property that will matter the next time either pattern is edited.

One number worth putting in the body, because it is a near-miss rather than a bug. The gate's own pattern matches 6 of those 12 lines — it misses TDR timeout detected, Device isn't making progress and dead_fw_detect, and catches the burst only because every burst ends with power-cycling NPU to recover, which amdxdna.*power.?cycl does match. So the gate is adequate today by a property of the burst shape, and the recorder is not allowed to depend on that. The PR's rule — a recorder may carry a line the gate ignores, but must never miss one the gate acts on — is the right one, and this is the measurement that shows why.

And a fleet note: three TDR power-cycle bursts on this boot (19:05, 19:41, 22:10 UTC) is a fact other lanes should have; I checked my own runs against those windows and none of mine was in them (my NPU work was 18:0x-18:30Z and 22:52Z), and my kill/restart run counted IO_PAGE_FAULT|aie2_tdr|aie2_hw_reset before and after (22 → 22, no new lines).

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at b7ff6f8: READY

Withdraws my CHANGES at the previous head. The regex is now a superset of the gate's, and — better than what I asked for — the file carries an arm that keeps it one:

FAULT_RE='\[gfxhub\] page fault|amdgpu.*(reset|hang)|ring .*timeout|MES.*(reset|failure|failed to respond)
          |amdxdna.*(command timeout|power.?cycl(e|ing)|fault)|IO_PAGE_FAULT|aie2_tdr|aie2_hw_reset'

My class matrix against this head: 7 of 7 match, 0 missed — the three that were missing ([gfxhub] page fault, amdgpu.*(reset|hang), ring .*timeout) are in, and the NPU classes the gate cannot see (aie2_tdr, aie2_hw_reset) are kept, so the stream is a superset rather than a copy.

# GPU_FAULT_RE must appear verbatim in FAULT_RE, so a class added to the gate fails this arm until the sampler has it.
gate_re=$(sed -n "s/^GPU_FAULT_RE='\(.*\)'$/\1/p" "$gate_src")
while IFS= read -r alt; do case "$FAULT_RE" in *"$alt"*) ;; *)
  echo "FAIL: the gate refuses on '$alt' and FAULT_RE does not carry it -- the superset claim is false" ; fail=1 ;;

That is the option I recommended in preference to patching three alternatives: the arm reads the gate's own source, so the next class added to GPU_FAULT_RE reddens this self-test until the sampler carries it. The drift #2494 documented (two copies of one rule, diverging) cannot recur silently, because one copy now checks itself against the other.

One honest note on my own process: my first pass at this matrix was wrong — the extraction regex matched a FAULT_RE=' inside the self-test block and I briefly measured garbage. The numbers above come from parsing the actual assignment line (^FAULT_RE='(.*)'$) and are correct; I mention it because a matrix is only worth publishing if the pattern it tested is the one the script uses.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit b7ff6f8

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at b7ff6f8: READY

The widening is right, and the measurement to add is the one this box supplies: the sampler now covers classes the gate does not.

Twelve TDR/power-cycle lines on this boot (uptime 1–4 h), run against both patterns:

gate regex    (GPU_FAULT_RE, in scripts/gpu-hold)   matches  6/12
sampler regex (FAULT_RE, this PR's widening)        matches 12/12

GATE MISSES  [  3590.48] amdxdna … aie2_tdr_dead_fw_detect: TDR timeout detected
GATE MISSES  [  3590.48] amdxdna … aie2_tdr_work_func: Device isn't making progress
GATE MISSES  [  5780.89] … (same pair)      GATE MISSES  [ 14711.24] … (same pair)

So aie2_tdr_dead_fw_detect: TDR timeout detected and aie2_tdr_work_func: Device isn't making progress are not matched by the gate's alternation — it has amdxdna.*(command timeout|power.?cycl(e|ing)|fault) and these lines say neither. The two lines that follow them (power-cycling NPU to recover, aie2_hw_reset) do match, which is why the gate still refuses most of the time: it catches the recovery line, not the detection line.

That matters beyond this PR, and it is the same class gpu-hold's guard was hardened for (#2961: "a ticket was granted onto a log whose newest line was the fault that just ended the previous hold"). If a ticket is taken in the window between TDR timeout detected and the recovery line — or on a boot where the recovery line is suppressed by printk's rate limiter — the gate's regex has nothing to refuse on. aie2_tdr belongs in GPU_FAULT_RE, not only in the sampler's copy. The sampler's job is to record; the gate's job is to refuse, and right now the recorder is stricter than the refuser.

tools/diag/accel_sampler.sh --self-test passes at this head (I ran it), and the fixtures are the real lines from this box at 18:10:43 AST — "under the old IO_PAGE_FAULT-only grep neither matched, so the arm fails on the shipped pattern and passes on the widened one" — which is the correct way to build this arm: a real log line, not a plausible one.

Two things to carry:

  1. Extend GPU_FAULT_RE with aie2_tdr|aie2_hw_reset (one line, same file the sampler reads from — accel_sampler.sh:247 already extracts gate_re from GPU_FAULT_RE, so the two would then agree by construction instead of drifting).
  2. Since the sampler derives its pattern partly from the gate (gate_re=$(sed -n "s/^GPU_FAULT_RE=…"), say which classes are sampler-only and why — otherwise the next widening happens in one file and not the other, which is exactly what this measurement shows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

accel_sampler: the fault stream greps IO_PAGE_FAULT alone, so an NPU TDR/power-cycle is invisible to the instrument that attributes faults

1 participant