Repository navigation
KernelX: audit thread priority mappings and CPU affinity mask bounds (#106) - #1609
slopgobblercobbler wants to merge 1 commit into
Conversation
…nds for 7-core environments
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review; I checked the sparse-mask case against the added implementation and tests.
| if (allowed >> b) & 1 != 0 { | ||
| m | (1 << b) | ||
| } else { | ||
| m | (1 << pcs[b as usize % pcs.len()]) |
There was a problem hiding this comment.
A mixed mask can collapse onto one allowed CPU. For mask = 0b0111 and allowed = 0b1010, CPUs 0 and 2 map to pcs[0] (CPU 1), while requested CPU 1 is retained, so this returns only 0b0010 and 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 against affinity_masks_outside_the_process_are_fitted.
|
Regression run for this PR: head main 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. |
gut0to
left a comment
There was a problem hiding this comment.
CONTRIBUTING.md also requires the full workspace GPU suite and a real-title regression comparison for runtime changes. This description reports only cargo test -p xcl -- kernelx and no scripts/smoke.ps1 blocks for main and this head. Please add both results before merge, including the skipped GPU test names. AI-assisted review; I checked the Tested and Regression run sections against the guide.
|
Full-suite GPU run (NVIDIA and AMD), which the review above asks for. Tested exact head Tested
Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
… upstream xcl-dev#1609 priority half) Windows hle/kernelx.rs + resolver.rs hunks verbatim reference-only (cfg(windows)-only): THREAD_PRIORITY_ERROR_RETURN, map_thread_priority, Set/GetThreadPriority, Set/GetThreadPriorityBoost, 4 export rows, SetThreadPriority resolver row, priority test. Linux twin hle/kernelx_linux.rs: map + map-before-store, Get null/unknown error return, new Boost fns, export rows; hle_linux sync count 69->73. Affinity/ideal half stays for step-80 (old fit intact, 0 new hits).
…rt upstream xcl-dev#1609 affinity/ideal half) Windows hle/kernelx.rs hunks verbatim reference-only (cfg(windows)-only): PROCESSOR_NUMBER + sys SetThreadIdealProcessor/Ex imports, 2 export rows, CONSOLE_TITLE consts, SetThreadpoolAffinityMask validation, partial-overlap fit_affinity_mask rewrite, affinity null/zero guards, fit_ideal_processor + SetThreadIdealProcessor/Ex, affinity/ideal tests. Linux twin hle/kernelx_linux.rs: CONSOLE_TITLE consts, partial-overlap fit rewrite, null/zero guards on all three affinity fns, PROCESSOR_NUMBER + fit_ideal_processor + IdealProcessor fns (best-effort record-only, no affinity change: an ideal processor is a hint, not a pin), export rows; hle_linux sync count 73->75; resolver SetThreadIdealProcessor row. Rebases onto step-79 (shared exports table, landed a6b1181). Failing-first: extended fit + new guard tests FAILED pre-fix, green after.
|
Nothing has happened on this PR for 3 days, so it is marked |
|
No open or merged PR makes the same change: main does not hook SetThreadPriority / SetThreadIdealProcessor, and its
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Summary
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