fix(libkernel): wake timed sleeps for thread cancellation #8916

Merged
Henryisdjfunkyho merged 8 commits from upstream-pr/8916 into main 2026-10-28 00:48:32 +00:00
Henryisdjfunkyho commented 2026-10-21 06:00:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Henryisdjfunkyho on 2026-10-21T06:00:01Z.


What

An enabled pthread cancellation request during a long POSIX usleep, nanosleep or _nanosleep previously waited for the full timeout. Waits longer than 1 ms now wake for enabled cancellation; shorter waits keep the existing GPU completion wake path and check cancellation before and after waiting. This follows POSIX.1-2024 section 2.9.5 (https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html).

sceKernelUsleep, sceKernelNanosleep and sceKernelSleep retain the prior wait path. Six registered deferred-cancellation tests cover all three SCE APIs in normal and coarse modes. The tests observe entry after the initial cancellation check, then require a canceled result, exactly one cleanup call, no normal return, and cleanup no earlier than the full one-second timeout. Ready, wait-entry and completion handshakes have three-second deadlines; each process retains its 20-second CTest timeout. POSIX nanosleep host waits now update the existing per-thread wait counter, matching the Windows sleep tracking used for this handshake. The POSIX cancellation matrix remains registered.

GuestSleepCancel.cpp uses the canonical API header declarations from current main; its duplicate test-local export declarations have been removed. All test cases and assertions are preserved.

The firmware 13.42 disassembly and emulated checks reported by BunnyFl support the SCE cancellation checks before and after sleep. The remaining unmeasured part is whether cancellation arriving mid-sleep interrupts the PS5 kernel sleep syscall. The six SCE deferred tests preserve this tree's current model until that kernel behavior is measured. No title unblock is claimed.

Tested

Fresh validation of 42bbc9823592f50de423d73d743e9bee42b7be5f, with main through cb45ae2ddf6e113a4619e8fed91fe7b9333c5c0f merged into the branch. The conflict was between adjacent debt entries after #11201 merged; its measured thread-creation details and this PR's cancellation entry are both preserved. Bundled dependencies, Release, full runtime configuration with BUILD_TESTING=ON; only the focused targets and tests below were built and run.

  • Windows x86-64, WinLibs GCC 15.2.0: 50/50 focused cases passed, no failures or skips.
  • Linux x86-64, Ubuntu 26.04 LTS under WSL2, kernel 6.18.54.1-microsoft-standard-WSL2, GCC 15.2.0, CMake 4.2.3: 49/49 focused cases passed, no failures or skips. The one-case difference is the Windows-only guest_nanosleep_timer_self_test registration.
  • Both systems register 44 guest_sleep_cancel_* cases, including all six SCE deferred cases. Each SCE case also passed five consecutive executions on each OS, 30 executions per OS.
  • All 65 public-header checks passed on each OS, including the declaration/coverage audit and all 64 standalone-header compilation batches.
  • These are fresh runs after merging current main. Earlier 50/49 reports apply to 4d8f05891b and 5d0ddabbde. The earlier contributor's 48-case report tested aa1e8d27e6 and is not the validation result for this head.

Windows commands, from the worktree root:

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
cmake --build build --target guest_sleep_cancel_tests guest_nanosleep_tests guest_pthread_cancel_tests guest_pthread_cancel_recovery_tests guest_nanosleep_long_request_tests --parallel 4
ctest --test-dir build --output-on-failure --parallel 2 -R '^(guest_nanosleep|guest_nanosleep_timer_self_test|guest_nanosleep_long_request|guest_pthread_cancel|guest_pthread_cancel_recovery|guest_pthread_cancel_recovery_coarse|guest_sleep_cancel_.*)$'
ctest --test-dir build --output-on-failure --parallel 2 --repeat until-fail:5 -R '^guest_sleep_cancel_sce_.*_deferred(_coarse)?$'

Linux commands, from the isolated source checkout:

