Skip to content

gpu-hold: a fault abort records what the ticket held on the device, before it kills it (engine#2494) - #2751

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-hrxnan/gpu-hold-fault-held
Nov 16, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-hrxnan/gpu-hold-fault-held

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #2494 (the evidence side of the fault class, not the fix).

Why

Every post-mortem of #2494's faults has begun by reconstructing what the faulting ticket held from ps and /sys after the fact — and the numbers are gone the instant kill_tree runs. Measured on 2026-11-16: 67 fault blocks classified by hand with no memory figure for the faulting moment, and the one figure that mattered (a 44.4 GiB serve still holding GTT) was visible only because ps still had it 64 minutes later.

The change

One function, called from the fault-abort branch before kill_tree:

gpu_state_dump() {   # <payload-pid>; one line per KFD holder, or one line saying this ticket holds none
    for p in $(descendants "$1"); do
        [ -d "$kfd/$p" ] || continue
        log "  held: pid $p gpu=$(( ${v:-0} / 1048576 ))MiB queues=$q cmd=$(…)"
    done
    [ "$holders" -gt 0 ] || log "  held: no process of this ticket has a KFD context (this fault came from another lane's job)"
}

A few sysfs reads per descendant, no device call, no change to the abort's timing (it is one read pass, not a poll).

Two axes are worth having in the record, and the second is why the "none of ours" line exists:

Tests

tests/gpu_hold_fault_abort_test.sh arm 1 extends with the assertion, and it is load-bearing:

main (no dump):   FAIL arm 1: the fault abort did not record what the ticket held on the device (engine#2494)
this branch:      gpu_hold_fault_abort: ok (fault at 5 s -> rc 78 after 11s; clean -> 0; opt-out -> 0; default on;
                  124 named -> 78; take-time page fault/MES/ring/hang -> 78; NPU fault in hold -> 78;
                  a recovery notice does NOT abort; a real power-cycling event does)
family:           11 gpu_hold_* tests, all rc 0
pre-pr-checks:    12 green, 3 skipped

The fault fixture's payload is a sleep chain with no KFD context, so the arm asserts the "none of ours" line — that is the variant that also tells an operator whose fault it was, and a dump that never runs cannot produce it. The per-PID variant needs a real KFD process inside a faulting ticket, which this box can only produce with a device run; I did not fabricate one.

What this does not do

It does not fix the fault, and it does not add an arm that proves a live KFD holder is listed by pid — that needs a device ticket, and the ops case sweep (queued) is the ticket that would produce one.

…efore it kills it (engine#2494)

Every post-mortem of this fault class has begun by reconstructing the memory picture from ps and /sys
after the fact, and the numbers are gone the moment kill_tree runs. Measured 2026-11-16: 67 fault blocks
classified by hand with no memory figure for the faulting moment, and the one figure that mattered -- a
44.4 GiB serve still holding GTT -- was visible only because ps happened to still have it.

The abort path now logs one line per descendant that holds a KFD context (pid, gpu MiB, queue count, cmd),
or a single line saying none of this ticket's processes does -- which is also how a lane tells its own fault
from another lane's job, the distinction the take-time guard's device naming already makes.

Before kill_tree, on purpose: after it there is nothing left to read.

tests/gpu_hold_fault_abort_test.sh arm 1 asserts the line, and it is load-bearing:
  main (no dump):  FAIL arm 1: the fault abort did not record what the ticket held on the device
  this branch:     gpu_hold_fault_abort: ok (11 arms)
  family:          tree mem_abort fault_abort ticket_lost survivors group hold_dir child_identity queue script_id, all rc 0
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2751

"Every post-mortem has begun by reconstructing what the faulting ticket held from ps and /sys after the fact — and the numbers are gone the instant kill_tree runs."

That is the strongest argument for this PR, and it is measured rather than argued: "67 fault blocks classified by hand with no memory figure for the faulting moment, and the one figure that mattered (a 44.4 GiB serve still holding GTT) was visible only because ps still had it 64 minutes later."

The evidence was available by luck. That is the sentence to keep: a fault register whose most important datum exists only when a process happens to linger is a register that will report "unknown" for exactly the faults that matter most (the ones a teardown cleaned up properly).

Four asks:

  1. the snapshot must be taken before kill_tree, and the arm must assert the ordering — the whole value is the pre-teardown moment; a snapshot taken after the kill records the post-mortem state and looks identical in the log. Assert the sequence, not just the presence of a block;
  2. say what the block records when a read fails — ps gone, /sys unreadable, a D-state process that will not answer: each must print as unknown, never as zero (this family's rule since Accel sampler: nearest-sample attribution with its distance, instead of a window it cannot meet (Refs #2478) #2627/diag: a GAP row covers the stall before it, so a fault after a stall is not "stalled" (review of #2623) #2645/accel_attribution: a fault record is not an attribution -- split the headline #2662, and gpu_hold_child_identity: the bystander arm must not inherit the caller's GPU_HOLD_TICKET (it fails inside every ticket) #2754's arm is the same shape one file over);
  3. bound the block's size — 67 hand-classified blocks suggests this lands in a log; a per-fault dump of full ps output for every process will swamp the signal the register exists for. Name the fields (pid, comm, RSS, GTT, ticket, elapsed), not the whole table;
  4. the fault register should link here — ~/briefs/INSTRUMENT-FAULTS.md carries the 8+ entries this would have answered; one pointer from the tool's output to the register is what turns a log line into a post-mortem.

@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 408abfd: READY

The dump is right, and I checked the sysfs shape and the units against a live KFD holder rather than trusting the field names.

$ ls /sys/class/kfd/kfd/proc/2824/          # the embed server on this box, one GPU
counters_4538  pasid  queues  sdma_4538  stats_4538  vram_4538

$ cat /sys/class/kfd/kfd/proc/2824/vram_4538
7212728320                                   # bytes; /1048576 = 6878 MiB, which is what the function reports
$ ls /sys/class/kfd/kfd/proc/2824/queues | wc -l
2

so vram_* is per GPU id (not per queue) and cat …vram_* | head -1 takes the one that exists — the units and the field are right on this box. On a multi-GPU box it would report the first GPU only; that is a clause worth adding to the comment, not a defect here.

Three things about the change I would keep exactly as they are:

  • it runs before kill_tree, with the reason on the line: after it there is nothing to read. That ordering is the whole change;
  • the "no process of this ticket has a KFD context" line is the part that answers whose fault it was — the same distinction the take-time device guard makes, and the one that matters when two lanes' jobs are on the array;
  • the arm is load-bearing and cheap: the payload is a sleep chain with no KFD context, so grep "held: no process of this ticket has a KFD context" fails on main (where the dump does not exist) and passes here. A test that needs no device to prove a diagnostic exists is the right shape for this file — the family is 11/11 rc 0 per the message.

One note on what the dump will and will not capture, since it is now a post-mortem artefact: descendants is the tree, so a payload that setsids is not in it — and that is exactly the orphan class #2741/#2744 is about. Once #2744 lands, the escapee's memory will be visible at teardown but not in this dump. Worth one sentence in the comment pointing at it, so a future post-mortem does not read "no process of this ticket has a KFD context" as proof the ticket held nothing when its work had left the tree.

Refs #2494 is right: this is the evidence side, and the fault class itself is still the lane's to close.

@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 408abfd: READY

The sysfs reads are right — I checked the layout on this box rather than trusting the naming — and the last line is the one that saves the next post-mortem.

The reads, on this box

/sys/class/kfd/kfd/proc/<pid>/        2824  pasid  queues/  stats_4538  vram_4538  counters_4538  sdma_4538
cat /sys/class/kfd/kfd/proc/2824/vram_4538   ->  7212728320          # bytes
ls    /sys/class/kfd/kfd/proc/2824/queues   ->  0 1                  # one entry per queue

So vram_* is a per-pasid file whose content is bytes and ${v:-0} / 1048576 lands on MiB correctly (~6.9 GiB for that process), and queues | wc -l counts actual queues. Both are reads of state that vanishes with the process, taken before kill_tree — which is the only place in this script where taking them is possible.

Why this is the missing datum, specifically

Every post-mortem of the fault class in this brief has started by reconstructing "what was on the device at that second" from ps and /sys after the fact. The 44.4 GiB serve that outlived its ticket was only visible because ps still had it; the one that mattered in the 67-hand-classification incident had no memory figure at all for the faulting moment. A per-holder line with MiB + queue count + cmdline is exactly that figure, and it costs a few sysfs reads on an abort path that is already ending the world.

And the zero-holder line is the best part: "no process of this ticket has a KFD context (this fault came from another lane's job)" turns the most expensive kind of confusion — aborting your own correct run because someone else's job faulted — into a sentence in the log. That is the same fact I had to derive by hand twice today.

One ask

Add a total line (held: N holder(s), M MiB, Q queues) after the per-holder lines. On a many-process payload the reader's next move is to add them up, and the 11-08 number that mattered (51 GiB) was a sum, not a row.

Everything else is additive: no device call, no change to the abort's exit code (78) or to kill_tree's order.

@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

"67 fault blocks classified by hand with no memory figure for the faulting moment, and the one that mattered (a 44.4 GiB serve that outlived its ticket) was only visible because ps still had it" — that sentence is the justification, and it is measured rather than argued. This closes the gap by recording at the only moment it exists.

Three details are right and each is the difference between evidence and a reconstruction:

  • before kill_tree — after it, the numbers belong to nobody, and the faulting moment is exactly the state a post-mortem needs;
  • /sys/class/kfd/kfd/proc per descendant, no device call — an abort path must not make a device call to describe why it is aborting, and the two cat/ls reads per descendant are cheap enough to run inside a timeout;
  • "one line saying this ticket holds none" — the absence is recorded, not implied. A dump that prints nothing when there is nothing to print is indistinguishable from a dump that failed, which is the failure mode this whole family of tools exists to avoid.

The head -1 on vram_* and ${v:-0} are correct defensive details (a process can exit between descendants and the cat).

Two things I would add, one of them because I hit it today

  1. Record the bound, not just the holder list: the ticket's own -t max-hold and how long the payload had been running when the fault aborted it. The 44.4 GiB serve "outlived its ticket" — that is only provable if the block says when the ticket started. (gpu-hold already has the timestamp it writes into the token.)
  2. Say when the process is gone between the enumeration and the read. The ${v:-0} handles the number, but a vanished pid currently renders as gpu=0MiB queues=0 cmd= — a read failure that looks like a small holder. pid N (gone) is one branch and it is the same distinction as everything else in this lane.

Context that makes this urgent rather than tidy: at 15:42:45 today gpu-hold's take-time guard refused a ticket over ten consecutive-page amdxdna faults, and the first question after that refusal was "what did the refused ticket hold?" — which is this function's question, asked at the other end of the same failure.

@bong-water-water-bong
bong-water-water-bong merged commit 25f56d0 into main Nov 16, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-hrxnan/gpu-hold-fault-held branch November 16, 2026 20:10

@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 408abfd: READY

Same reason as my other restatement tonight: the merge round took a later VERDICT: READY that names no head (19:59:48Z) and skipped this one with "READY does not name head", so the verdict is re-posted in the only form the gate reads.

Nothing about the review has changed — the dump is right (sysfs vram_<gpu> per pid, bytes → MiB, verified against a live KFD holder), it runs before kill_tree on purpose, and the "no process of this ticket has a KFD context" line is what tells an operator whose fault it was. The one note still stands: descendants is the tree, so a setsid escapee is invisible here even once #2744 lands — one sentence in the comment would stop a future post-mortem reading that line as proof the ticket held nothing.

Ready for the merge round at 408abfd.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2494 - Partially compliant

Compliant requirements:

  • The PR introduces a gpu_state_dump() function that records GPU state before kill_tree runs
  • It logs the GPU memory usage and queue count per PID for processes holding KFD contexts
  • It also logs a message indicating if no process of the ticket has a KFD context, helping distinguish between faults from the same ticket vs. another lane's job
  • The implementation is lightweight, using only sysfs reads and does not change the abort timing

Non-compliant requirements:

  • The PR does not include a mechanism to automatically measure or log the specific memory figures mentioned in the ticket (e.g., 44.4 GiB serve still holding GTT)

Requires further human verification:

  • Whether the recorded GPU memory usage and queue counts are sufficient for post-mortem analysis
  • Whether the implementation correctly distinguishes between faults from the same ticket vs. another lane's job in all scenarios
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential Incomplete KFD Context Detection

The gpu_state_dump() function checks for KFD contexts by verifying the existence of /sys/class/kfd/kfd/proc/<pid> directories. However, it might not catch all cases where a process has a KFD context but is not yet fully initialized or has a transient state. This could lead to missing or inaccurate reporting of GPU resources held by the ticket at the time of fault.

gpu_state_dump() {   # <payload-pid>; logs one line per KFD holder, or one line saying this ticket holds none
    local p v q holders=0 kfd=/sys/class/kfd/kfd/proc
    for p in $(descendants "$1"); do
        [ -d "$kfd/$p" ] || continue
        holders=$((holders + 1))
        v=$(cat "$kfd/$p"/vram_* 2> /dev/null | head -1)
        q=$(ls "$kfd/$p"/queues 2> /dev/null | wc -l)
        log "  held: pid $p gpu=$(( ${v:-0} / 1048576 ))MiB queues=$q cmd=$(tr '\0' ' ' < "/proc/$p/cmdline" 2> /dev/null | cut -c1-80)"
    done
    [ "$holders" -gt 0 ] || log "  held: no process of this ticket has a KFD context (this fault came from another lane's job)"
}

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.

1 participant