Skip to content

fix(libkernel): report current thread scheduling policy in attributes - #8583

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
Ondra97:codex/fix-pthread-attr-policy
Oct 20, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
Ondra97:codex/fix-pthread-attr-policy

Conversation

@Ondra97

@Ondra97 Ondra97 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What

scePthreadAttrGet always writes FIFO, even when scePthreadGetschedparam reports RR for the same live thread. pthread_attr_get_np leaves the destination's previous policy untouched. Both attribute queries now read the thread's existing atomic scheduling-policy metadata.

The scheduling regression checks both APIs with destinations preseeded to FIFO and RR, queries from the thread itself and from another thread, explicit and inherited creation policies, subsequent policy changes, rejected setters, and the existing SCE ESRCH result after join. The guest constants have a GUEST_ prefix because <future> brings in host scheduling macros.

The policy-copy behavior follows FreeBSD 11.4 libthr's attribute query, whose copy range includes the policy; setschedparam updates that attribute. The console result of these attribute queries has not been measured, and that limit is recorded in the library's technical debt. Host scheduling is still unaffected. This addresses CORE 01 in #8005; no title compatibility claim is made.

Tested

Windows 11 Pro 10.0.26300; AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER. WinLibs GCC 15.2.0 UCRT r7; Release with BUILD_TESTING=ON.

Base: 1b08a33b121e23a4f9e84999c233e094b5055893. Fix: ad1650686c0686bd6971eda5a7e40c74cc319279.

Metric Before (base) After (fix)
Wrong policy results in the same 8-case probe 4/8 0/8
Extended guest_pthread_schedparam regression Fails Passes

The probe uses a live guest thread, FIFO/RR settings, both attribute-query APIs and both destination policies. The committed regression also covers creation, inheritance, changes to another gated thread, and SCE ended-thread behavior. The unchanged guest_pthread_attr and guest_pthread_attr_errors tests pass before and after.

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DPython3_EXECUTABLE=C:/Python314/python.exe -DFFMPEG_PREBUILT_DIR=D:/Github/AnyPS5/build-runtime/externals/ffmpeg-9ac4cfd195f1
cmake --build build --parallel 6
ctest --test-dir build -R '^(patched_libraries|guest_thread_self|guest_pthread_(attr|attr_errors|attr_stack|schedparam|start))$' --output-on-failure
python tools/check_conventions.py --base origin/main
python tools/pr_overlap.py --branch codex/fix-pthread-attr-policy

The overlap checker reports no confirmed conflicts. I manually reviewed its incomplete shared-file comparisons: #6893 changes guard-size fields, #6044 moves the unchanged scheduling test, and the debt changes concern other entries. #8041's guard-size change also leaves the policy untouched. None supplies this fix or is a prerequisite.

No console modules or game payloads are needed by the regression. No game run was performed.

Full all-target Windows Release build passed. The final seven runtime tests passed, including loading 354 patched libraries with zero failures. The full build used a temporary alignment adjustment confined to an unrelated existing test; it was restored afterward and is absent from the submitted diff.

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

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

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 4630 docs/dev/debt/libkernel.md
PR 5021 docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestPthreadSchedparam.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6519 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6977 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7530 docs/dev/debt/libkernel.md
PR 7653 docs/dev/debt/libkernel.md
PR 8255 docs/dev/debt/libkernel.md
PR 8539 docs/dev/debt/libkernel.md

@oneandonlydean
oneandonlydean merged commit 352dbe7 into boykopovar:main Oct 20, 2026
11 checks passed
@Ondra97
Ondra97 deleted the codex/fix-pthread-attr-policy branch October 22, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants