VICTORY_CACHE_CORES: read the processors' cache records to the last one (it was always skipped) #284
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/284"
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?
Imported from avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T14:22:26Z.
cores.rsl3_of_sets(used byVICTORY_CACHE_CORES, from #147) walked the recordsGetLogicalProcessorInformationEx(RelationCache)writes, but only while a wholeSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX(80 bytes) still fit. Each cache record states its own, smaller size (56 bytes: the union is as large as its largest member). So:fast_by_cachewould then pick the complex without the stacked cache as the fast one.Fix: a pure function,
largest_caches(&[u8]). It walks the records by their ownSize, stops at a zero or truncated size, and copies each record's own bytes into a zeroed structure before reading it, so nothing outside a record is read.l3_of_setscalls it on the bytes the system returned. The buffer is nowu8, and the copy makes alignment irrelevant.Test:
the_last_cache_record_is_read_toouses synthetic records: two complexes of eight processors, with the stacked 96 MiB L3 listed last. With the old bound the stacked complex came out at 1 MiB (its L2s) and the other complex was picked. Now each complex has its L3, andfast_by_cachepicks processors 8–15. A record cut short and a record of size 0 are also covered. The test fails with the old bound and passed 10 runs out of 10 with the fix.Results:
cargo test -p victory-gpu --locked: 382 passed, 34 ignored.-D warningsadds nothing beyond main's existingwatch.rslint, which #241 fixes.I can't show that Windows ever lists an L3 last on real hardware, so the practical impact may be nil. The out-of-bounds read is fixed either way.
🤖 Generated with Claude Code
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.