test(agc): make a missed order-hold wake slow in agc_driver_pm4_order_signal #24170

Merged
GiannisG1 merged 1 commit from upstream-pr/24170 into main 2026-11-28 06:39:06 +00:00
GiannisG1 commented 2026-11-20 08:55:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by GiannisG1 on 2026-11-20T08:55:55Z.


What

agc_driver_pm4_order_signal (#22188) fails on main's Linux job. It checks that a wait-free submission held behind queue 0 starts within 0.1 ms (median) of queue 0 blocking on the label it writes, and loaded runners land around 0.14 ms. On #22188, oneandonlydean asked for a test in which a missed wake is slow instead of a small gap (comment), and I took the first variant (comment).

  • QueueWorker.cpp: the held submission's changed.wait_for waits OrderHoldWait() instead of a fixed 200 µs.
  • SubmissionRing.cpp: OrderHoldWait() reads a test-only APS5_ORDER_HOLD_WAIT_US, from 1 to 1000000. It defaults to 200, so nothing changes unless the variable is set. It is read with the other queue settings at the first submission (ReadSubmissionRingSettings), so an invalid or zero value rejects the submission, as APS5_PM4_RING and APS5_STALL_WATCHDOG_SECS do. docs/dev/ENVIRONMENT.md lists it.
  • The test: ctest sets 50000 for agc_driver_pm4_order_signal, which checks first that the value is at least that and then compares the median with 5 ms. Two new cases, agc_driver_pm4_order_hold_wait_invalid (50x) and agc_driver_pm4_order_hold_wait_zero (0), use expectSettingRejected like the ring and watchdog cases.

What the test now catches, and what it cannot. If nothing wakes the hold when queue 0 blocks, the median is about 25 ms and the test fails. With either the old bound or the new one, it cannot tell whether the orderHolders notify that #22188 added at the end of Driver::noteWaitBlocked is present. In this test queue 0's block leaves no worker running, so the idle-epoch notify a few lines earlier (runningWorkers reaching 0) wakes the hold too. It fires just before queue0Awaited is stored, and the woken hold nearly always reads the value after the store. Removing only the orderHolders notify left the median at 0.07 ms (table below). Only the rare lost race fell back to the fallback wait, which is where 10 to 25 ms largest samples came from.

To see that notify alone, another worker has to be running when queue 0 blocks. I tried a third queue (0x21) running 16384 writes behind an already-satisfied WAIT_REG_MEM, which made it not wait-free, so nothing held it or was held behind it. It did not overlap the block in any of 32 rounds: write streams on two queues ran one after the other (APS5_TRACE_GPU: queue 0's 4096 writes reached its wait at 132 ms, after queue 0x21 finished at 107 ms). That attempt is not in this PR. A running GPU dispatch on another queue might do it; that would be a follow-up if you want it.

#23886 (cocoa55) has since landed: on main an APS5_SKIP_TIMING_TESTS return before this check skips the latency bound in the sanitizer job. This head is rebased onto it and keeps that return, so the 5 ms bound applies wherever timing tests run.

Tested

Linux Mint 22.3, kernel 7.0.0-38, GCC 13.3.0, Release, BUILD_TESTING=ON. Head on main 4cb7752e50, rebased over #23886; the only conflict was that check line. The table and the load runs below were measured on the previous head on main 79d02ad925. The order-signal test creates no Vulkan device (the split suite runs it once), so the device setting does not matter for it. It ran with ANYPS5_GPU set to each of the three devices below.

Build runs result median / largest, ms
this PR 9 (3 per device setting) pass 9/9 0.068-0.081 / 1.54-3.01
this PR, the idle-epoch and orderHolders notifies removed from noteWaitBlocked (nothing wakes the hold) 9 fail 9/9 19.0-25.5 / 25.8-26.4
this PR, only the orderHolders notify removed 9 pass 9/9 0.069-1.536 / 2.9-25.2
under 4 busy loops on the 4 cores, interleaved, 10 each with the GTX and llvmpipe settings: main 79d02ad925 20 fail 1/20 (median 0.153 ms)
same load: this PR 20 pass 20/20
  • On this head: agc_driver_pm4_order_signal passes 12/12, 3 runs with each of the GTX 1050 Ti, HD 630, llvmpipe and lavapipe 26.0.8 settings (median 0.051-0.060 ms), and once each with the validation layer (no VUIDs).
  • agc_driver_pm4_order_hold_wait_invalid and _zero pass. As a control, the invalid mode run with a valid value (APS5_ORDER_HOLD_WAIT_US=500) fails with expected PM4 rejection.
  • The split suite of this head against a split run of main 41dfbe4d8e on the same machine (every test once on the GTX 1050 Ti, the 2091 GPU tests on all three devices). GTX: no failure. HD 630: the 10 known on this machine and 4 more. llvmpipe: image_filter_mode_three (#27671), scattered_runs (#21649) and 2 more. The 6 extra failures are image_d16_load (HD 630, llvmpipe), image_plane_offset_on_line and image_sample_cube_offset (HD 630), and image_sample_lod_clamp_shader_lane (HD 630, llvmpipe). The first three are tests that landed on main since (#22750, #23701, #23498). With this PR's changes left out, main 4cb7752e50 fails all 6 the same way, 3/3 on each device. The two new tests pass on all three.
  • check_conventions.py, check_test_registration.py, check_main_sync.py (1 ahead, 0 behind, merges cleanly), check_compile.py (3 translation units), tools/env_reference.py --check (751 names, all documented) and git diff --check are clean.
  • tools/pr_overlap.py --branch compared 174 PRs and reports one: #22029 at Pm4.cpp L3049, the one-line mode table that the two new cases extend. Of the 25 it could not compare (they conflict with main), #6186, #11436 and #12944 touch the same files but not these lines (#12944 changes the test mode list a few lines away in agc_driver_graphics_tests.cmake); the others share only ENVIRONMENT.md or that cmake file.
  • Not run on Windows, where queue 0's own hold uses poll (unchanged here).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (the mode-table line also with #22029)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce GTX 1050 Ti (580.178.04), Intel HD Graphics 630 (Mesa 25.2.8 ANV), llvmpipe (Mesa 25.2.8); Linux Mint 22.3, kernel 7.0.0-38
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a test-only setting to configure the order-hold wait duration. It defaults to 200 microseconds and accepts values from 1 to 1,000,000 microseconds.
  • Bug Fixes
    • Invalid and zero wait-duration values are now rejected.
    • Updated the order-signal test to allow a longer configured wait while checking wake latency.
  • Documentation
    • Documented the new setting and its accepted values.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5410563676 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24170). Originally posted by [GiannisG1](https://github.com/GiannisG1) on 2026-11-20T08:55:55Z. --- ### What `agc_driver_pm4_order_signal` (#22188) fails on `main`'s Linux job. It checks that a wait-free submission held behind queue 0 starts within 0.1 ms (median) of queue 0 blocking on the label it writes, and loaded runners land around 0.14 ms. On #22188, oneandonlydean asked for a test in which a missed wake is slow instead of a small gap ([comment](https://github.com/boykopovar/AnyPS5/pull/22188#issuecomment-7023761248)), and I took the first variant ([comment](https://github.com/boykopovar/AnyPS5/pull/22188#issuecomment-7034025683)). - `QueueWorker.cpp`: the held submission's `changed.wait_for` waits `OrderHoldWait()` instead of a fixed 200 µs. - `SubmissionRing.cpp`: `OrderHoldWait()` reads a test-only `APS5_ORDER_HOLD_WAIT_US`, from 1 to 1000000. It defaults to 200, so nothing changes unless the variable is set. It is read with the other queue settings at the first submission (`ReadSubmissionRingSettings`), so an invalid or zero value rejects the submission, as `APS5_PM4_RING` and `APS5_STALL_WATCHDOG_SECS` do. `docs/dev/ENVIRONMENT.md` lists it. - The test: ctest sets 50000 for `agc_driver_pm4_order_signal`, which checks first that the value is at least that and then compares the median with 5 ms. Two new cases, `agc_driver_pm4_order_hold_wait_invalid` (`50x`) and `agc_driver_pm4_order_hold_wait_zero` (`0`), use `expectSettingRejected` like the ring and watchdog cases. **What the test now catches, and what it cannot.** If nothing wakes the hold when queue 0 blocks, the median is about 25 ms and the test fails. With either the old bound or the new one, it cannot tell whether the `orderHolders` notify that #22188 added at the end of `Driver::noteWaitBlocked` is present. In this test queue 0's block leaves no worker running, so the idle-epoch notify a few lines earlier (`runningWorkers` reaching 0) wakes the hold too. It fires just before `queue0Awaited` is stored, and the woken hold nearly always reads the value after the store. Removing only the `orderHolders` notify left the median at 0.07 ms (table below). Only the rare lost race fell back to the fallback wait, which is where 10 to 25 ms largest samples came from. To see that notify alone, another worker has to be running when queue 0 blocks. I tried a third queue (0x21) running 16384 writes behind an already-satisfied `WAIT_REG_MEM`, which made it not wait-free, so nothing held it or was held behind it. It did not overlap the block in any of 32 rounds: write streams on two queues ran one after the other (`APS5_TRACE_GPU`: queue 0's 4096 writes reached its wait at 132 ms, after queue 0x21 finished at 107 ms). That attempt is not in this PR. A running GPU dispatch on another queue might do it; that would be a follow-up if you want it. #23886 (cocoa55) has since landed: on `main` an `APS5_SKIP_TIMING_TESTS` return before this `check` skips the latency bound in the sanitizer job. This head is rebased onto it and keeps that return, so the 5 ms bound applies wherever timing tests run. ### Tested Linux Mint 22.3, kernel 7.0.0-38, GCC 13.3.0, Release, `BUILD_TESTING=ON`. Head on `main` `4cb7752e50`, rebased over #23886; the only conflict was that `check` line. The table and the load runs below were measured on the previous head on `main` `79d02ad925`. The order-signal test creates no Vulkan device (the split suite runs it once), so the device setting does not matter for it. It ran with `ANYPS5_GPU` set to each of the three devices below. | Build | runs | result | median / largest, ms | |---|---|---|---| | this PR | 9 (3 per device setting) | pass 9/9 | 0.068-0.081 / 1.54-3.01 | | this PR, the idle-epoch and `orderHolders` notifies removed from `noteWaitBlocked` (nothing wakes the hold) | 9 | fail 9/9 | 19.0-25.5 / 25.8-26.4 | | this PR, only the `orderHolders` notify removed | 9 | pass 9/9 | 0.069-1.536 / 2.9-25.2 | | under 4 busy loops on the 4 cores, interleaved, 10 each with the GTX and llvmpipe settings: `main` `79d02ad925` | 20 | fail 1/20 (median 0.153 ms) | | | same load: this PR | 20 | pass 20/20 | | - On this head: `agc_driver_pm4_order_signal` passes 12/12, 3 runs with each of the GTX 1050 Ti, HD 630, llvmpipe and lavapipe 26.0.8 settings (median 0.051-0.060 ms), and once each with the validation layer (no VUIDs). - `agc_driver_pm4_order_hold_wait_invalid` and `_zero` pass. As a control, the invalid mode run with a valid value (`APS5_ORDER_HOLD_WAIT_US=500`) fails with `expected PM4 rejection`. - The split suite of this head against a split run of `main` `41dfbe4d8e` on the same machine (every test once on the GTX 1050 Ti, the 2091 GPU tests on all three devices). GTX: no failure. HD 630: the 10 known on this machine and 4 more. llvmpipe: `image_filter_mode_three` (#27671), `scattered_runs` (#21649) and 2 more. The 6 extra failures are `image_d16_load` (HD 630, llvmpipe), `image_plane_offset_on_line` and `image_sample_cube_offset` (HD 630), and `image_sample_lod_clamp_shader_lane` (HD 630, llvmpipe). The first three are tests that landed on `main` since (#22750, #23701, #23498). With this PR's changes left out, `main` `4cb7752e50` fails all 6 the same way, 3/3 on each device. The two new tests pass on all three. - `check_conventions.py`, `check_test_registration.py`, `check_main_sync.py` (1 ahead, 0 behind, merges cleanly), `check_compile.py` (3 translation units), `tools/env_reference.py --check` (751 names, all documented) and `git diff --check` are clean. - `tools/pr_overlap.py --branch` compared 174 PRs and reports one: #22029 at `Pm4.cpp` L3049, the one-line mode table that the two new cases extend. Of the 25 it could not compare (they conflict with `main`), #6186, #11436 and #12944 touch the same files but not these lines (#12944 changes the test mode list a few lines away in `agc_driver_graphics_tests.cmake`); the others share only `ENVIRONMENT.md` or that cmake file. - Not run on Windows, where queue 0's own hold uses `poll` (unchanged here). ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (the mode-table line also with #22029) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce GTX 1050 Ti (580.178.04), Intel HD Graphics 630 (Mesa 25.2.8 ANV), llvmpipe (Mesa 25.2.8); Linux Mint 22.3, kernel 7.0.0-38 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added a test-only setting to configure the order-hold wait duration. It defaults to 200 microseconds and accepts values from 1 to 1,000,000 microseconds. * **Bug Fixes** * Invalid and zero wait-duration values are now rejected. * Updated the order-signal test to allow a longer configured wait while checking wake latency. * **Documentation** * Documented the new setting and its accepted values. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-20 09:24:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T09:24:44Z.

Review: COMMENTED


Reviewed — comments

The new configurable fallback wait and test cases are documented and wired into submission settings; the timing test’s stated limit is not demonstrated by this change.

What I ran

Read the prepared diff and all six changed files at head 4de3318c33e18f081fc3d48fed850c0df899e004, including every added line. Read Submission.cpp around the callers of ReadSubmissionRingSettings. No tests or build checks were run.

Results

Check Result Note
Diff and changed lines passed All six changed files read
Targeted caller context passed Submission settings callers read
Build and tests not run No commands run

Findings

Blocking

None.

Non-blocking

  • The new test is described as detecting a missing queue 0 wake, but the author’s own description reports that removing only orderHolders notification still passes 9/9 runs, with a median as high as 1.536 ms, under the 5 ms threshold. This makes the test tolerant of the specific missed-wake defect it aims to detect. Consider tightening or restructuring the test so this regression fails reliably. Changed line: core/libs/prx/libSceAgcDriver/tests/Pm4.cpp:2667.

Not verified

No build, tests, or static checks were run. The author’s reported test results were not independently verified. Read all changed files listed in the manifest; no changed files were excluded.

To get this to a good state

Nothing is required. The optional test reliability point is listed above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5990352075 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24170#pullrequestreview-5990352075). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T09:24:44Z. **Review:** COMMENTED --- # Reviewed — comments The new configurable fallback wait and test cases are documented and wired into submission settings; the timing test’s stated limit is not demonstrated by this change. ## What I ran Read the prepared diff and all six changed files at head `4de3318c33e18f081fc3d48fed850c0df899e004`, including every added line. Read `Submission.cpp` around the callers of `ReadSubmissionRingSettings`. No tests or build checks were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | All six changed files read | | Targeted caller context | passed | Submission settings callers read | | Build and tests | not run | No commands run | ## Findings ### Blocking None. ### Non-blocking - The new test is described as detecting a missing queue 0 wake, but the author’s own description reports that removing only `orderHolders` notification still passes 9/9 runs, with a median as high as 1.536 ms, under the 5 ms threshold. This makes the test tolerant of the specific missed-wake defect it aims to detect. Consider tightening or restructuring the test so this regression fails reliably. Changed line: `core/libs/prx/libSceAgcDriver/tests/Pm4.cpp:2667`. ## Not verified No build, tests, or static checks were run. The author’s reported test results were not independently verified. Read all changed files listed in the manifest; no changed files were excluded. ## To get this to a good state Nothing is required. The optional test reliability point is listed above.
MarcZX10 commented 2026-11-27 09:08:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T09:08:46Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head c5564d012d500c16114be5972b01cb8ffb7fcaed. No commands or tests were run; this review used the prepared diff and pinned repository reader.

Results

Check Result Note
Changed code review passed All six changed files and added lines reviewed
Automated checks not run Results in the description are author-reported

Findings

Blocking

None.

Non-blocking

  • The description explains that this test does not isolate the orderHolders notification: the idle-epoch notification can also wake the hold. That limitation is documented clearly, but the test's name and failure text may still suggest it verifies the specific wake introduced in #22188. Consider clarifying the test description or name that it checks prompt wake behavior through the available notifications, while retaining the stated follow-up for a test that isolates orderHolders.

Not verified

No tests, builds, or platform-specific behavior were run. Author-reported Linux test and check results were not independently verified; Windows behavior was not run. The prepared review folder contained all changed files; all six changed files listed in the manifest were read, including each added line. The diff excluded no changed files according to the manifest.

To get this to a good state

Nothing is required. The test-isolation clarification is optional.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6085819247 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24170#pullrequestreview-6085819247). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T09:08:46Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `c5564d012d500c16114be5972b01cb8ffb7fcaed`. No commands or tests were run; this review used the prepared diff and pinned repository reader. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All six changed files and added lines reviewed | | Automated checks | not run | Results in the description are author-reported | ## Findings ### Blocking None. ### Non-blocking - The description explains that this test does not isolate the `orderHolders` notification: the idle-epoch notification can also wake the hold. That limitation is documented clearly, but the test's name and failure text may still suggest it verifies the specific wake introduced in #22188. Consider clarifying the test description or name that it checks prompt wake behavior through the available notifications, while retaining the stated follow-up for a test that isolates `orderHolders`. ## Not verified No tests, builds, or platform-specific behavior were run. Author-reported Linux test and check results were not independently verified; Windows behavior was not run. The prepared review folder contained all changed files; all six changed files listed in the manifest were read, including each added line. The diff excluded no changed files according to the manifest. ## To get this to a good state Nothing is required. The test-isolation clarification is optional.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!24170
No description provided.