fix(libkernel): read a size-0 _umtx_op timeout as a timespec #16873

Open
JAB-dev wants to merge 1 commit from upstream-pr/16873 into main
JAB-dev commented 2026-11-07 19:41:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-11-07T19:41:10Z.


Unity's worker threads spin in Monopoly (PPSA17419): every timed wait they make through PS5Util.prx expires the moment it starts. Reading that timeout the way the PS5 kernel does takes the language-select screen from 10.8 to 13.4 FPS (+24%) on the same machine, and from 9.4 to 13.5 FPS (+42%) with APS5_DRAW_PIPELINE=1.

What

_umtx_op with size argument 0 reads its timeout as a relative struct timespec, and an invalid one fails with EINVAL like an explicit size. That is what the PS5 kernel does: in firmware 13.60 the UMTX_OP_WAIT, WAIT_UINT and WAIT_UINT_PRIVATE handlers compare the size argument with 16, copy a 16-byte timespec for any size up to 16 (0 included) and 24 bytes above it, and return EINVAL (22) for a negative tv_sec or a tv_nsec above 999999999 (unsigned compare, so negative too); firmware 5.50 has the same code. FreeBSD 11's umtx_copyin_umtx_time does the same. Since the change that added microsecond size-0 timeouts, main reads a 4-byte microsecond count there. UmtxDeadline serves the wait, SEM_WAIT, umutex and rwlock operations, so they all change the same way; condition-variable waits decode their timeout separately and do not change.

Monopoly's PS5Util.prx export zlqfTyrQSPk (RVA 0x102a0) is jmp 0x10500. It takes a pointer to a 32-bit microsecond count, converts the count to a timespec on its stack, checks it as one, and passes it to _umtx_op with size argument 0:

10532: mov (%rdx),%eax                                  ; the caller's microseconds
10540: imul $0x431bde83,%rax,%rcx ; shr $0x32,%rcx       ; seconds = us / 1000000
1054b: imul $0xf4240,%ecx,%edx ; sub %edx,%eax ; imul $0x3e8,%eax,%eax   ; nanoseconds
10559: mov %rax,-0x38(%rbp) ; mov %rcx,-0x40(%rbp)       ; {tv_sec, tv_nsec}
10566: lea -0x40(%rbp),%rdx ; ... ; call 0x10700
10700: mov %rdx,%r8 ; mov %rsi,%rdx
1070b: cmpq $0x0,(%r8) ; js 0x1072c ; jne 0x1071a       ; tv_sec < 0: ETIMEDOUT
10713: cmpq $0x0,0x8(%r8) ; jle 0x1072c                  ; tv_sec == 0 and tv_nsec <= 0: ETIMEDOUT
1071a: mov $0x2,%esi ; mov $0xffffffff,%r9d ; xor %ecx,%ecx ; jmp 0x10790
10794: call 0x10340                                      ; PLT slot of _umtx_op (04AjkP0jO9U)

On an earlier build, with a libkernel that logged every size-0 caller, the only one in a run of the language screen returned to PS5Util.prx+0x10799 and passed 00000000 00000000 000f4240 00000000, a timespec of 1 ms. Read as microseconds, every such wait has a 0 or near-0 count: about 1.6 million waits a second expired on entry, and five Unity threads used about 92% of a core each. On the current base, sampled stacks of those five threads on main return to PS5Util.prx+0x10799; with this change three threads use 52-77% of a core each and every other thread less than 7%.

That change's Metal Gear Solid 4 (PPSA18194) listing shows the game passing a pointer to a 4-byte microsecond count to zlqfTyrQSPk, the same export whose Monopoly build converts that count to a timespec before it calls _umtx_op. The moves it quotes (mov %rdx,%r8, mov %rsi,%rdx, mov $0x2,%esi, xor %ecx,%ecx) also appear in Monopoly's helper at 0x10700, which runs after the conversion. I can't check that title's PS5Util.prx build because I don't have it. It also named SCE libc.prx: the libc.prx Monopoly ships calls _umtx_op with size 0 only from its once-flag wait, with a null timeout (xor %edx,%edx before the wrapper that moves it into r8), so that call doesn't change. The older PS5Util.prx builds I checked import sceKernelSyncOnAddressWait and don't call _umtx_op. A caller that did pass a bare 4-byte count with size 0 would get the console's reading: 16 bytes read as a timespec. @leorossi2005, could you check whether Metal Gear Solid 4 still gets past its startup barrier with this change?

Tested

  • Performance report captures, APS5_TRACE_SECONDS=40:20 and no other switch, Monopoly (PPSA17419) language-select screen, main at 07c8408713 and this change at 5ece2d8b9e (the same base), captured alternately (each trace lost slices once its buffer filled; the totals behind the summary lines are complete):
main this change
FPS 11.05, 10.57 13.12, 13.66
frame p50 / p90 / p99 87.4 / 106.3 / 145.0, 90.9 / 118.0 / 157.1 ms 74.3 / 85.7 / 113.2, 71.2 / 84.4 / 104.5 ms
GPU busy per present 39.6, 35.8 ms 34.4, 33.8 ms

Traces, in capture order:

Summary lines, in capture order:

{"commit":"07c8408713eb","dirty":false,"env":{"APS5_TRACE_SECONDS":"40:20"},"gpu":"NVIDIA GeForce RTX 4070 SUPER","driver":"NVIDIA 610.88","os":"Windows 10.0.26100","cpu":"AMD Ryzen 5 5600XT 6-Core Processor","cpu_threads":12,"memory_mib":32694,"title_id":"PPSA17419","title":"MONOPOLY®","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 40:20","first_present":235,"ms":20084.143},"presents":222,"frame_ms":{"p50":87.354,"p90":106.316,"p99":144.980,"max":150.004},"gpu_busy_ms_per_present":39.604,"worker_busy_pct":{"queue worker 0x0":98.091},"top_phases_ms_per_frame":{"Driver.Packet":87.083,"Driver.Packet.draw":64.580,"Driver.Draw":64.039,"Graphics.Draw":59.514,"Graphics.Draw.draw_and_resource_release":47.743,"Driver.Draw.draw_enqueued":28.639,"Driver.Draw.shader_compile_and_link":28.328,"Shader.DrawStage":22.382},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.388,"events_lost":735788,"totals_full":false},"draw committer":{"events_full_after_s":11.527,"events_lost":204283,"totals_full":false}},"trace":"aps5-trace-07c8408713eb-134008.json.gz"}
{"commit":"5ece2d8b9eb6","dirty":false,"env":{"APS5_TRACE_SECONDS":"40:20"},"gpu":"NVIDIA GeForce RTX 4070 SUPER","driver":"NVIDIA 610.88","os":"Windows 10.0.26100","cpu":"AMD Ryzen 5 5600XT 6-Core Processor","cpu_threads":12,"memory_mib":32694,"title_id":"PPSA17419","title":"MONOPOLY®","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 40:20","first_present":342,"ms":20044.739},"presents":263,"frame_ms":{"p50":74.332,"p90":85.736,"p99":113.171,"max":135.386},"gpu_busy_ms_per_present":34.393,"worker_busy_pct":{"queue worker 0x0":97.985},"top_phases_ms_per_frame":{"Driver.Packet":73.159,"Driver.Packet.draw":55.129,"Driver.Draw":54.660,"Graphics.Draw":52.129,"Graphics.Draw.draw_and_resource_release":41.485,"Driver.Draw.draw_enqueued":24.486,"Driver.Draw.shader_compile_and_link":23.902,"Shader.DrawStage":18.404},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.241,"events_lost":742148,"totals_full":false},"draw committer":{"events_full_after_s":11.070,"events_lost":214193,"totals_full":false}},"trace":"aps5-trace-5ece2d8b9eb6-153412.json.gz"}
{"commit":"07c8408713eb","dirty":false,"env":{"APS5_TRACE_SECONDS":"40:20"},"gpu":"NVIDIA GeForce RTX 4070 SUPER","driver":"NVIDIA 610.88","os":"Windows 10.0.26100","cpu":"AMD Ryzen 5 5600XT 6-Core Processor","cpu_threads":12,"memory_mib":32694,"title_id":"PPSA17419","title":"MONOPOLY®","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 40:20","first_present":278,"ms":20047.622},"presents":212,"frame_ms":{"p50":90.863,"p90":118.005,"p99":157.076,"max":175.968},"gpu_busy_ms_per_present":35.785,"worker_busy_pct":{"queue worker 0x0":98.011},"top_phases_ms_per_frame":{"Driver.Packet":90.913,"Driver.Packet.draw":66.669,"Driver.Draw":66.082,"Graphics.Draw":63.028,"Graphics.Draw.draw_and_resource_release":50.391,"Driver.Draw.shader_compile_and_link":30.067,"Driver.Draw.draw_enqueued":28.412,"Shader.DrawStage":23.692},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.185,"events_lost":717859,"totals_full":false},"draw committer":{"events_full_after_s":10.860,"events_lost":199486,"totals_full":false}},"trace":"aps5-trace-07c8408713eb-141636.json.gz"}
{"commit":"5ece2d8b9eb6","dirty":false,"env":{"APS5_TRACE_SECONDS":"40:20"},"gpu":"NVIDIA GeForce RTX 4070 SUPER","driver":"NVIDIA 610.88","os":"Windows 10.0.26100","cpu":"AMD Ryzen 5 5600XT 6-Core Processor","cpu_threads":12,"memory_mib":32694,"title_id":"PPSA17419","title":"MONOPOLY®","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 40:20","first_present":420,"ms":20059.691},"presents":274,"frame_ms":{"p50":71.163,"p90":84.425,"p99":104.550,"max":108.190},"gpu_busy_ms_per_present":33.761,"worker_busy_pct":{"queue worker 0x0":97.975},"top_phases_ms_per_frame":{"Driver.Packet":70.280,"Driver.Packet.draw":52.874,"Driver.Draw":52.433,"Graphics.Draw":49.396,"Graphics.Draw.draw_and_resource_release":39.178,"Driver.Draw.draw_enqueued":24.257,"Driver.Draw.shader_compile_and_link":22.131,"Shader.DrawStage":17.096},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.192,"events_lost":755045,"totals_full":false},"draw committer":{"events_full_after_s":11.032,"events_lost":213273,"totals_full":false}},"trace":"aps5-trace-5ece2d8b9eb6-172592.json.gz"}
  • Supplemental, APS5_DRAW_PIPELINE=1: Windows 11, RTX 4070 SUPER (NVIDIA 610.88), Monopoly (PPSA17419) language-select screen, main at dd00a9c54e against the same build with this change in libkernel (measured before the rebase onto the current base, which changed libkernel only in Socket/src/Udp.cpp), four alternated pairs of 75 s runs, FPS from 30 s on:
