test(libc): run cpu_topology on Windows #9584

Open
DavidSamir wants to merge 3 commits from upstream-pr/9584 into main
DavidSamir commented 2026-10-22 03:15:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T03:15:58Z.


What

cpu_topology was registered only on Linux (libc/CMakeLists.txt:912). CpuTopology::Get and Pin also have Windows paths, which no test ran: GetProcessAffinityMask, LayoutFromClasses over GetLogicalProcessorInformationEx efficiency classes, and SetThreadAffinityMask.

How:

  • libc/CMakeLists.txt: the guard becomes Linux OR WIN32. macOS stays excluded because Get/Pin have no macOS path. The libc link, configure_windows_unwind and the PATH prepend apply on WIN32 only, so the Linux build is unchanged.
  • CpuTopology.cpp: the sysfs MaskFromCpuList checks move under #ifdef __linux__, since that function is Linux-only. On Windows the pinned mask is read back with SetThreadAffinityMask, which returns the mask it replaces. Pinning by thread handle is also checked, because the Windows Pin honours handles. The Linux checks are unchanged.

Tested

  • Windows 11 Pro 26200, WinLibs GCC 15.2.0, Release. CPU-side only, no GPU involved. ctest -R ^cpu_topology$ passes.
  • Negative control: with GetProcessAffinityMask in Get() disabled, the test fails with "process affinity read". Restored, it passes.
  • tools/check_conventions.py passes.

Overlap (tools/pr_overlap.py --branch plus git merge-tree):

  • #6044 moves this test to tests/process/CpuTopology.cpp. git merge-tree follows the rename and reports no conflict there, and the libc CMakeLists conflict-hunk count against #6044 is unchanged (17).
  • #7715 already conflicts with main in libc/CMakeLists.txt; its hunk count is unchanged.

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:4961548725 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-22T03:15:58Z. --- ### What `cpu_topology` was registered only on Linux (libc/CMakeLists.txt:912). `CpuTopology::Get` and `Pin` also have Windows paths, which no test ran: `GetProcessAffinityMask`, `LayoutFromClasses` over `GetLogicalProcessorInformationEx` efficiency classes, and `SetThreadAffinityMask`. How: - `libc/CMakeLists.txt`: the guard becomes `Linux OR WIN32`. macOS stays excluded because `Get`/`Pin` have no macOS path. The libc link, `configure_windows_unwind` and the `PATH` prepend apply on WIN32 only, so the Linux build is unchanged. - `CpuTopology.cpp`: the sysfs `MaskFromCpuList` checks move under `#ifdef __linux__`, since that function is Linux-only. On Windows the pinned mask is read back with `SetThreadAffinityMask`, which returns the mask it replaces. Pinning by thread handle is also checked, because the Windows `Pin` honours handles. The Linux checks are unchanged. ### Tested - Windows 11 Pro 26200, WinLibs GCC 15.2.0, Release. CPU-side only, no GPU involved. `ctest -R ^cpu_topology$` passes. - Negative control: with `GetProcessAffinityMask` in `Get()` disabled, the test fails with "process affinity read". Restored, it passes. - `tools/check_conventions.py` passes. Overlap (`tools/pr_overlap.py --branch` plus `git merge-tree`): - #6044 moves this test to `tests/process/CpuTopology.cpp`. `git merge-tree` follows the rename and reports no conflict there, and the libc CMakeLists conflict-hunk count against #6044 is unchanged (17). - #7715 already conflicts with main in libc/CMakeLists.txt; its hunk count is unchanged. ### 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 - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-22 03:45:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T03:45:23Z.

Review: CHANGES_REQUESTED


The Windows assertions exercise process-mask filtering, current-thread pinning and the thread-handle path; the implementation changes shown in the PR leave the Linux assertions under their original platform guard. The latest conventions check passes, superseding the earlier template-check failure. Hosted relinker, register-context and write-watch checks pass; product build jobs are skipped. The Windows test result is author-reported; I did not run it locally.

The unresolved manual overlap with #6044 is specifically the moved CpuTopology.cpp, not just the shared CMake insertion. #6044 renames the Linux test to core/libs/tests/process/CpuTopology.cpp without changing its contents; this PR adds the Windows branch to the original path. Please coordinate with #6044's author so the Windows additions follow the file to its renamed path if #6044 lands first, and record the agreed order/dependency if one must land first. The PR's statement that merge-tree followed the rename should be reconciled with the overlap bot's explicit inability to compare the test path.

Please also update the test path/registration if the reorganization lands first; keeping the new Windows-only coverage on the unregistered old filename would drop it from CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609015277 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584#pullrequestreview-5609015277). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T03:45:23Z. **Review:** CHANGES_REQUESTED --- The Windows assertions exercise process-mask filtering, current-thread pinning and the thread-handle path; the implementation changes shown in the PR leave the Linux assertions under their original platform guard. The latest conventions check passes, superseding the earlier template-check failure. Hosted relinker, register-context and write-watch checks pass; product build jobs are skipped. The Windows test result is author-reported; I did not run it locally. The unresolved manual overlap with #6044 is specifically the moved `CpuTopology.cpp`, not just the shared CMake insertion. #6044 renames the Linux test to `core/libs/tests/process/CpuTopology.cpp` without changing its contents; this PR adds the Windows branch to the original path. Please coordinate with #6044's author so the Windows additions follow the file to its renamed path if #6044 lands first, and record the agreed order/dependency if one must land first. The PR's statement that merge-tree followed the rename should be reconciled with the overlap bot's explicit inability to compare the test path. Please also update the test path/registration if the reorganization lands first; keeping the new Windows-only coverage on the unregistered old filename would drop it from CI.
fogydes commented 2026-10-22 08:13:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T08:13:10Z.


The Conventions check fails on the head of this PR (job 119621777041: Fill in the pull request template: section 'What' is missing or empty, and the same for Tested and Checklist).

Everything else in the matrix is green (relinker on all three OSes, relinker-asan, register-context, write-watch), and python3 tools/check_conventions.py --base origin/main prints the same three template findings locally. Filling in every line of .github/pull_request_template.md (What, Tested, Depends on, Unblocks, GPUs tested, AI-assisted, and tick the boxes) is all that appears to block CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336038225 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584#issuecomment-6336038225). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-22T08:13:10Z. --- The Conventions check fails on the head of this PR ([job 119621777041](https://github.com/boykopovar/AnyPS5/actions/runs/39717118005/job/119621777041): `Fill in the pull request template: section 'What' is missing or empty`, and the same for `Tested` and `Checklist`). Everything else in the matrix is green (relinker on all three OSes, relinker-asan, register-context, write-watch), and `python3 tools/check_conventions.py --base origin/main` prints the same three template findings locally. Filling in every line of `.github/pull_request_template.md` (What, Tested, Depends on, Unblocks, GPUs tested, AI-assisted, and tick the boxes) is all that appears to block CI.
DavidSamir commented 2026-10-22 09:20:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T09:20:37Z.


@fogydes thanks. That was the first head; the template was filled in and the Conventions job on the current head passes. For #6044 I've proposed the order on that PR (the Windows additions follow CpuTopology.cpp to tests/process/ if #6044 lands first) and am waiting for its author.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337294969 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584#issuecomment-6337294969). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-22T09:20:37Z. --- @fogydes thanks. That was the first head; the template was filled in and the Conventions job on the current head passes. For #6044 I've proposed the order on that PR (the Windows additions follow `CpuTopology.cpp` to `tests/process/` if #6044 lands first) and am waiting for its author. AI-assisted: yes
MarcZX10 commented 2026-10-22 10:22:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T10:22:24Z.

Review: CHANGES_REQUESTED