cmake -S . -B ../build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
cmake --build ../build --target guest_sleep_cancel_tests guest_nanosleep_tests guest_pthread_cancel_tests guest_pthread_cancel_recovery_tests guest_nanosleep_long_request_tests --parallel 4
ctest --test-dir ../build --output-on-failure --parallel 2 -R '^(guest_nanosleep|guest_nanosleep_timer_self_test|guest_nanosleep_long_request|guest_pthread_cancel|guest_pthread_cancel_recovery|guest_pthread_cancel_recovery_coarse|guest_sleep_cancel_.*)$'
ctest --test-dir ../build --output-on-failure --parallel 2 --repeat until-fail:5 -R '^guest_sleep_cancel_sce_.*_deferred(_coarse)?$'

Public-header checks, Windows and Linux respectively:

ctest --test-dir build --output-on-failure --parallel 2 -R '^public_headers(_compile_[0-9]+)?$'
ctest --test-dir ../build --output-on-failure --parallel 2 -R '^public_headers(_compile_[0-9]+)?$'

Negative control on Linux: in an isolated validation copy, replacing SleepWake::Sleep(nanos) inside SleepUntilComplete with CancellableSleep(nanos) made all six SCE cases fail the elapsed-time assertion at GuestSleepCancel.cpp:139. Restoring the exact source, rebuilding, and rerunning the complete focused matrix passed 49/49 again. The mutation is not in this patch.

The long-nanosleep overflow clamp already in main remains intact; guest_nanosleep_long_request passes on both systems. python tools/check_conventions.py --base origin/main --head HEAD and git diff --check origin/main...HEAD pass. The earlier header merge received an independent Luna review with no outstanding findings. I reviewed this debt-entry conflict resolution directly, without a subagent; no new independent review is claimed for this merge.

PR #11201 has merged into main; its measured thread-create/detach entry is preserved alongside this PR's cancellation entry. The refreshed overlap scan flags adjacent debt edits in #7135, which changes cpuset entries, and #10856, which adds a separate cancellation-wait-registration entry. I inspected these hunks; both entries must be preserved when merging. Neither is a semantic prerequisite for this sleep fix. Older PRs with conflicting base histories still prevent complete automated comparisons; no exhaustive combined-PR validation is claimed.

