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

Manually merged
github merged 1 commit from github-bot/gh-2834 into gh-pr/2834/base 2026-11-29 22:58:46 +00:00 AGit
Owner

@⁠101Leafy on GitHub · 2026-11-29 17:53 UTC · original
101Leafy:nv/refused-ask → main · +126 −0 · 1 files · 1 commits · merged 2026-11-29 22:54 UTC

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.

**@⁠101Leafy** on GitHub · 2026-11-29 17:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2834) `101Leafy:nv/refused-ask` → `main` · +126 −0 · 1 files · 1 commits · merged 2026-11-29 22:54 UTC 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 17:55:59 +00:00
github-bot changed target branch from main to gh-pr/2834/base 2026-11-29 22:58:02 +00:00
github manually merged commit 897b0f9240 into gh-pr/2834/base 2026-11-29 22:58:03 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!2834
No description provided.