Write watch: don't ask the kernel again about ranges it refused #2834

Merged
101Leafy merged 1 commit from upstream-pr/2834 into main 2026-11-29 22:54:42 +00:00
101Leafy commented 2026-11-29 17:53:32 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 101Leafy on 2026-11-29T17:53:32Z.


GetWriteWatch refuses ranges that cross reservations, and ranges over views. Today every frame asks the kernel about the same refused ranges again, though nothing about them changed, and each refusal costs a kernel call before the range falls back to guards.

This keeps the refused ranges per thread (no lock shared between threads) and skips asking about them again for 64 frames. A refusal is dropped early when the title allocator reports write-watched memory over it through title_memory_allocated, since that is the only change that can turn a refusal into an answer. Freed memory and mapped or unmapped views stay refused. A small hashed bitmap of the MiB that refused ranges touched keeps allocations elsewhere from taking the lock.

Keeping a refusal by mistake only costs time: the range is guarded as any refused range is, and the next asking after it finds every page written since.

VICTORY_REFUSED_KEEP=0 turns it off (every asking goes to the kernel, as before).

Measured on our fork's build, 20 s of a title's intro (60-80 s in):

before after
refused askings a frame 65.5 19.6
time in refused kernel calls a frame 2.57 ms 0.40 ms

The picture was unchanged.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5553454029 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2834). Originally posted by [101Leafy](https://github.com/101Leafy) on 2026-11-29T17:53:32Z. --- GetWriteWatch refuses ranges that cross reservations, and ranges over views. Today every frame asks the kernel about the same refused ranges again, though nothing about them changed, and each refusal costs a kernel call before the range falls back to guards. This keeps the refused ranges per thread (no lock shared between threads) and skips asking about them again for 64 frames. A refusal is dropped early when the title allocator reports write-watched memory over it through `title_memory_allocated`, since that is the only change that can turn a refusal into an answer. Freed memory and mapped or unmapped views stay refused. A small hashed bitmap of the MiB that refused ranges touched keeps allocations elsewhere from taking the lock. Keeping a refusal by mistake only costs time: the range is guarded as any refused range is, and the next asking after it finds every page written since. `VICTORY_REFUSED_KEEP=0` turns it off (every asking goes to the kernel, as before). Measured on our fork's build, 20 s of a title's intro (60-80 s in): | | before | after | |---|---|---| | refused askings a frame | 65.5 | 19.6 | | time in refused kernel calls a frame | 2.57 ms | 0.40 ms | The picture was unchanged.
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
trustno1-coder/VIctory-NVIDIA!2834
No description provided.