main this change
FPS 9.94, 11.60, 8.77, 7.45 (mean 9.44) 13.88, 14.23, 13.21, 12.46 (mean 13.45)
median frame time 96.0, 81.3, 107.0, 111.2 ms 67.8, 67.8, 72.7, 79.3 ms
  • Three other titles on the same base with APS5_DRAW_PIPELINE=1, main against this change: a Unity title whose older PS5Util.prx waits through sceKernelSyncOnAddressWait shows 48.8, 52.8, 49.7 against 55.6, 50.1, 53.7 FPS on its title screen (within its run-to-run spread); two titles capped at 60 FPS stay at 60; the same kinds of log lines either way.

  • ctest -R guest_umtx_op: passes with this change. On main it fails at the size-0 timespec {0, 20000000}, which returns at once instead of after 20 ms. Size-0 timespecs with negative seconds or 1e9 nanoseconds fail with EINVAL for UMTX_OP_WAIT and UMTX_OP_WAIT_UINT.

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 (speeds up Monopoly, PPSA17419, Game bring-up)
  • GPUs tested: n/a (libkernel change; the FPS runs used an RTX 4070 SUPER, NVIDIA 610.88, Windows 11)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5205198853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16873). Originally posted by [JAB-dev](https://github.com/JAB-dev) on 2026-11-07T19:41:10Z. --- Unity's worker threads spin in Monopoly (PPSA17419): every timed wait they make through `PS5Util.prx` expires the moment it starts. Reading that timeout the way the PS5 kernel does takes the language-select screen from 10.8 to 13.4 FPS (+24%) on the same machine, and from 9.4 to 13.5 FPS (+42%) with `APS5_DRAW_PIPELINE=1`. ### What `_umtx_op` with size argument 0 reads its timeout as a relative `struct timespec`, and an invalid one fails with `EINVAL` like an explicit size. That is what the PS5 kernel does: in firmware 13.60 the `UMTX_OP_WAIT`, `WAIT_UINT` and `WAIT_UINT_PRIVATE` handlers compare the size argument with 16, copy a 16-byte `timespec` for any size up to 16 (0 included) and 24 bytes above it, and return `EINVAL` (22) for a negative `tv_sec` or a `tv_nsec` above 999999999 (unsigned compare, so negative too); firmware 5.50 has the same code. FreeBSD 11's `umtx_copyin_umtx_time` does the same. Since the change that added microsecond size-0 timeouts, main reads a 4-byte microsecond count there. `UmtxDeadline` serves the wait, `SEM_WAIT`, umutex and rwlock operations, so they all change the same way; condition-variable waits decode their timeout separately and do not change. Monopoly's `PS5Util.prx` export `zlqfTyrQSPk` (RVA `0x102a0`) is `jmp 0x10500`. It takes a pointer to a 32-bit microsecond count, converts the count to a `timespec` on its stack, checks it as one, and passes it to `_umtx_op` with size argument 0: ``` 10532: mov (%rdx),%eax ; the caller's microseconds 10540: imul $0x431bde83,%rax,%rcx ; shr $0x32,%rcx ; seconds = us / 1000000 1054b: imul $0xf4240,%ecx,%edx ; sub %edx,%eax ; imul $0x3e8,%eax,%eax ; nanoseconds 10559: mov %rax,-0x38(%rbp) ; mov %rcx,-0x40(%rbp) ; {tv_sec, tv_nsec} 10566: lea -0x40(%rbp),%rdx ; ... ; call 0x10700 10700: mov %rdx,%r8 ; mov %rsi,%rdx 1070b: cmpq $0x0,(%r8) ; js 0x1072c ; jne 0x1071a ; tv_sec < 0: ETIMEDOUT 10713: cmpq $0x0,0x8(%r8) ; jle 0x1072c ; tv_sec == 0 and tv_nsec <= 0: ETIMEDOUT 1071a: mov $0x2,%esi ; mov $0xffffffff,%r9d ; xor %ecx,%ecx ; jmp 0x10790 10794: call 0x10340 ; PLT slot of _umtx_op (04AjkP0jO9U) ``` On an earlier build, with a libkernel that logged every size-0 caller, the only one in a run of the language screen returned to `PS5Util.prx+0x10799` and passed `00000000 00000000 000f4240 00000000`, a `timespec` of 1 ms. Read as microseconds, every such wait has a 0 or near-0 count: about 1.6 million waits a second expired on entry, and five Unity threads used about 92% of a core each. On the current base, sampled stacks of those five threads on `main` return to `PS5Util.prx+0x10799`; with this change three threads use 52-77% of a core each and every other thread less than 7%. That change's Metal Gear Solid 4 (PPSA18194) listing shows the game passing a pointer to a 4-byte microsecond count to `zlqfTyrQSPk`, the same export whose Monopoly build converts that count to a `timespec` before it calls `_umtx_op`. The moves it quotes (`mov %rdx,%r8`, `mov %rsi,%rdx`, `mov $0x2,%esi`, `xor %ecx,%ecx`) also appear in Monopoly's helper at `0x10700`, which runs after the conversion. I can't check that title's `PS5Util.prx` build because I don't have it. It also named SCE `libc.prx`: the `libc.prx` Monopoly ships calls `_umtx_op` with size 0 only from its once-flag wait, with a null timeout (`xor %edx,%edx` before the wrapper that moves it into `r8`), so that call doesn't change. The older `PS5Util.prx` builds I checked import `sceKernelSyncOnAddressWait` and don't call `_umtx_op`. A caller that did pass a bare 4-byte count with size 0 would get the console's reading: 16 bytes read as a `timespec`. @leorossi2005, could you check whether Metal Gear Solid 4 still gets past its startup barrier with this change? ### 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. --> - Performance report captures, `APS5_TRACE_SECONDS=40:20` and no other switch, Monopoly (PPSA17419) language-select screen, `main` at `07c8408713` and this change at `5ece2d8b9e` (the same base), captured alternately (each trace lost slices once its buffer filled; the totals behind the summary lines are complete): | | `main` | this change | |---|---|---| | FPS | 11.05, 10.57 | 13.12, 13.66 | | frame p50 / p90 / p99 | 87.4 / 106.3 / 145.0, 90.9 / 118.0 / 157.1 ms | 74.3 / 85.7 / 113.2, 71.2 / 84.4 / 104.5 ms | | GPU busy per present | 39.6, 35.8 ms | 34.4, 33.8 ms | Traces, in capture order: - `main`: [aps5-trace-07c8408713eb-134008.json.gz](https://github.com/user-attachments/files/34527622/aps5-trace-07c8408713eb-134008.json.gz) - this change: [aps5-trace-5ece2d8b9eb6-153412.json.gz](https://github.com/user-attachments/files/34527625/aps5-trace-5ece2d8b9eb6-153412.json.gz) - `main`: [aps5-trace-07c8408713eb-141636.json.gz](https://github.com/user-attachments/files/34527626/aps5-trace-07c8408713eb-141636.json.gz) - this change: [aps5-trace-5ece2d8b9eb6-172592.json.gz](https://github.com/user-attachments/files/34527628/aps5-trace-5ece2d8b9eb6-172592.json.gz) Summary lines, in capture order: ```json {"commit":"07c8408713eb","dirty":false,"env":{"APS5_TRACE_SECONDS":"40:20"},"gpu":"NVIDIA GeForce RTX 4070 SUPER","driver":"NVIDIA 610.88","os":"Windows 10.0.26100","cpu":"AMD Ryzen 5 5600XT 6-Core Processor","cpu_threads":12,"memory_mib":32694,"title_id":"PPSA17419","title":"MONOPOLY®","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 40:20","first_present":235,"ms":20084.143},"presents":222,"frame_ms":{"p50":87.354,"p90":106.316,"p99":144.980,"max":150.004},"gpu_busy_ms_per_present":39.604,"worker_busy_pct":{"queue worker 0x0":98.091},"top_phases_ms_per_frame":{"Driver.Packet":87.083,"Driver.Packet.draw":64.580,"Driver.Draw":64.039,"Graphics.Draw":59.514,"Graphics.Draw.draw_and_resource_release":47.743,"Driver.Draw.draw_enqueued":28.639,"Driver.Draw.shader_compile_and_link":28.328,"Shader.DrawStage":22.382},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.388,"events_lost":735788,"totals_full":false},"draw committer":{"events_full_after_s":11.527,"events_lost":204283,"totals_full":false}},"trace":"aps5-trace-07c8408713eb-134008.json.gz"} {"commit":"5ece2d8b9eb6","dirty":false,"env":{"APS5_TRACE_SECONDS":"40:20"},"gpu":"NVIDIA GeForce RTX 4070 SUPER","driver":"NVIDIA 610.88","os":"Windows 10.0.26100","cpu":"AMD Ryzen 5 5600XT 6-Core Processor","cpu_threads":12,"memory_mib":32694,"title_id":"PPSA17419","title":"MONOPOLY®","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 40:20","first_present":342,"ms":20044.739},"presents":263,"frame_ms":{"p50":74.332,"p90":85.736,"p99":113.171,"max":135.386},"gpu_busy_ms_per_present":34.393,"worker_busy_pct":{"queue worker 0x0":97.985},"top_phases_ms_per_frame":{"Driver.Packet":73.159,"Driver.Packet.draw":55.129,"Driver.Draw":54.660,"Graphics.Draw":52.129,"Graphics.Draw.draw_and_resource_release":41.485,"Driver.Draw.draw_enqueued":24.486,"Driver.Draw.shader_compile_and_link":23.902,"Shader.DrawStage":18.404},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.241,"events_lost":742148,"totals_full":false},"draw committer":{"events_full_after_s":11.070,"events_lost":214193,"totals_full":false}},"trace":"aps5-trace-5ece2d8b9eb6-153412.json.gz"} {"commit":"07c8408713eb","dirty":false,"env":{"APS5_TRACE_SECONDS":"40:20"},"gpu":"NVIDIA GeForce RTX 4070 SUPER","driver":"NVIDIA 610.88","os":"Windows 10.0.26100","cpu":"AMD Ryzen 5 5600XT 6-Core Processor","cpu_threads":12,"memory_mib":32694,"title_id":"PPSA17419","title":"MONOPOLY®","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 40:20","first_present":278,"ms":20047.622},"presents":212,"frame_ms":{"p50":90.863,"p90":118.005,"p99":157.076,"max":175.968},"gpu_busy_ms_per_present":35.785,"worker_busy_pct":{"queue worker 0x0":98.011},"top_phases_ms_per_frame":{"Driver.Packet":90.913,"Driver.Packet.draw":66.669,"Driver.Draw":66.082,"Graphics.Draw":63.028,"Graphics.Draw.draw_and_resource_release":50.391,"Driver.Draw.shader_compile_and_link":30.067,"Driver.Draw.draw_enqueued":28.412,"Shader.DrawStage":23.692},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.185,"events_lost":717859,"totals_full":false},"draw committer":{"events_full_after_s":10.860,"events_lost":199486,"totals_full":false}},"trace":"aps5-trace-07c8408713eb-141636.json.gz"} {"commit":"5ece2d8b9eb6","dirty":false,"env":{"APS5_TRACE_SECONDS":"40:20"},"gpu":"NVIDIA GeForce RTX 4070 SUPER","driver":"NVIDIA 610.88","os":"Windows 10.0.26100","cpu":"AMD Ryzen 5 5600XT 6-Core Processor","cpu_threads":12,"memory_mib":32694,"title_id":"PPSA17419","title":"MONOPOLY®","content_version":"01.005.000","resolution":"3840x2160","window":{"spec":"seconds 40:20","first_present":420,"ms":20059.691},"presents":274,"frame_ms":{"p50":71.163,"p90":84.425,"p99":104.550,"max":108.190},"gpu_busy_ms_per_present":33.761,"worker_busy_pct":{"queue worker 0x0":97.975},"top_phases_ms_per_frame":{"Driver.Packet":70.280,"Driver.Packet.draw":52.874,"Driver.Draw":52.433,"Graphics.Draw":49.396,"Graphics.Draw.draw_and_resource_release":39.178,"Driver.Draw.draw_enqueued":24.257,"Driver.Draw.shader_compile_and_link":22.131,"Shader.DrawStage":17.096},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.192,"events_lost":755045,"totals_full":false},"draw committer":{"events_full_after_s":11.032,"events_lost":213273,"totals_full":false}},"trace":"aps5-trace-5ece2d8b9eb6-172592.json.gz"} ``` - Supplemental, `APS5_DRAW_PIPELINE=1`: Windows 11, RTX 4070 SUPER (NVIDIA 610.88), Monopoly (PPSA17419) language-select screen, `main` at `dd00a9c54e` against the same build with this change in libkernel (measured before the rebase onto the current base, which changed libkernel only in `Socket/src/Udp.cpp`), four alternated pairs of 75 s runs, FPS from 30 s on: | | `main` | this change | |---|---|---| | FPS | 9.94, 11.60, 8.77, 7.45 (mean 9.44) | 13.88, 14.23, 13.21, 12.46 (mean 13.45) | | median frame time | 96.0, 81.3, 107.0, 111.2 ms | 67.8, 67.8, 72.7, 79.3 ms | - Three other titles on the same base with `APS5_DRAW_PIPELINE=1`, `main` against this change: a Unity title whose older `PS5Util.prx` waits through `sceKernelSyncOnAddressWait` shows 48.8, 52.8, 49.7 against 55.6, 50.1, 53.7 FPS on its title screen (within its run-to-run spread); two titles capped at 60 FPS stay at 60; the same kinds of log lines either way. - `ctest -R guest_umtx_op`: passes with this change. On `main` it fails at the size-0 `timespec {0, 20000000}`, which returns at once instead of after 20 ms. Size-0 `timespec`s with negative seconds or 1e9 nanoseconds fail with `EINVAL` for `UMTX_OP_WAIT` and `UMTX_OP_WAIT_UINT`. ### 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 - [x] Fixes: none - [x] Unblocks: none (speeds up Monopoly, PPSA17419, [Game bring-up](https://github.com/boykopovar/AnyPS5/discussions/11954)) - [x] GPUs tested: n/a (libkernel change; the FPS runs used an RTX 4070 SUPER, NVIDIA 610.88, Windows 11) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabichuuuuu commented 2026-11-07 23:12:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T23:12:52Z.

Review: COMMENTED


Read 5ece2d8b9e against main.

Semantics. FreeBSD 11.4's umtx_copyin_umtx_time (sys/kern/kern_umtx.c:3329-3346) copies a timespec for any size up to sizeof(struct timespec), 0 included, sets CLOCK_REALTIME with no flags, and fails with EINVAL for a negative tv_sec or a tv_nsec outside [0, 1e9). The wait, umutex, rwlock and semaphore handlers all go through it, while CV_WAIT uses umtx_copyin_timeout (:3511-3527), which matches leaving ConditionWait alone. With the size-0 branch gone, UmtxDeadline (SyncOnAddress.cpp:304-317) does exactly this.

Generality. This removes a reading taken from one title's call site rather than adding one; the test is the only other in-tree caller of _umtx_op_nid_postfix.

Test. On main the size-0 {0, 20000000} is read as 0 µs and returns ETIMEDOUT at once, so the 15 ms check fails; here it waits. The new size-0 EINVAL cases follow the same copy-in.

Whether Metal Gear Solid 4 still gets past its barrier stays open, as the description says.

Not run here; this is from reading the code.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5815504574 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16873#pullrequestreview-5815504574). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T23:12:52Z. **Review:** COMMENTED --- Read `5ece2d8b9e` against `main`. **Semantics.** FreeBSD 11.4's `umtx_copyin_umtx_time` (sys/kern/kern_umtx.c:3329-3346) copies a `timespec` for any size up to `sizeof(struct timespec)`, 0 included, sets `CLOCK_REALTIME` with no flags, and fails with `EINVAL` for a negative `tv_sec` or a `tv_nsec` outside [0, 1e9). The wait, umutex, rwlock and semaphore handlers all go through it, while `CV_WAIT` uses `umtx_copyin_timeout` (:3511-3527), which matches leaving `ConditionWait` alone. With the size-0 branch gone, `UmtxDeadline` (`SyncOnAddress.cpp:304-317`) does exactly this. **Generality.** This removes a reading taken from one title's call site rather than adding one; the test is the only other in-tree caller of `_umtx_op_nid_postfix`. **Test.** On `main` the size-0 `{0, 20000000}` is read as 0 µs and returns `ETIMEDOUT` at once, so the 15 ms check fails; here it waits. The new size-0 `EINVAL` cases follow the same copy-in. Whether Metal Gear Solid 4 still gets past its barrier stays open, as the description says. Not run here; this is from reading the code. AI-assisted: yes.
MarcZX10 commented 2026-11-22 12:24:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T12:24:40Z.

Review: APPROVED


Reviewed — looks good

The reviewed change at head 5ece2d8b9eb61e9ca08c9e1abeda1771a8a83332 reads size-zero _umtx_op timeouts as KernelTimespec, with tests for a timed wait and invalid values; the source and tests support the stated behavior.

What I ran

No commands were run. I inspected the prepared diff and manifest, then read both changed files at the pinned head: core/libs/prx/libkernel/SyncOnAddress/src/SyncOnAddress.cpp and core/libs/tests/GuestUmtxOp.cpp.

Results

Check Result Note
Diff and changed source passed Size zero follows the timespec path
Changed tests passed Added timed and invalid timeout assertions
Test execution not run No commands were available

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests or builds were run. Performance measurements, console behavior, and the Metal Gear Solid 4 startup behavior were not independently verified. No files were excluded from review; both manifest files were included and read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012196994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16873#pullrequestreview-6012196994). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T12:24:40Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change at head `5ece2d8b9eb61e9ca08c9e1abeda1771a8a83332` reads size-zero `_umtx_op` timeouts as `KernelTimespec`, with tests for a timed wait and invalid values; the source and tests support the stated behavior. ## What I ran No commands were run. I inspected the prepared diff and manifest, then read both changed files at the pinned head: `core/libs/prx/libkernel/SyncOnAddress/src/SyncOnAddress.cpp` and `core/libs/tests/GuestUmtxOp.cpp`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed source | passed | Size zero follows the timespec path | | Changed tests | passed | Added timed and invalid timeout assertions | | Test execution | not run | No commands were available | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests or builds were run. Performance measurements, console behavior, and the Metal Gear Solid 4 startup behavior were not independently verified. No files were excluded from review; both manifest files were included and read. ## To get this to a good state Nothing is required.
Plyxen commented 2026-12-03 10:35:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T10:35:54Z.

Review: APPROVED


I read the diff at 5ece2d8b9e. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged into main at b97867d3ce6 together with other open PRs (so not an isolated build).

  • guest_umtx_op: pass on both.
  • Control (same tree and tests, the changed files of those PRs put back to main's): aborts on both.

Not checked: a title.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6168065767 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16873#pullrequestreview-6168065767). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T10:35:54Z. **Review:** APPROVED --- I read the diff at `5ece2d8b9e`. Windows 11 with GCC 15.2 and Linux (Ubuntu 24.04 in WSL2, GCC 13.3), merged into `main` at `b97867d3ce6` together with other open PRs (so not an isolated build). - `guest_umtx_op`: pass on both. - Control (same tree and tests, the changed files of those PRs put back to `main`'s): aborts on both. Not checked: a title. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 13:09:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:09:11Z.

Review: COMMENTED


Built the changed sources and ran GuestUmtxOp on Linux against the existing runtime. The fixture passed, including the size-zero relative timespec cases.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170422492 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16873#pullrequestreview-6170422492). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:09:11Z. **Review:** COMMENTED --- Built the changed sources and ran `GuestUmtxOp` on Linux against the existing runtime. The fixture passed, including the size-zero relative timespec cases. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/16873:upstream-pr/16873'
git switch 'upstream-pr/16873'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/16873'
git switch 'upstream-pr/16873'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/16873'
git switch 'upstream-pr/16873'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/16873'
git switch 'main'
git merge --squash 'upstream-pr/16873'
git switch 'main'
git merge --ff-only 'upstream-pr/16873'
git switch 'main'
git merge 'upstream-pr/16873'
git push origin 'main'
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!16873
No description provided.