Repository navigation
test(agc): move the lock-hold spin increment out of the for-increment - #18312
Conversation
GCC 15 warns with -Wvolatile on `spin = spin + 1` as the for-increment of the volatile spin in MutexCounts. The same assignment as a loop-body statement keeps the volatile load and store per iteration; the generated test binary is unchanged.
|
Windows check of head AI-assisted: yes. |
|
Windows check of head Setup: Windows 11 x64, WinLibs GCC 15.2.0 (r7), Ninja, Release,
AI-assisted: yes. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this; the points below are optional. The change moves the spin increment out of the for header into a while body, and the loop still reads and writes the volatile the same way.
What I ran
- Head:
f57c41c43186a73146e2f9fcd61c1fac8d81046c, basemain. - Read-only review: the diff, the head copy of
core/libs/prx/libSceAgcDriver/tests/Locks.cpp(all 222 lines), and the same idiom incore/libs/tests/GuestRaiseException.cpp. - No build, no compiler, no test run.
python3 repo_read.py search "volatile int spin" core/libs
python3 repo_read.py search "volatile" core/libs/tests/GuestRaiseException.cpp
python3 repo_read.py cat core/libs/tests/GuestRaiseException.cpp 121 127Results
| Check | Result | Note |
|---|---|---|
| Diff and changed file read | passed | 2 lines changed, file read in full |
| Loop keeps the same volatile reads and writes | passed | by reading the code |
| Same idiom in GuestRaiseException.cpp | passed | line 124 |
| GCC 15 warning gone | not run | no build in this review |
| Disassembly identical | not run | author-reported |
ctest for agc_locks |
not run | author-reported only |
| Convention and registration scripts | not run | not run in this review |
Findings
Blocking
None.
Non-blocking
None.
Sources
- GuestRaiseException.cpp line 124, the
while (...) x = x + 1;form on a volatile.
Not verified
- The GCC 15 warning and its removal, and the GCC 16 behaviour: no build was run.
- The disassembly comparison in the description: the author's Windows build only.
- The
ctestruns and timings in the description: author-reported, not reproduced. tools/check_conventions.pyandtools/check_test_registration.py: not run.- The reference to #6292: not checked.
- Hosted CI for
f57c41c43186a73146e2f9fcd61c1fac8d81046c: not checked.
To get this to a good state
Nothing is required.
What
MutexCountsincore/libs/prx/libSceAgcDriver/tests/Locks.cppholds the mutex for a while by spinning on avolatile int. That loop was written asfor (volatile int spin = 0; spin < holdSpins; spin = spin + 1) {}. GCC 15 warns about the for-increment:This change moves the same assignment into the loop body as a statement:
volatile int spin = 0; while (spin < holdSpins) spin = spin + 1;. The same idiom is already used incore/libs/tests/GuestRaiseException.cpp. Every iteration still loads and stores the volatile, so the lock is still held forholdSpinsiterations. With WinLibs GCC 15.2.0 at-O3, the disassembly ofagc_locks_tests.exeis identical before and after the change. GCC 16.2.1 already accepts the old form, which is a discarded-value expression, so the warning only appears with GCC 15. The loop was added in #6292.Tested
Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release,
-DBUILD_TESTING=ON. Arch Linux (WSL2) on the same machine, GCC 15.3.0 (gcc15package) and GCC 16.2.1, Release.main-WvolatileatLocks.cpp:36:68Locks.cpp-WvolatileatLocks.cpp:36:68Locks.cppobjdump -dofagc_locks_tests.exe(Windows,-O3) is identical onmainand with the change. The spin loop ismov 0x2c(%rsp),%eax; add $0x1,%eax; mov %eax,0x2c(%rsp); mov 0x2c(%rsp),%eax; cmp; jgin both.ctest -R '^agc_locks$' --repeat until-fail:100results:main: 100/100 idle (18.7 s) and 100/100 under load (32.9 s; 32 busy CPU threads alongside other builds).main(23.5 s) and with the change (23.9 s).main(25.6 s) and with the change (22.5 s).ctest -R "agc_locks|patched_libraries": 2/2 passed.libstarget both succeed on Windows. The remaining project warnings are in files this PR doesn't touch.tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.tools/pr_overlap.pyreports no overlap.No test fails on
main, because this change removes a warning and doesn't change behaviour.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)