No full repository test-suite, macOS, console, title, GPU or performance result is claimed. Full GitHub runtime CI requires a collaborator's manual Build workflow run under the contribution policy.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4947130111 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8916). Originally posted by [Henryisdjfunkyho](https://github.com/Henryisdjfunkyho) on 2026-10-21T06:00:01Z. --- ### What An enabled pthread cancellation request during a long POSIX `usleep`, `nanosleep` or `_nanosleep` previously waited for the full timeout. Waits longer than 1 ms now wake for enabled cancellation; shorter waits keep the existing GPU completion wake path and check cancellation before and after waiting. This follows POSIX.1-2024 section 2.9.5 (https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html). `sceKernelUsleep`, `sceKernelNanosleep` and `sceKernelSleep` retain the prior wait path. Six registered deferred-cancellation tests cover all three SCE APIs in normal and coarse modes. The tests observe entry after the initial cancellation check, then require a canceled result, exactly one cleanup call, no normal return, and cleanup no earlier than the full one-second timeout. Ready, wait-entry and completion handshakes have three-second deadlines; each process retains its 20-second CTest timeout. POSIX `nanosleep` host waits now update the existing per-thread wait counter, matching the Windows sleep tracking used for this handshake. The POSIX cancellation matrix remains registered. `GuestSleepCancel.cpp` uses the canonical API header declarations from current `main`; its duplicate test-local export declarations have been removed. All test cases and assertions are preserved. The [firmware 13.42 disassembly and emulated checks reported by BunnyFl](https://github.com/boykopovar/AnyPS5/pull/8916#issuecomment-6416760904) support the SCE cancellation checks before and after sleep. The remaining unmeasured part is whether cancellation arriving mid-sleep interrupts the PS5 kernel sleep syscall. The six SCE deferred tests preserve this tree's current model until that kernel behavior is measured. No title unblock is claimed. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Fresh validation of `42bbc9823592f50de423d73d743e9bee42b7be5f`, with `main` through `cb45ae2ddf6e113a4619e8fed91fe7b9333c5c0f` merged into the branch. The conflict was between adjacent debt entries after #11201 merged; its measured thread-creation details and this PR's cancellation entry are both preserved. Bundled dependencies, Release, full runtime configuration with `BUILD_TESTING=ON`; only the focused targets and tests below were built and run. - Windows x86-64, WinLibs GCC 15.2.0: 50/50 focused cases passed, no failures or skips. - Linux x86-64, Ubuntu 26.04 LTS under WSL2, kernel `6.18.54.1-microsoft-standard-WSL2`, GCC 15.2.0, CMake 4.2.3: 49/49 focused cases passed, no failures or skips. The one-case difference is the Windows-only `guest_nanosleep_timer_self_test` registration. - Both systems register 44 `guest_sleep_cancel_*` cases, including all six SCE deferred cases. Each SCE case also passed five consecutive executions on each OS, 30 executions per OS. - All 65 public-header checks passed on each OS, including the declaration/coverage audit and all 64 standalone-header compilation batches. - These are fresh runs after merging current main. Earlier 50/49 reports apply to `4d8f05891b` and `5d0ddabbde`. The earlier contributor's 48-case report tested `aa1e8d27e6` and is not the validation result for this head. Windows commands, from the worktree root: ```sh cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON cmake --build build --target guest_sleep_cancel_tests guest_nanosleep_tests guest_pthread_cancel_tests guest_pthread_cancel_recovery_tests guest_nanosleep_long_request_tests --parallel 4 ctest --test-dir build --output-on-failure --parallel 2 -R '^(guest_nanosleep|guest_nanosleep_timer_self_test|guest_nanosleep_long_request|guest_pthread_cancel|guest_pthread_cancel_recovery|guest_pthread_cancel_recovery_coarse|guest_sleep_cancel_.*)$' ctest --test-dir build --output-on-failure --parallel 2 --repeat until-fail:5 -R '^guest_sleep_cancel_sce_.*_deferred(_coarse)?$' ``` Linux commands, from the isolated source checkout: ```sh cmake -S . -B ../build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON cmake --build ../build --target guest_sleep_cancel_tests guest_nanosleep_tests guest_pthread_cancel_tests guest_pthread_cancel_recovery_tests guest_nanosleep_long_request_tests --parallel 4 ctest --test-dir ../build --output-on-failure --parallel 2 -R '^(guest_nanosleep|guest_nanosleep_timer_self_test|guest_nanosleep_long_request|guest_pthread_cancel|guest_pthread_cancel_recovery|guest_pthread_cancel_recovery_coarse|guest_sleep_cancel_.*)$' ctest --test-dir ../build --output-on-failure --parallel 2 --repeat until-fail:5 -R '^guest_sleep_cancel_sce_.*_deferred(_coarse)?$' ``` Public-header checks, Windows and Linux respectively: ```sh ctest --test-dir build --output-on-failure --parallel 2 -R '^public_headers(_compile_[0-9]+)?$' ctest --test-dir ../build --output-on-failure --parallel 2 -R '^public_headers(_compile_[0-9]+)?$' ``` Negative control on Linux: in an isolated validation copy, replacing `SleepWake::Sleep(nanos)` inside `SleepUntilComplete` with `CancellableSleep(nanos)` made all six SCE cases fail the elapsed-time assertion at `GuestSleepCancel.cpp:139`. Restoring the exact source, rebuilding, and rerunning the complete focused matrix passed 49/49 again. The mutation is not in this patch. The long-nanosleep overflow clamp already in `main` remains intact; `guest_nanosleep_long_request` passes on both systems. `python tools/check_conventions.py --base origin/main --head HEAD` and `git diff --check origin/main...HEAD` pass. The earlier header merge received an independent Luna review with no outstanding findings. I reviewed this debt-entry conflict resolution directly, without a subagent; no new independent review is claimed for this merge. PR #11201 has merged into main; its measured thread-create/detach entry is preserved alongside this PR's cancellation entry. The refreshed overlap scan flags adjacent debt edits in #7135, which changes cpuset entries, and #10856, which adds a separate cancellation-wait-registration entry. I inspected these hunks; both entries must be preserved when merging. Neither is a semantic prerequisite for this sleep fix. Older PRs with conflicting base histories still prevent complete automated comparisons; no exhaustive combined-PR validation is claimed. No full repository test-suite, macOS, console, title, GPU or performance result is claimed. Full GitHub runtime CI requires a collaborator's manual Build workflow run under the contribution policy. ### 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) - [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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-21 06:01:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:01:41Z.


