fix(libkernel): give an inheriting thread its creator's priority #5230

Merged
hugodearaujo merged 1 commit from upstream-pr/5230 into main 2026-10-14 19:07:30 +00:00
hugodearaujo commented 2026-10-13 15:17:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-13T15:17:01Z.


What

A thread created with inherited scheduling took the priority stored in its attribute. On the console it runs at its creator's priority. I created threads from a homebrew payload on a PS5 (firmware 13.60), with the creator set to 450 and then to 600 through scePthreadSetprio, and read the child's priority with scePthreadGetschedparam:

Attribute of the new thread Console main
PTHREAD_INHERIT_SCHED, priority 300 set creator's (450, 600) 300
PTHREAD_INHERIT_SCHED, no priority set creator's 700
null attribute (scePthreadCreate, pthread_create) creator's 700
default attribute (pthread_create) creator's 700
PTHREAD_EXPLICIT_SCHED, priority 300 set 300 300
PTHREAD_EXPLICIT_SCHED, no priority set 700 700

The policy already followed this rule (#4086); the priority now does too. The TechnicalDebt sentence that recorded the difference is updated.

Titles, from a run on Linux with logging added to scePthreadCreate:

  • Hollow Knight: Silksong (PPSA12544): FMOD creates its threads with inherited scheduling and priority 256–265 in the attribute. "FMOD nonblocking thread (0)" is created from a thread at 700 with 265 in its attribute, so on the console it runs at 700 and here at 265; the "FMOD file thread" it creates then inherits 265 instead of 700. Silksong reads thread priorities with scePthreadGetschedparam.
  • ASTRO BOT (PPSA21567): five threads (sndz_stream_task_service, tbb_thead) are created with inherited scheduling from creators at 699 and 680 and got 700.

Tested

  • PS5 firmware 13.60: the table above.
  • Linux: full CTest 1052/1053. guest_pthread_schedparam now also creates threads from a guest thread at 450 and 600 with each attribute in the table; it aborts on main. agc_driver_tessellation segfaults the same way on current main.
  • Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1077 tests with no failures (the GPU tests skip in this VM); guest_pthread_schedparam passes.
  • Silksong and ASTRO BOT run as before.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4845419556 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5230). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-13T15:17:01Z. --- ### What A thread created with inherited scheduling took the priority stored in its attribute. On the console it runs at its creator's priority. I created threads from a homebrew payload on a PS5 (firmware 13.60), with the creator set to 450 and then to 600 through `scePthreadSetprio`, and read the child's priority with `scePthreadGetschedparam`: | Attribute of the new thread | Console | `main` | |---|---|---| | `PTHREAD_INHERIT_SCHED`, priority 300 set | **creator's (450, 600)** | 300 | | `PTHREAD_INHERIT_SCHED`, no priority set | **creator's** | 700 | | null attribute (`scePthreadCreate`, `pthread_create`) | **creator's** | 700 | | default attribute (`pthread_create`) | **creator's** | 700 | | `PTHREAD_EXPLICIT_SCHED`, priority 300 set | 300 | 300 | | `PTHREAD_EXPLICIT_SCHED`, no priority set | 700 | 700 | The policy already followed this rule (#4086); the priority now does too. The TechnicalDebt sentence that recorded the difference is updated. Titles, from a run on Linux with logging added to `scePthreadCreate`: - Hollow Knight: Silksong (PPSA12544): FMOD creates its threads with inherited scheduling and priority 256–265 in the attribute. "FMOD nonblocking thread (0)" is created from a thread at 700 with 265 in its attribute, so on the console it runs at 700 and here at 265; the "FMOD file thread" it creates then inherits 265 instead of 700. Silksong reads thread priorities with `scePthreadGetschedparam`. - ASTRO BOT (PPSA21567): five threads (`sndz_stream_task_service`, `tbb_thead`) are created with inherited scheduling from creators at 699 and 680 and got 700. ### Tested - PS5 firmware 13.60: the table above. - Linux: full CTest 1052/1053. `guest_pthread_schedparam` now also creates threads from a guest thread at 450 and 600 with each attribute in the table; it aborts on `main`. `agc_driver_tessellation` segfaults the same way on current `main`. - Windows Server 2025 VM, WinLibs GCC 15.2, CI configure flags: CTest 1077 tests with no failures (the GPU tests skip in this VM); `guest_pthread_schedparam` passes. - Silksong and ASTRO BOT run as before. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-14 18:08:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:08:57Z.


Checked the new priority rule in PthreadPrivate (inherit → creator's priority, explicit or no creator → attribute's), the removed duplicate store in scePthreadCreate, and the TechnicalDebt update. guest_pthread_schedparam aborts without the change and passes with it; scoped build and ctest are green. Merging once the full build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175058666 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5230#issuecomment-6175058666). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T18:08:57Z. --- Checked the new priority rule in `PthreadPrivate` (inherit → creator's priority, explicit or no creator → attribute's), the removed duplicate store in `scePthreadCreate`, and the TechnicalDebt update. `guest_pthread_schedparam` aborts without the change and passes with it; scoped build and ctest are green. Merging once the full build is green.
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!5230
No description provided.