The test changes keep Linux behavior under the Linux guards and add Windows checks for process affinity, class layout, current-thread pinning and handle-based pinning. I also compiled the exact core/libs/tests/CpuTopology.cpp with GCC 12.2 (-std=c++20 -Wall -Wextra -Werror) and ran it standalone on Linux; it passed. This checks the shared/Linux path, not the new Windows-only assertions. The Windows 11 run and negative control in the PR description remain author-reported. One repository gate remains: 1. #6044 coordination: thank you for proposing on #6044 that the Windows cases follow CpuTopology.cpp to tests/process/ if its rename lands first. I do not see an agreement from that PR's author yet. Please wait for agreement and record the agreed merge order in the checklist (Depends on if this PR must wait), then carry the Windows cases and registration to the renamed path as needed. The overlap workflow cannot compare the shared files while #6044 conflicts with main. This head is 107 commits behind current upstream/main; please update it after the #6044 order is settled and rerun the checks. Checks on exact head 46c665015223ad582a26e90768b2c0f9dfd7b0e0: - git diff --check upstream/main...HEAD: passed. - python tools/check_conventions.py --base upstream/main --head HEAD: passed. - Standalone Linux test-source compile/run: passed (GCC 12.2; this does not test the Windows branch). - Hosted eligibility, conventions, labels, report, relinker matrix, ASan, register-context and write-watch checks pass; Linux/Windows product jobs are skipped. I am requesting changes for unresolved overlap agreement and base freshness only, not a queue-based intake hold or a defect in the added test logic. It is fine to keep submitting PRs; maintainers will handle them in due course.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5612699682 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584#pullrequestreview-5612699682). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T10:22:24Z. **Review:** CHANGES_REQUESTED --- The test changes keep Linux behavior under the Linux guards and add Windows checks for process affinity, class layout, current-thread pinning and handle-based pinning. I also compiled the exact `core/libs/tests/CpuTopology.cpp` with GCC 12.2 (`-std=c++20 -Wall -Wextra -Werror`) and ran it standalone on Linux; it passed. This checks the shared/Linux path, not the new Windows-only assertions. The Windows 11 run and negative control in the PR description remain author-reported. One repository gate remains: 1. **#6044 coordination:** thank you for proposing on #6044 that the Windows cases follow `CpuTopology.cpp` to `tests/process/` if its rename lands first. I do not see an agreement from that PR's author yet. Please wait for agreement and record the agreed merge order in the checklist (`Depends on` if this PR must wait), then carry the Windows cases and registration to the renamed path as needed. The overlap workflow cannot compare the shared files while #6044 conflicts with `main`. This head is 107 commits behind current `upstream/main`; please update it after the #6044 order is settled and rerun the checks. Checks on exact head `46c665015223ad582a26e90768b2c0f9dfd7b0e0`: - `git diff --check upstream/main...HEAD`: passed. - `python tools/check_conventions.py --base upstream/main --head HEAD`: passed. - Standalone Linux test-source compile/run: passed (GCC 12.2; this does not test the Windows branch). - Hosted eligibility, conventions, labels, report, relinker matrix, ASan, register-context and write-watch checks pass; Linux/Windows product jobs are skipped. I am requesting changes for unresolved overlap agreement and base freshness only, not a queue-based intake hold or a defect in the added test logic. It is fine to keep submitting PRs; maintainers will handle them in due course. I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
JJenkx commented 2026-10-22 13:17:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T13:17:36Z.


Independent Windows run, as data only. Machine: Windows 11 Enterprise 10.0.22621, AMD Ryzen 9 5950X (16 cores, 32 logical processors), WinLibs GCC 15.2.0 UCRT r7, Release. Head 46c6650152 was merged with #9583 onto main 8b3a6ba88d. cpu_topology passes in 10 of 10 runs. (guest_fopen_errors from #9583 is a separate issue, reported there.)

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341726775 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584#issuecomment-6341726775). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T13:17:36Z. --- Independent Windows run, as data only. Machine: Windows 11 Enterprise 10.0.22621, AMD Ryzen 9 5950X (16 cores, 32 logical processors), WinLibs GCC 15.2.0 UCRT r7, Release. Head 46c6650152 was merged with #9583 onto `main` 8b3a6ba88d. `cpu_topology` passes in 10 of 10 runs. (`guest_fopen_errors` from #9583 is a separate issue, reported there.) AI-assisted (Claude Code).
THEMANnt commented 2026-10-25 04:16:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T04:16:18Z.

Review: APPROVED


Reviewed 46c665015223ad582a26e90768b2c0f9dfd7b0e0 against 6ef5a1c4c92272598b18adeb9b5414112f8d15ed. No actionable findings in this focused review.

Source review: Inspected the complete registration/test change and CpuTopology's header-only implementation. Linux list parsing stays Linux-only. Windows checks compare SetThreadAffinityMask's previous-mask return value after Pin, reject masks outside the process and verify handle-based pinning. The CMake branch adds the Windows runtime/unwind setup and PATH consistently with neighboring native tests.

