Skip to content

test(agc): move the lock-hold spin increment out of the for-increment - #18312

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
dantdmdarealguy:agent/winwarn2
Nov 13, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
dantdmdarealguy:agent/winwarn2

Conversation

@dantdmdarealguy

Copy link
Copy Markdown
Contributor

What

MutexCounts in core/libs/prx/libSceAgcDriver/tests/Locks.cpp holds the mutex for a while by spinning on a volatile int. That loop was written as for (volatile int spin = 0; spin < holdSpins; spin = spin + 1) {}. GCC 15 warns about the for-increment:

core/libs/prx/libSceAgcDriver/tests/Locks.cpp:36:68: warning: using value of assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile]

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 in core/libs/tests/GuestRaiseException.cpp. Every iteration still loads and stores the volatile, so the lock is still held for holdSpins iterations. With WinLibs GCC 15.2.0 at -O3, the disassembly of agc_locks_tests.exe is 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 (gcc15 package) and GCC 16.2.1, Release.

Build main This PR
Windows, WinLibs GCC 15.2.0 -Wvolatile at Locks.cpp:36:68 no warning in Locks.cpp
Arch, GCC 15.3.0 -Wvolatile at Locks.cpp:36:68 no warning in Locks.cpp
Arch, GCC 16.2.1 no warning no warning
  • objdump -d of agc_locks_tests.exe (Windows, -O3) is identical on main and with the change. The spin loop is mov 0x2c(%rsp),%eax; add $0x1,%eax; mov %eax,0x2c(%rsp); mov 0x2c(%rsp),%eax; cmp; jg in both.
  • ctest -R '^agc_locks$' --repeat until-fail:100 results:
    • Windows, main: 100/100 idle (18.7 s) and 100/100 under load (32.9 s; 32 busy CPU threads alongside other builds).
    • Windows, this PR: 100/100 idle (18.7 s), 100/100 under load (34.5 s), and 100/100 again after rebasing onto a7ac923.
    • Arch GCC 16.2.1: 100/100 on main (23.5 s) and with the change (23.9 s).
    • Arch GCC 15.3.0: 100/100 on main (25.6 s) and with the change (22.5 s).
  • ctest -R "agc_locks|patched_libraries": 2/2 passed.
  • The full build and the libs target both succeed on Windows. The remaining project warnings are in files this PR doesn't touch.
  • tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass. tools/pr_overlap.py reports no overlap.

No test fails on main, because this change removes a warning and doesn't change behaviour.

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
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes, some AI assistance was used

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.
@JJenkx

JJenkx commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Windows check of head f57c41c431 on main 9bce44ce3b (fast-forward). Setup: Windows 11 Enterprise 22621, Ryzen 9 5950X, MinGW-w64 GCC 15.2 UCRT, Release. agc_locks passed in 3 of 3 runs, taking 0.15–0.45 s, with Vulkan hidden. It needs no device.

AI-assisted: yes.

@github-actions github-actions Bot added the agc libSceAgc* label Nov 11, 2026
@gabichuuuuu

Copy link
Copy Markdown
Contributor

Windows check of head f57c41c431, merged onto main f57c971559 (clean merge, built together with other open PRs that touch different files).

Setup: Windows 11 x64, WinLibs GCC 15.2.0 (r7), Ninja, Release, BUILD_TESTING=ON, Python 3.15.

  • Tests built from this PR's test files: agc_locks.
  • All of them pass in 3 of 3 runs.
  • No negative control: the PR changes only test files.

AI-assisted: yes.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, base main.
  • Read-only review: the diff, the head copy of core/libs/prx/libSceAgcDriver/tests/Locks.cpp (all 222 lines), and the same idiom in core/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 127

Results

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

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 ctest runs and timings in the description: author-reported, not reproduced.
  • tools/check_conventions.py and tools/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.

@oneandonlydean
oneandonlydean merged commit b94a634 into boykopovar:main Nov 13, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants