KernelX: audit thread priority mappings and CPU affinity mask bounds (#106) #1609
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1609
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1609"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@slopgobblercobbler on GitHub · 2026-11-24 18:14 UTC · original
slopgobblercobbler:fix/kernelx-priority-affinity→main· +347 −8 · 2 files · 1 commits · openSummary
Audits thread priority mappings and CPU affinity mask bounds for console 7-core environments in
crates/xcl/src/hle/kernelx.rsandresolver.rs:map_thread_priorityto valid Win32 constants (3..=6->HIGHEST,>=7->TIME_CRITICAL,-14..=-3->LOWEST,<= -15->IDLE), preventing Windows NTERROR_INVALID_PARAMETER(87) failures.SetThreadPriority,GetThreadPriority,SetThreadPriorityBoost, andGetThreadPriorityBoost.ERROR_INVALID_HANDLE(6) and null pointer validation onp_disable_priority_boostreturningERROR_INVALID_PARAMETER(87).fit_affinity_mask: previously, mixed affinity masks (bits partially inside and partially outside process affinity) discarded out-of-process console cores completely. The updated mapping retains in-process bits and maps out-of-process console cores modulo host available processors.CONSOLE_TITLE_CORES(7),CONSOLE_TITLE_AFFINITY_MASK(0x7F),CONSOLE_TITLE_SMT_AFFINITY_MASK(0x3FFF).fit_ideal_processor,SetThreadIdealProcessor, andSetThreadIdealProcessorEx, mapping console core IDs onto available host processors and validating null out-pointers and handles.SetThreadpoolAffinityMask: validates null threadpool pointers and zero affinity masks, returningERROR_INVALID_PARAMETER.SetThreadAffinityMaskandSetThreadGroupAffinity: validates null thread handles (ERROR_INVALID_HANDLE) and zero masks (ERROR_INVALID_PARAMETER).affinity_masks_outside_the_process_are_fittedset_thread_affinity_mask_takes_console_masksthreadpool_affinity_mask_validation_and_boundsideal_processor_bounds_and_fittingthread_priority_mappings_and_error_handlingChanges
crates/xcl/src/hle/kernelx.rs: thread priority tier mappings, affinity bounds fitting, and validation.crates/xcl/src/resolver.rs: exported thread priority and ideal processor APIs.Tested
cargo test -p xcl -- kernelx: 35 passed, 0 failed.upstream/main, GPL-2.0-only compliant, zero retail game data or keys.Not Tested
AI Use
Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
@Anon64 on GitHub · 2026-11-24 18:23 UTC · original
Regression run for this PR: head
a7e3240, based onmain9e3831e. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, back to back with themainrun.main
9e3831e:this PR:
No device removals or crashes; 95 % of main's frames, 98 % of its peak commit.
Peak commit on this machine is mostly the pipeline preload's DXC compiles (#1035) and varies a lot from run to run, so it says little about this PR.
Not tested: the whole suite; whether the title reaches the changed code in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@futurepro62 on GitHub · 2026-11-24 19:00 UTC · original
Full-suite GPU run (NVIDIA and AMD), which the review above asks for. Tested exact head
a7e3240(on its base9e3831e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 778 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.threadpool_affinity_mask_validation_and_bounds,ideal_processor_bounds_and_fitting,thread_priority_mappings_and_error_handling.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 779 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).heap_window_out_of_memory_falls_back_to_the_switch_formwas skipped with--skip. It fails on main9e3831etoo, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWSunset). Reported as #1651.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 20:30 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
@ -1439,0 +1475,4 @@if (allowed >> b) & 1 != 0 {m | (1 << b)} else {m | (1 << pcs[b as usize % pcs.len()])@gut0to on GitHub · 2026-11-24 18:21 UTC · original
A mixed mask can collapse onto one allowed CPU. For
mask = 0b0111andallowed = 0b1010, CPUs 0 and 2 map topcs[0](CPU 1), while requested CPU 1 is retained, so this returns only0b0010and never uses allowed CPU 3. This leaves a title that requested three processors pinned to one even though two are available. Could the remapping distribute out-of-range bits without duplicating a retained CPU where possible? AI-assisted review; I verified this case againstaffinity_masks_outside_the_process_are_fitted.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.