Validation: Windows / MinGW GCC 15.2: built the exact head CpuTopology.cpp against its pinned headers and ran it successfully (exit 0). Its runtime changes are confined to that test child. Baseline Windows compilation fails at the former unconditional Linux affinity APIs, demonstrating the portability change. Conventions, whitespace and script registration passed. Current hosted relinker/ASan and metadata checks succeeded; product Windows/Linux jobs were skipped.

Scope: Actual header-only CPU topology test on this Windows host; the full libc-linked CMake target and Linux runtime were not rebuilt/run locally. No game or GPU test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641463125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584#pullrequestreview-5641463125). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-25T04:16:18Z. **Review:** APPROVED --- Reviewed `46c665015223ad582a26e90768b2c0f9dfd7b0e0` against `6ef5a1c4c92272598b18adeb9b5414112f8d15ed`. No actionable findings in this focused review. **Source review:** Inspected the complete registration/test change and CpuTopology's header-only implementation. Linux list parsing stays Linux-only. Windows checks compare SetThreadAffinityMask's previous-mask return value after Pin, reject masks outside the process and verify handle-based pinning. The CMake branch adds the Windows runtime/unwind setup and PATH consistently with neighboring native tests. **Validation:** Windows / MinGW GCC 15.2: built the exact head CpuTopology.cpp against its pinned headers and ran it successfully (exit 0). Its runtime changes are confined to that test child. Baseline Windows compilation fails at the former unconditional Linux affinity APIs, demonstrating the portability change. Conventions, whitespace and script registration passed. Current hosted relinker/ASan and metadata checks succeeded; product Windows/Linux jobs were skipped. **Scope:** Actual header-only CPU topology test on this Windows host; the full libc-linked CMake target and Linux runtime were not rebuilt/run locally. No game or GPU test.
MarcZX10 commented 2026-11-21 07:08:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:08:40Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the Windows test setup and affinity assertions are consistent with the implementation inspected.

What I ran

Reviewed head bdcb263095b74c4403680707ebe0a3245a89a426. Read review/description.md, review/commits.md, review/manifest.json, review/diff.patch, and both changed files in full, plus the relevant CpuTopology.hpp implementation. The repository reader was used for targeted reads. No build or test commands were run.

Results

Check Result Note
Diff and changed files passed Both reviewed files were fully read
Targeted implementation review passed Windows affinity paths inspected
Tests not run Reported runs are author supplied

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports Windows 11, WinLibs GCC 15.2.0 CTest and convention checks passed, including a negative control; these were not independently run. No programmatic checks were run during this review. review/files.json was not provided as a review document; the file listing confirms both manifest-listed changed files were included and read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003721604 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584#pullrequestreview-6003721604). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:08:40Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the Windows test setup and affinity assertions are consistent with the implementation inspected. ## What I ran Reviewed head `bdcb263095b74c4403680707ebe0a3245a89a426`. Read `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`, and both changed files in full, plus the relevant `CpuTopology.hpp` implementation. The repository reader was used for targeted reads. No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | Both reviewed files were fully read | | Targeted implementation review | passed | Windows affinity paths inspected | | Tests | not run | Reported runs are author supplied | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The author reports Windows 11, WinLibs GCC 15.2.0 CTest and convention checks passed, including a negative control; these were not independently run. No programmatic checks were run during this review. `review/files.json` was not provided as a review document; the file listing confirms both manifest-listed changed files were included and read. ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 11:53:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:53:46Z.

Review: COMMENTED


The exact CpuTopology fixture passed on Linux. I also compiled its Windows code path with MinGW and ran it under Wine, where the affinity and handle checks passed. The Windows check used a standalone executable, with the CMake linkage and native Windows left to CI.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6169225959 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9584#pullrequestreview-6169225959). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T11:53:46Z. **Review:** COMMENTED --- The exact `CpuTopology` fixture passed on Linux. I also compiled its Windows code path with MinGW and ran it under Wine, where the affinity and handle checks passed. The Windows check used a standalone executable, with the CMake linkage and native Windows left to CI. 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/9584:upstream-pr/9584'
git switch 'upstream-pr/9584'

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