I checked the shared CancellableSleep path and the new test matrix. The POSIX cancellation-point behavior is supported by the cited contract, but the same change also makes sceKernelUsleep, sceKernelNanosleep and sceKernelSleep wake on cancellation; the debt entry says those SCE cancellation semantics have not been measured. Could the implementation keep the new interruptible wait on the POSIX aliases and preserve the current SCE behavior until there is console evidence, or point to the project policy/reference that supports applying the POSIX rule to those exports? The test coverage can still exercise the established POSIX paths either way.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309234736 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8916#issuecomment-6309234736). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T06:01:41Z. --- I checked the shared `CancellableSleep` path and the new test matrix. The POSIX cancellation-point behavior is supported by the cited contract, but the same change also makes `sceKernelUsleep`, `sceKernelNanosleep` and `sceKernelSleep` wake on cancellation; the debt entry says those SCE cancellation semantics have not been measured. Could the implementation keep the new interruptible wait on the POSIX aliases and preserve the current SCE behavior until there is console evidence, or point to the project policy/reference that supports applying the POSIX rule to those exports? The test coverage can still exercise the established POSIX paths either way.
MarcZX10 commented 2026-10-21 06:02:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:02:48Z.


I also checked the exact PR head 722e494d98 from a fresh Linux worktree. python3 tools/check_conventions.py --base upstream/main --head HEAD and git diff --check upstream/main...HEAD both pass. I could not configure the full Linux build: the SDL submodule is uninitialized and this host does not have SDL XRandR support. I did not run the focused runtime tests here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309250008 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8916#issuecomment-6309250008). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T06:02:48Z. --- I also checked the exact PR head `722e494d98` from a fresh Linux worktree. `python3 tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check upstream/main...HEAD` both pass. I could not configure the full Linux build: the SDL submodule is uninitialized and this host does not have SDL XRandR support. I did not run the focused runtime tests here.
Henryisdjfunkyho commented 2026-10-21 07:30:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Henryisdjfunkyho on 2026-10-21T07:30:20Z.


I checked the shared CancellableSleep path and the new test matrix. The POSIX cancellation-point behavior is supported by the cited contract, but the same change also makes sceKernelUsleep, sceKernelNanosleep and sceKernelSleep wake on cancellation; the debt entry says those SCE cancellation semantics have not been measured. Could the implementation keep the new interruptible wait on the POSIX aliases and preserve the current SCE behavior until there is console evidence, or point to the project policy/reference that supports applying the POSIX rule to those exports? The test coverage can still exercise the established POSIX paths either way.

Thanks for flagging this. I’ve limited cancellation-aware behavior to POSIX usleep, nanosleep, and _nanosleep. The sceKernel* calls keep their previous behavior until we can check their cancellation semantics on console. I added tests for that and recorded the open question in the libkernel debt notes. Could you take another look?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310571861 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8916#issuecomment-6310571861). Originally posted by [Henryisdjfunkyho](https://github.com/Henryisdjfunkyho) on 2026-10-21T07:30:20Z. --- > I checked the shared `CancellableSleep` path and the new test matrix. The POSIX cancellation-point behavior is supported by the cited contract, but the same change also makes `sceKernelUsleep`, `sceKernelNanosleep` and `sceKernelSleep` wake on cancellation; the debt entry says those SCE cancellation semantics have not been measured. Could the implementation keep the new interruptible wait on the POSIX aliases and preserve the current SCE behavior until there is console evidence, or point to the project policy/reference that supports applying the POSIX rule to those exports? The test coverage can still exercise the established POSIX paths either way. Thanks for flagging this. I’ve limited cancellation-aware behavior to POSIX usleep, nanosleep, and _nanosleep. The sceKernel* calls keep their previous behavior until we can check their cancellation semantics on console. I added tests for that and recorded the open question in the libkernel debt notes. Could you take another look?
Filip722 commented 2026-10-21 10:00:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Filip722 on 2026-10-21T10:00:47Z.


Linux runtime validation of current head aa1e8d27e6e628ba58366dc41daa7dcca236db0a: all 48 cases registered by the focused selection on Linux passed, with no failures or skips. The six blocked POSIX cases also each passed three consecutive executions.

This exercises the updated split from the review follow-up:

  • POSIX usleep, nanosleep, and _nanosleep: blocked cancellation, disabled cancellation, ordinary completion, pending cancellation at zero duration, and pending cancellation before a long wait.
  • Each API's registered normal/coarse variants; cleanup runs exactly once on cancellation, and the canceled wait does not return normally.
  • The six SCE deferred-cancellation cases (sceKernelUsleep, sceKernelNanosleep, sceKernelSleep, both registrations): the thread remains unfinished during the early observation and completes the requested sleep before pending cancellation is delivered.
  • Existing guest_nanosleep, pthread cancellation/recovery, and sleep controls remain passing.

Negative control: kept the PR tests, replaced only Time.cpp with merge-base b77bd58806a5d9a7ecc91ee7290728a4d2ff4d6d, and rebuilt libkernel. guest_sleep_cancel_usleep_blocked fails after the ten-second sleep with sleep stayed blocked after cancellation and GuestSleepCancel.cpp:132: requirement failed. Restoring the exact PR source and rebuilding makes the unchanged case pass again.

Environment: Debian 13.7 x86-64, Linux 7.2.9-x64v3-xanmod1, AMD Ryzen 5 7640HS, GCC 15.2.0, CMake 3.31.6. Full Release configuration, BUILD_TESTING=ON, ANYPS5_RELINKER_ONLY=OFF, bundled dependencies. Built libkernel and all four focused executables plus dependencies with two jobs.

ctest --test-dir build \
  -R '^(guest_nanosleep|guest_nanosleep_timer_self_test|guest_pthread_cancel|guest_pthread_cancel_recovery|guest_pthread_cancel_recovery_coarse|guest_sleep_cancel_.*)$' \
  --parallel 2 -V
ctest --test-dir build \
  -R '^guest_sleep_cancel_(usleep|nanosleep|_nanosleep)_blocked(_coarse)?$' \
  --repeat until-fail:3 -V

Tracked source restored to the named head. No new Windows/macOS, console, title, GPU or full repository test-suite run. This adds actual Linux runtime coverage beyond the earlier configure/syntax-only checks; it does not establish SCE cancellation semantics on console hardware.

AI-assisted testing and report.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313258240 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8916#issuecomment-6313258240). Originally posted by [Filip722](https://github.com/Filip722) on 2026-10-21T10:00:47Z. --- Linux runtime validation of current head `aa1e8d27e6e628ba58366dc41daa7dcca236db0a`: all **48 cases registered by the focused selection on Linux passed**, with no failures or skips. The six blocked POSIX cases also each passed three consecutive executions. This exercises the updated split from the review follow-up: - POSIX `usleep`, `nanosleep`, and `_nanosleep`: blocked cancellation, disabled cancellation, ordinary completion, pending cancellation at zero duration, and pending cancellation before a long wait. - Each API's registered normal/coarse variants; cleanup runs exactly once on cancellation, and the canceled wait does not return normally. - The six SCE deferred-cancellation cases (`sceKernelUsleep`, `sceKernelNanosleep`, `sceKernelSleep`, both registrations): the thread remains unfinished during the early observation and completes the requested sleep before pending cancellation is delivered. - Existing `guest_nanosleep`, pthread cancellation/recovery, and `sleep` controls remain passing. Negative control: kept the PR tests, replaced only `Time.cpp` with merge-base `b77bd58806a5d9a7ecc91ee7290728a4d2ff4d6d`, and rebuilt libkernel. `guest_sleep_cancel_usleep_blocked` fails after the ten-second sleep with `sleep stayed blocked after cancellation` and `GuestSleepCancel.cpp:132: requirement failed`. Restoring the exact PR source and rebuilding makes the unchanged case pass again. Environment: Debian 13.7 x86-64, Linux `7.2.9-x64v3-xanmod1`, AMD Ryzen 5 7640HS, GCC 15.2.0, CMake 3.31.6. Full Release configuration, `BUILD_TESTING=ON`, `ANYPS5_RELINKER_ONLY=OFF`, bundled dependencies. Built libkernel and all four focused executables plus dependencies with two jobs. ```sh ctest --test-dir build \ -R '^(guest_nanosleep|guest_nanosleep_timer_self_test|guest_pthread_cancel|guest_pthread_cancel_recovery|guest_pthread_cancel_recovery_coarse|guest_sleep_cancel_.*)$' \ --parallel 2 -V ctest --test-dir build \ -R '^guest_sleep_cancel_(usleep|nanosleep|_nanosleep)_blocked(_coarse)?$' \ --repeat until-fail:3 -V ``` Tracked source restored to the named head. No new Windows/macOS, console, title, GPU or full repository test-suite run. This adds actual Linux runtime coverage beyond the earlier configure/syntax-only checks; it does not establish SCE cancellation semantics on console hardware. AI-assisted testing and report.
harisibrar1 commented 2026-10-24 13:24:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T13:24:46Z.

