Repository navigation
serve: decide the CWSR placement once, so the log names what the user set (c20 gate red) - #813
Conversation
… set
c20's ctest caught `hrx_cwsr_route` failing on one assertion, "and serve names it in the log": with
HSA_USERPTR_FOR_PAGED_MEM=5 in the environment and --device hrx, serve logged
HRX: CWSR save area placed in GTT by default (...); kept from the environment:
HSA_USE_SVM, HSA_USERPTR_FOR_PAGED_MEM, HRX_ALLOW_NO_SVM
i.e. all three "kept from the environment" when the user had set exactly one. The environment assertion right
above it in the same test passes, so the backend does get the right trio: only the message is wrong.
Cause: #794 (engine#715) puts the trio into serve's *own* environment at startup
(apply_cwsr_env_to_self(hrx_cwsr_env(o))), and announce_cwsr_env() then recomputed
decide_cwsr_placement(...) to build its line. Recomputed afterwards, getenv() reads our own exports, so
user_set lists every variable and the line can no longer distinguish what the operator set from what serve
added.
Fix: one decision per process. hrx_cwsr_decision() holds the CwsrDecision (computed once, at the first HRX
route - before the self-export, because that export calls hrx_cwsr_env(o) for its argument), hrx_cwsr_env()
returns its env, and announce_cwsr_env() prints its stored log instead of recomputing. Same single line, same
place, same behaviour when nothing is set; the difference is that the line now tells the truth about which
variables came from the environment.
Verified against the release build's own ctest case (tests/hrx_cwsr_route.sh) - see the PR for the before/after
line - and it is exactly the red that stopped c20's software gate.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Verified on the box against the release build's own ctest case (so the PR claim is measured, not reasoned): copied this Before the patch, the same test on the same tree: For the record, the before/after line on the failing case ( That is the assertion's expectation, and it is also simply the truth: the operator set one variable, serve added the other two. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
The red gate is green at this head, and the fix is the right shape — one decision per process, printed from the stored copy.
Ran (host build, no HRX submodules — the route test drives serve with the fake backend):
$ ninja onebit hrx_cwsr_test rc 0
$ ctest -R 'hrx_cwsr' --output-on-failure
19/58 Test #19: hrx_cwsr_route ......... Passed 0.72 sec <- the assertion that stopped c20
30/58 Test #30: hrx_cwsr ............... Passed 0.00 sec
100% tests passed, 0 tests failed out of 2
Cause and fix, and it is a bug I should have caught in #794. I read announce_cwsr_env() there — I even quoted its body —
and did not notice that it recomputed decide_cwsr_placement(...) after apply_cwsr_env_to_self() had already exported the
trio into serve's own environment: getenv() then reports our own exports, so user_set lists all three and the line can no
longer distinguish what the operator set from what serve added. #813 stores the CwsrDecision in a function-local static
(hrx_cwsr_decision()), returns its env from hrx_cwsr_env(), and prints its stored log. Because the self-export takes
hrx_cwsr_env(o) as an argument, the decision is computed before the export — which is the ordering that makes the line
truthful. One line, same place, unchanged when nothing is set.
That is also why the environment assertion above it in the same test kept passing: the backend got the right trio all along;
only the message lied. Worth saying plainly, because a wrong log line is exactly the kind of thing that makes the next
investigation chase the wrong variable.
Release context I checked rather than accepted: the red was in the software gate's ctest, so package, hw_gate and QEMU
never ran for rc-2026-11-01b; the rest of that run was 57/58 in the parallel batch and 9/10 in the serial engine set, with
hybrid_kvshare_route's share 1.074 ms timing assertion passing 3/3 on a clean re-run. So this really is the one blocker, and
it is fixed at the assertion that failed.
build and CodeQL are green on this head. tprs-ready applied — this is the head to merge on, and I would merge it before
anything else tonight.
…s backend (engine#715, #816) (#825) The trio is only in serve's printed plan, so a grep on --print-backend-env is the whole check. Both packages on the box today print 0, for two different reasons: rc-2026-10-31c predates #794/#813 (its log still says the placement is unchanged) and rc-2026-11-01b exports the trio into serve's own environment before building the plan, which is what #816 fixes. Co-authored-by: bong-water-water-bong <[email protected]>
Fixes the one non-infrastructure red that stopped c20's software gate. ctest failed
hrx_cwsr_routeontests/hrx_cwsr_route.sh:111, "and serve names it in the log": withHSA_USERPTR_FOR_PAGED_MEM=5in the environment and--device hrx, serve logged— all three "kept from the environment" when the user set exactly one. The environment assertion immediately above it in the same test passes (
auto: a value the user set wins, the other two are still added), so the backend gets the right trio; only the message is wrong.Cause. #794 (engine#715) puts the trio into serve's own environment at startup (
apply_cwsr_env_to_self(hrx_cwsr_env(o))), andannounce_cwsr_env()then recomputeddecide_cwsr_placement(...)to build its line. Recomputed afterwards,getenv()reads our own exports, souser_setlists every variable and the line can no longer distinguish what the operator set from what serve added.Fix. One decision per process:
hrx_cwsr_decision()holds theCwsrDecision(computed once, on the first HRX route — which is before the self-export, because that export takeshrx_cwsr_env(o)as its argument),hrx_cwsr_env()returns itsenv, andannounce_cwsr_env()prints its stored log instead of recomputing. Same single line, same place, unchanged when nothing is set; the line now tells the truth about which variables came from the environment.Why this blocked the release run, and what it does not change: the red is in the software gate's ctest, so
package, the hardware gate and QEMU were not run for c20 (rc-2026-11-01b). Nothing else in that run was red: the parallel batch was 57/58 and the serial engine-test set 9/10, the other failure (hybrid_kvshare_route) being a timing assertion (share 1.074 msvs the test'sshare 0.x ms) that then passed 3/3 on a clean re-run — a separate, much smaller issue I am not touching here.Verified by reproducing the exact case outside ctest (serve + the test's fake backend,
HSA_USERPTR_FOR_PAGED_MEM=5, clean env): before, the line lists all three; after, it names onlyHSA_USERPTR_FOR_PAGED_MEM, which is what the test asserts.