feat(libkernel): trace semaphore lifecycle under sync logging #6123

Merged
MarcZX10 merged 2 commits from upstream-pr/6123 into main 2026-10-18 18:22:40 +00:00
MarcZX10 commented 2026-10-14 22:50:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T22:50:19Z.


What

Extend APS5_TRACE_SYNC to log semaphore creation, successful signals with token counts before and after, and wait begin/end with the same semaphore address, name, need, available count, timeout and guest caller. This makes semaphore instances traceable across their lifecycle and shows whether any signal reaches a waiter. It also passes the guest caller address to the existing wait aggregator rather than the internal lambda call site. Tracing remains disabled unless the environment variable is set.

Related to #6006, where the report needs to distinguish which same-named semaphore instance receives signals.

Tested

Linux x86-64, GCC 12.2, Release, Ninja:

  • Built libkernel, guest_semaphore_tests and the standalone semaphore_trace_tests target.
  • guest_semaphore_trace passed. It captures stderr with tracing disabled and enabled, then checks create/signal/wait records use the same semaphore address and identify an indefinite wait as timeout=-1.
  • python3 tools/check_conventions.py --base upstream/main, python3 tools/check_test_registration.py <build>, and git diff --check passed.
  • The emulator-linked guest_semaphore test cannot run on this host: the Xeon E5-1620 v2 lacks LZCNT, BMI1, BMI2, MOVBE, AVX2 and FMA required by the emulator. The standalone test exercises the production semaphore and timed-wait sources without that emulator CPU gate.

Checklist

  • Based on current main; no other open pull request implements this change
  • One topic per pull request
  • No comments in code added
  • Unimplemented paths throw; no silent stubs added
  • No investigation notes or title data added
  • No third-party code added
  • Generic diagnostic behavior
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4865631418 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6123). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T22:50:19Z. --- ### What Extend `APS5_TRACE_SYNC` to log semaphore creation, successful signals with token counts before and after, and wait begin/end with the same semaphore address, name, need, available count, timeout and guest caller. This makes semaphore instances traceable across their lifecycle and shows whether any signal reaches a waiter. It also passes the guest caller address to the existing wait aggregator rather than the internal lambda call site. Tracing remains disabled unless the environment variable is set. Related to #6006, where the report needs to distinguish which same-named semaphore instance receives signals. ### Tested Linux x86-64, GCC 12.2, Release, Ninja: - Built `libkernel`, `guest_semaphore_tests` and the standalone `semaphore_trace_tests` target. - `guest_semaphore_trace` passed. It captures stderr with tracing disabled and enabled, then checks create/signal/wait records use the same semaphore address and identify an indefinite wait as `timeout=-1`. - `python3 tools/check_conventions.py --base upstream/main`, `python3 tools/check_test_registration.py <build>`, and `git diff --check` passed. - The emulator-linked `guest_semaphore` test cannot run on this host: the Xeon E5-1620 v2 lacks LZCNT, BMI1, BMI2, MOVBE, AVX2 and FMA required by the emulator. The standalone test exercises the production semaphore and timed-wait sources without that emulator CPU gate. ### Checklist - [x] Based on current `main`; no other open pull request implements this change - [x] One topic per pull request - [x] No comments in code added - [x] Unimplemented paths throw; no silent stubs added - [x] No investigation notes or title data added - [x] No third-party code added - [x] Generic diagnostic behavior - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-15 12:15:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:15:06Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4972 core/libs/prx/libkernel/CMakeLists.txt
PR 5021 core/libs/prx/libkernel/CMakeLists.txt
PR 6044 core/libs/prx/libkernel/CMakeLists.txt
PR 6226 core/libs/prx/libkernel/CMakeLists.txt
PR 6244 core/libs/prx/libkernel/CMakeLists.txt
PR 6658 core/libs/prx/libkernel/CMakeLists.txt
PR 6908 core/libs/prx/libkernel/CMakeLists.txt
PR 6936 core/libs/prx/libkernel/CMakeLists.txt
PR 6977 core/libs/prx/libkernel/CMakeLists.txt
PR 7192 core/libs/prx/libkernel/CMakeLists.txt
PR 7201 core/libs/prx/libkernel/CMakeLists.txt
PR 7299 core/libs/prx/libkernel/CMakeLists.txt
PR 7332 core/libs/prx/libkernel/CMakeLists.txt
PR 7464 core/libs/prx/libkernel/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191803295 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6123#issuecomment-6191803295). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:15:06Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 4972](https://www.github.com/boykopovar/AnyPS5/pull/4972) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6226](https://www.github.com/boykopovar/AnyPS5/pull/6226) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6244](https://www.github.com/boykopovar/AnyPS5/pull/6244) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6658](https://www.github.com/boykopovar/AnyPS5/pull/6658) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6908](https://www.github.com/boykopovar/AnyPS5/pull/6908) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7299](https://www.github.com/boykopovar/AnyPS5/pull/7299) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libkernel/CMakeLists.txt` | | [PR 7464](https://www.github.com/boykopovar/AnyPS5/pull/7464) | `core/libs/prx/libkernel/CMakeLists.txt` |
adriadam10 commented 2026-10-16 23:31:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:31:31Z.


Checked the new guest_semaphore_trace test: it passes with the PR and fails against main's Semaphore.cpp; tracing stays off without APS5_TRACE_SYNC. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226637848 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6123#issuecomment-6226637848). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T23:31:31Z. --- Checked the new `guest_semaphore_trace` test: it passes with the PR and fails against `main`'s `Semaphore.cpp`; tracing stays off without `APS5_TRACE_SYNC`. Merging once the full Build is green.
MarcZX10 commented 2026-10-16 23:38:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T23:38:07Z.


Thanks for checking the regression and its main control. I independently built PR head a741cd435 on Linux x86-64 with GCC 12.2, Release, and BUILD_TESTING=ON. libkernel, guest_semaphore_tests, and semaphore_trace_tests all built, and ctest --test-dir /tmp/AnyPS5-pr6123-build --output-on-failure -R '^guest_semaphore_trace$' passed (1/1).

I did not run guest_semaphore; this host lacks the CPU features required by the emulator. The hosted Linux and Windows Build jobs remain skipped on this PR, so this is focused local validation, not a full Build result.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226716116 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6123#issuecomment-6226716116). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T23:38:07Z. --- Thanks for checking the regression and its `main` control. I independently built PR head `a741cd435` on Linux x86-64 with GCC 12.2, Release, and `BUILD_TESTING=ON`. `libkernel`, `guest_semaphore_tests`, and `semaphore_trace_tests` all built, and `ctest --test-dir /tmp/AnyPS5-pr6123-build --output-on-failure -R '^guest_semaphore_trace$'` passed (1/1). I did not run `guest_semaphore`; this host lacks the CPU features required by the emulator. The hosted Linux and Windows Build jobs remain skipped on this PR, so this is focused local validation, not a full Build result.
oneandonlydean commented 2026-10-18 18:24:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T18:24:01Z.


Merged while @adriadam10 is away: the review passed and full CI is green on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253489521 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6123#issuecomment-6253489521). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-18T18:24:01Z. --- Merged while @adriadam10 is away: the review passed and full CI is green on this head.
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!6123
No description provided.