Review: COMMENTED


Checked against main 6cd36e6517 and FreeBSD 11.4 lib/libthr (thr_syscalls.c __thr_nanosleep with _thr_cancel_enter/_thr_cancel_leave(curthread, 1)):

  • It still merges cleanly, and main hasn't done this: POSIX usleep/nanosleep/_nanosleep go through CancellableSleep, which only checks before and after the host sleep. The new long-wait loop mirrors sleep_nid_postfix and looks right to me, and making these POSIX calls cancellation points matches libthr.
  • The SCE "deferred" tests mentioned in the reply above seem to have been lost in the rewrite. aa1e8d27e6 registered foreach(sleepApi IN ITEMS sce_usleep sce_nanosleep sce_sleep) ..._deferred tests, but the current head isn't a descendant of it: at c7e2611 the CMake loop only covers usleep nanosleep _nanosleep, and the deferred mode is gone from GuestSleepCancel.cpp. So the 48-case Linux run above was for an earlier head, and nothing currently pins the "longer SCE waits do not wake on cancellation" debt wording. Could you restore those registrations?
  • If they're not restored, the sce_* branches in Sleep() (GuestSleepCancel.cpp:50-57) and the sceKernelSleep declaration are unreachable and could be removed.
  • Runtime of the 30 new tests looks fine from reading the test (I didn't run it): about 2 s per API/registration pair on the passing path, about 10 s worst case on a regression, both under TIMEOUT 20.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638403965 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8916#pullrequestreview-5638403965). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T13:24:46Z. **Review:** COMMENTED --- Checked against main 6cd36e6517 and FreeBSD 11.4 lib/libthr (thr_syscalls.c `__thr_nanosleep` with `_thr_cancel_enter`/`_thr_cancel_leave(curthread, 1)`): - It still merges cleanly, and main hasn't done this: POSIX `usleep`/`nanosleep`/`_nanosleep` go through `CancellableSleep`, which only checks before and after the host sleep. The new long-wait loop mirrors `sleep_nid_postfix` and looks right to me, and making these POSIX calls cancellation points matches libthr. - The SCE "deferred" tests mentioned in the reply above seem to have been lost in the rewrite. aa1e8d27e6 registered `foreach(sleepApi IN ITEMS sce_usleep sce_nanosleep sce_sleep)` `..._deferred` tests, but the current head isn't a descendant of it: at c7e2611 the CMake loop only covers `usleep nanosleep _nanosleep`, and the `deferred` mode is gone from GuestSleepCancel.cpp. So the 48-case Linux run above was for an earlier head, and nothing currently pins the "longer SCE waits do not wake on cancellation" debt wording. Could you restore those registrations? - If they're not restored, the `sce_*` branches in `Sleep()` (GuestSleepCancel.cpp:50-57) and the `sceKernelSleep` declaration are unreachable and could be removed. - Runtime of the 30 new tests looks fine from reading the test (I didn't run it): about 2 s per API/registration pair on the passing path, about 10 s worst case on a regression, both under TIMEOUT 20. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
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!8916
No description provided.