Skip to content

fix(libScePosixForWebKit): implement SCHED_OTHER wrapper - #23347

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Thimo188:fix/posix-pthread-setschedparam-np
Nov 25, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Thimo188:fix/posix-pthread-setschedparam-np

Conversation

@Thimo188

@Thimo188 Thimo188 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Implement pthread_setschedparam_np's SCHED_OTHER path from firmware 13.42 evidence. The wrapper reads the requested priority first and uses libkernel's measured priority setter for the firmware import identified as pthread_setschedother_np(thread, priority), preserving pointer, thread and priority error precedence. Add focused success and error-path coverage and update the pending technical-debt fragment for the unmodelled host timesharing class.

Tested

Linux x86-64 (Ubuntu 24.04, GCC 13.3, Release) in anyps5-dev:24.04: full BUILD_TESTING=ON configure; built guest_posix_wrap_tests; ctest -R ^guest_posix_wrap$ --output-on-failure passed 1/1. tools/debt_fold.py --check, tools/guest_pointer_audit.py libScePosixForWebKit (six existing findings, none in this function), test_public_headers.py --audit-only (413 libraries, 34,732 exports), tools/check_conventions.py --base origin/main, and both required overlap scans passed.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

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

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 50b1c7157b:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_posix_wrap_tests built cleanly.
  • CTest (guest_posix_wrap):
    1/1 Test #4927: guest_posix_wrap .................   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libScePosixForWebKit/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4927: guest_posix_wrap .................Subprocess aborted***Exception:   0.34 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified guest pointer validation in pthread_setschedparam_np: GuestCopyIn_nid_no_patch(&requested, param, sizeof(requested)) correctly catches null or invalid guest addresses (e.g. 0x10) and returns PosixEfault (14).
    • Verified error code precedence and return values: when policy == 2 (SCHED_OTHER), GuestCopyIn_nid_no_patch failure returns PosixEfault without dereferencing, while invalid thread handles or priorities are validated by pthread_setprio_nid_postfix returning Einval.
    • Verified non-SCHED_OTHER pass-through: policy != 2 forwards directly to pthread_setschedparam_nid_postfix(thread, policy, param), matching firmware 13.42 behavior.
    • Verified test coverage in core/libs/tests/GuestPosixWrap.cpp: exercises successful SCHED_OTHER priority update, restoration of original priority, invalid priority rejection (Einval), null/invalid param pointers (Efault), and non-SCHED_OTHER passthrough without polluting error state.
    • Verified AGENTS.md conventions: no illegal comments added, technical debt fragment added under docs/dev/debt/changes/, and commit/PR conventions satisfied.

Looks Good To Me

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Progress report (96dddbe → d8a9c14)

📈 System libraries: 45.24% (+0.01%, +1 implemented function)

✅ 1 implemented
Library Name
libScePosixForWebKit pthread_setschedparam_np

Changed libraries (implemented exports)

Library Before After Change
libScePosixForWebKit 38/40 (95.00%) 39/40 (97.50%) +2.50%

@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

The changed wrapper, focused tests, and debt entry are consistent with the stated SCHED_OTHER behavior; the author reports passing checks that I did not run.

What I ran

Reviewed head 50b1c7157b139994821fa473ae0b0f9d9d64046a. I read the description, commits, diff, manifest, all three changed files, and targeted scheduler implementation and test context. No commands or tests were run.

Results

Check Result Note
Source review passed All changed files read
Reported checks not run Reported by the author
Negative control not run No test mutation or control run

Negative control

A negative control could not be run in this review.

Findings

Blocking

None.

Non-blocking

None.

Sources

The relevant implementation and test context were read at the pinned head. No external sources used.

Not verified

I did not run the reported build, test, audit, convention, or overlap checks. I did not verify behavior on a physical console or firmware 13.42.

To get this to a good state

Nothing is required.

@maskym

maskym commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Windows result for head 50b1c7157b, merged alone into main 9a50e1014e (the PR's Tested section names no Windows run).

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. main itself fails to compile one test on Windows at this commit (UploadCacheReadOnlyFlush.cpp:177, setenv; #19899 fixes it), so the tree was built with ninja -k 0. This PR adds no other build failure.

guest_posix_wrap, the test this PR adds or extends, passes 3 of 3 runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@Romannachwievor

Copy link
Copy Markdown
Contributor

Tested on an Apple M1 (macOS 26.5, Apple clang 21.0.0), x86_64 Release under Rosetta 2. The tree was main 245210b07e with #17425 and #11049, which the macOS build needs. I applied this PR's diff (head 50b1c7157b) on top and rebuilt guest_posix_wrap_tests and libScePosixForWebKit.

guest_posix_wrap
without this PR (old test file) pass, 3 of 3 runs
with this PR (updated test file) pass, 3 of 3 runs

I only ran this test, and I did not run a title that sets SCHED_OTHER through pthread_setschedparam_np.

AI-assisted: yes (Claude Code)

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 50b1c7157b, applied with git apply on main fd4aeed483 together with the other 25 PRs of one batch (#24107, #24132, #24238, #15143, #22088, #22685, #23739, #24032, #16054, #20001, #20344, #24170, #24396, #16856, #17298, #20497, #24426, #24554, #24598, #21376, #21556, #22047, #22082, #14124, #18476). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
guest_posix_wrap (1 test, matched by name to the test file this PR changes) all pass outside the iGPU subset

Whole batch: the full ctest -j 12 (6524 tests) on the RTX 3080 has 8 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Traced to other PRs of the batch, each by reverting it and testing again: #21556 (guest_json_allocator), #16856 (guest_kernel_sys_module_internal), #15143 (guest_math_exact); none is in this PR's area. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): public_headers. The 2127 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

@Thimo188
Thimo188 force-pushed the fix/posix-pthread-setschedparam-np branch 3 times, most recently from 6818aa6 to 498c7db Compare November 21, 2026 20:06

@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 — looks good

The reviewed change at d8a9c14864a4408ff96e70fcf7e79b3013686572 has no verified blocking defects; the PR-reported checks were not run by me.

What I ran

Read the prepared description, commits, manifest, diff, and all three changed files listed in the manifest at the pinned head. Inspected the priority setter and scheduling code touched by the wrapper. No build or tests were run.

Results

Check Result Note
Changed files reviewed passed All three manifest files read
Build and tests not run PR description reports successful checks
Priority setter behavior passed Range, thread, and error handling inspected

Findings

Blocking

None.

Non-blocking

None.

Sources

The wrapper copies the requested parameter before calling the priority setter; that setter validates the thread and accepted priority ranges. The added tests cover success, invalid priority, null and unreadable parameter, and forwarding for other policies.

Not verified

No independent build, tests, or console behavior were verified. The review-folder files.json inventory was unavailable; the prepared manifest listed three changed files, and all three were read. The PR-reported checks were not independently confirmed.

To get this to a good state

Nothing is required.

@maskym

maskym commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Retested head d8a9c14864 on Windows (the head moved since my earlier run), merged alone into main 2b09db6f11.

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. Build clean.

guest_posix_wrap, the test this PR adds or extends, passes 3 of 3 runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants